about summary refs log tree commit diff stats
path: root/makefile
diff options
context:
space:
mode:
authorRen Kararou <[email protected]>2025-01-30 06:12:18 -0600
committerRen Kararou <[email protected]>2025-01-30 06:12:18 -0600
commit1e468866fc4455193df8d33b1711b6519dd4c721 (patch)
tree4c8478fabe1b5b189e443efe0332cdb2319bc07e /makefile
downloadlibspicy-1e468866fc4455193df8d33b1711b6519dd4c721.tar.gz
libspicy-1e468866fc4455193df8d33b1711b6519dd4c721.tar.bz2
libspicy-1e468866fc4455193df8d33b1711b6519dd4c721.zip
spicy allocator get!
Diffstat (limited to 'makefile')
-rw-r--r--makefile53
1 files changed, 53 insertions, 0 deletions
diff --git a/makefile b/makefile
new file mode 100644
index 0000000..26595fd
--- /dev/null
+++ b/makefile
@@ -0,0 +1,53 @@
+CC:=clang
+AR:=llvm-ar
+CFLAGS:=-march=native -O3 -funroll-loops -Wall -Wextra -Werror -fPIC
+LDFLAGS:=-flto=thin -lpthread
+
+ifeq ($(shell uname),SunOS)
+CC = gcc
+LDFLAGS += -lsocket
+CFLAGS += -std=gnu11
+else
+CFLAGS += -std=c11
+endif
+
+INCLUDES=-Iinc/
+
+OBJECTS=obj/salloc.o
+
+.PHONY: all
+all: build/lib/libspicy.so build/lib/static/libspicy.a includes
+
+.PHONY: includes
+includes:
+	@if [ ! -d "build/include/libspicy" ]; then mkdir -p build/include/libspicy; fi
+	@cp -v inc/*.h build/include/libspicy/
+
+.PHONY: release
+release: all build/rel/libspicy.so build/dbg/libspicy.so.debug
+
+build/rel/%: build/lib/%
+	@if [ ! -d "build/rel" ]; then mkdir -p build/rel; fi
+	strip -s -o $@ $<
+
+build/dbg/%.debug: build/lib/%
+	@if [ ! -d "build/dbg" ]; then mkdir -p build/dbg; fi
+	strip --only-keep-debug -o $@ $<
+
+build/lib/%.so: $(OBJECTS)
+	@if [ ! -d "build/lib" ]; then mkdir -p build/lib; fi
+	$(CC) -g -shared $(CFLAGS) $(LDFLAGS) -o $@ $^
+
+build/lib/static/%.a: $(OBJECTS)
+	@if [ ! -d "build/lib/static" ]; then mkdir -p build/lib/static; fi
+	$(AR) rcs $@ $^
+
+obj/%.o: src/%.c inc/%.h
+	@if [ ! -d "obj" ]; then mkdir -p obj; fi
+	$(CC) -g -c $(INCLUDES) $(CFLAGS) -o $@ $<
+
+.PHONY: clean
+clean:
+	@rm -rf obj
+	@rm -rf build
+