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