Makefile (1147B)
1 TARGET?= 2 3 BIN=sfinx 4 5 SRC:= 6 SRC+=$(wildcard src/*.c) 7 SRC+=$(wildcard src/*/*.c) 8 SRC+=$(wildcard src/*/*/*.c) 9 10 CFLAGS?=-Wall -Wextra -O2 11 LDFLAGS?= 12 13 # Drop unreferenced code: dependencies export whole libraries, of which we use a part 14 CFLAGS +=-ffunction-sections -fdata-sections 15 ifeq ($(shell uname -s),Darwin) 16 LDFLAGS+=-Wl,-dead_strip 17 else 18 LDFLAGS+=-Wl,--gc-sections 19 endif 20 21 # pthread backs the optional worker pool in sfinx.c; the library manifest leaves it to the consumer 22 CFLAGS +=-pthread 23 LDFLAGS+=-pthread 24 25 ifneq ($(SFINX_VERSION),) 26 CFLAGS +=-DSFINX_VERSION='"$(SFINX_VERSION)"' 27 endif 28 29 INCLUDES:= 30 INCLUDES+=-I src 31 32 include lib/.dep/config.mk 33 34 # Target-specific overrides, optional. 35 # Supplied by target/<target>/Makefile.target 36 -include Makefile.target 37 38 CFLAGS+=$(INCLUDES) 39 40 OBJ:=$(SRC:.c=.o) 41 42 .PHONY: default 43 default: $(BIN) 44 45 lib/.dep/config.mk: 46 @dep install 47 48 %.o: %.c $(LIBS) 49 $(CC) $(CFLAGS) $(@:.o=.c) -D__NAME=\"$(BIN)\" -D__TARGET=\"$(TARGET)\" -c -o $@ 50 51 $(BIN): $(OBJ) 52 $(CC) $(CFLAGS) $(OBJ) $(LDFLAGS) -o $@ 53 54 .PHONY: clean 55 clean: 56 rm -f $(OBJ) $(BIN) 57 58 .PHONY: install 59 install: $(BIN) 60 install -Dm0755 $(BIN) $(DESTDIR)/usr/bin/$(BIN)