SRC = $(wildcard src/*.c) INCLUDE = include CFLAGS = -Wall $(addprefix -I,$(INCLUDE)) --std=gnu11 -pedantic CFLAGS+= -O3 -flto -fgraphite LDFLAGS = -O3 -flto OBJ:= obj STATIC = $(addprefix $(OBJ)/static/,$(SRC:.c=.o)) SHARED = $(addprefix $(OBJ)/shared/,$(SRC:.c=.o)) BUILD = librc .PHONY: all all: dirs $(BUILD) dirs: @mkdir -p obj/{shared,static}/src obj/static/%.o: %.c $(CC) -c $< $(CFLAGS) -o $@ obj/shared/%.o: %.c $(CC) -fPIC -c $< $(CFLAGS) -o $@ $(BUILD).a: $(STATIC) ar rcs $@ $^ $(BUILD).so: $(SHARED) $(CC) -shared $^ $(CFLAGS) -o $@ $(LDFLAGS) strip $@ $(BUILD): $(BUILD).a $(BUILD).so clean: rm -f $(BUILD).{a,so} rm -rf obj