Makefile (876B)
1CFLAGS = -I include -g 2LDLIBS = 3DEPFLAGS = -MT $@ -MMD -MP -MF build/$*.d 4 5_SRCS = idx.c 6SRCS = $(_SRCS:%.c=src/%.c) 7OBJS = $(_SRCS:%.c=build/%.o) 8DEPS = $(_SRCS:%.c=build/%.d) 9PI_OBJS = $(_SRCS:%.c=build/%.pi.o) 10 11.PHONY: all clean 12 13all: build/libidx.so build/libidx.a build/test 14 15clean: 16 rm -rf build 17 18build: 19 mkdir build 20 21build/%.o: src/%.c build/%.d | build 22 $(CC) -c -o $@ $< $(DEPFLAGS) $(CFLAGS) 23 24build/%.pi.o: src/%.c build/%.d | build 25 $(CC) -c -o $@ $< $(DEPFLAGS) $(CFLAGS) -fPIC 26 27build/%.d: | build; 28 29include $(DEPS) 30 31build/libidx.a: $(OBJS) | build 32 $(CC) -o build/tmp.o $^ $(CFLAGS) -r 33 objcopy --keep-global-symbols=libidx.api build/tmp.o build/fixed.o 34 ar rcs $@ build/fixed.o 35 36build/libidx.so: $(PI_OBJS) | build 37 $(CC) -o $@ $(PI_OBJS) $(CFLAGS) -shared -Wl,-version-script libidx.lds 38 39build/test: src/test.c build/libidx.a | build 40 $(CC) -o $@ $^ $(CFLAGS) 41