1OS := $(shell uname) 2LIBSOURCES = $(wildcard c/common/*.c) $(wildcard c/dec/*.c) \ 3 $(wildcard c/enc/*.c) 4SOURCES = $(LIBSOURCES) c/tools/brotli.c 5BINDIR = bin 6OBJDIR = $(BINDIR)/obj 7LIBOBJECTS = $(addprefix $(OBJDIR)/, $(LIBSOURCES:.c=.o)) 8OBJECTS = $(addprefix $(OBJDIR)/, $(SOURCES:.c=.o)) 9LIB_A = libbrotli.a 10EXECUTABLE = brotli 11DIRS = $(OBJDIR)/c/common $(OBJDIR)/c/dec $(OBJDIR)/c/enc \ 12 $(OBJDIR)/c/tools $(BINDIR)/tmp 13CFLAGS += -O2 14ifeq ($(os), Darwin) 15 CPPFLAGS += -DOS_MACOSX 16endif 17 18all: test 19 @: 20 21.PHONY: all clean test 22 23$(DIRS): 24 mkdir -p $@ 25 26$(EXECUTABLE): $(OBJECTS) 27 $(CC) $(LDFLAGS) $(OBJECTS) -lm -o $(BINDIR)/$(EXECUTABLE) 28 29lib: $(LIBOBJECTS) 30 rm -f $(LIB_A) 31 ar -crs $(LIB_A) $(LIBOBJECTS) 32 33test: $(EXECUTABLE) 34 tests/compatibility_test.sh 35 tests/roundtrip_test.sh 36 37clean: 38 rm -rf $(BINDIR) $(LIB_A) 39 40.SECONDEXPANSION: 41$(OBJECTS): $$(patsubst %.o,%.c,$$(patsubst $$(OBJDIR)/%,%,$$@)) | $(DIRS) 42 $(CC) $(CFLAGS) $(CPPFLAGS) -Ic/include \ 43 -c $(patsubst %.o,%.c,$(patsubst $(OBJDIR)/%,%,$@)) -o $@ 44