brotli/Makefile

56 lines
1.4 KiB
Makefile
Raw Normal View History

2016-06-24 13:32:51 +00:00
OS := $(shell uname)
LIBSOURCES = $(wildcard c/common/*.c) $(wildcard c/dec/*.c) \
$(wildcard c/enc/*.c)
SOURCES = $(LIBSOURCES) c/tools/brotli.c
2016-06-24 13:32:51 +00:00
BINDIR = bin
OBJDIR = $(BINDIR)/obj
LIBOBJECTS = $(addprefix $(OBJDIR)/, $(LIBSOURCES:.c=.o))
2016-06-24 13:32:51 +00:00
OBJECTS = $(addprefix $(OBJDIR)/, $(SOURCES:.c=.o))
LIB_A = libbrotli.a
EXECUTABLE = brotli
DIRS = $(OBJDIR)/c/common $(OBJDIR)/c/dec $(OBJDIR)/c/enc \
$(OBJDIR)/c/tools $(BINDIR)/tmp
2016-06-24 13:32:51 +00:00
CFLAGS += -O2
ifeq ($(os), Darwin)
CPPFLAGS += -DOS_MACOSX
endif
ifneq ($(strip $(CROSS_COMPILE)), )
CC=$(CROSS_COMPILE)-gcc
ARCH=$(firstword $(subst -, ,$(CROSS_COMPILE)))
BROTLI_WRAPPER="qemu-$(ARCH) -L /usr/$(CROSS_COMPILE)"
endif
# The arm-linux-gnueabi compiler defaults to Armv5. Since we only support Armv7
# and beyond, we need to select Armv7 explicitly with march.
ifeq ($(ARCH), arm)
CFLAGS += -march=armv7-a -mfloat-abi=hard -mfpu=neon
endif
2016-06-24 13:32:51 +00:00
all: test
@:
2016-06-24 13:32:51 +00:00
.PHONY: all clean test
2016-06-24 13:32:51 +00:00
$(DIRS):
mkdir -p $@
2016-06-24 13:32:51 +00:00
$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -lm -o $(BINDIR)/$(EXECUTABLE)
2016-06-24 13:32:51 +00:00
lib: $(LIBOBJECTS)
rm -f $(LIB_A)
ar -crs $(LIB_A) $(LIBOBJECTS)
2016-06-24 13:32:51 +00:00
test: $(EXECUTABLE)
tests/compatibility_test.sh $(BROTLI_WRAPPER)
tests/roundtrip_test.sh $(BROTLI_WRAPPER)
2016-06-24 13:32:51 +00:00
clean:
rm -rf $(BINDIR) $(LIB_A)
.SECONDEXPANSION:
$(OBJECTS): $$(patsubst %.o,%.c,$$(patsubst $$(OBJDIR)/%,%,$$@)) | $(DIRS)
$(CC) $(CFLAGS) $(CPPFLAGS) -Ic/include \
-c $(patsubst %.o,%.c,$(patsubst $(OBJDIR)/%,%,$@)) -o $@