Makefile revision 5b372b684ac4f9585fb2a00098d77f959bec0074
1# Default options 2USE_BSDIFF ?= y 3 4BINARIES-y = bspatch 5BINARIES-$(USE_BSDIFF) += bsdiff 6 7BINARIES += $(BINARIES-y) 8 9INSTALL = install 10CFLAGS += -O3 -Wall -Werror 11CXXFLAGS += -std=c++11 12 13DESTDIR ?= 14PREFIX = /usr 15BINDIR = $(PREFIX)/bin 16DATADIR = $(PREFIX)/share 17MANDIR = $(DATADIR)/man 18MAN1DIR = $(MANDIR)/man1 19INSTALL_PROGRAM ?= $(INSTALL) -c -m 755 20INSTALL_MAN ?= $(INSTALL) -c -m 444 21 22.PHONY: all test clean 23all: $(BINARIES) 24test: unittests 25clean: 26 rm -f *.o $(BINARIES) unittests 27 28BSDIFF_LIBS = -lbz2 -ldivsufsort -ldivsufsort64 29BSDIFF_OBJS = \ 30 bsdiff.o 31 32BSPATCH_LIBS = -lbz2 33BSPATCH_OBJS = \ 34 bspatch.o \ 35 extents.o \ 36 extents_file.o \ 37 file.o \ 38 memory_file.o 39 40UNITTEST_LIBS = -lgmock -lgtest -lpthread 41UNITTEST_OBJS = \ 42 bsdiff_unittest.o \ 43 bspatch_unittest.o \ 44 extents_file_unittest.o \ 45 extents_unittest.o \ 46 test_utils.o \ 47 testrunner.o 48 49bsdiff: $(BSDIFF_OBJS) bsdiff_main.o 50bsdiff: LDLIBS += $(BSDIFF_LIBS) 51 52bspatch: $(BSPATCH_OBJS) bspatch_main.o 53bspatch: LDLIBS += $(BSPATCH_LIBS) 54 55unittests: LDLIBS += $(BSDIFF_LIBS) $(BSPATCH_LIBS) $(UNITTEST_LIBS) 56unittests: $(BSPATCH_OBJS) $(BSDIFF_OBJS) $(UNITTEST_OBJS) 57 58unittests bsdiff bspatch: 59 $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $^ $(LDLIBS) 60 61# Source file dependencies. 62bsdiff.o: bsdiff.cc 63bsdiff_main.o: bsdiff_main.cc bsdiff.h 64bsdiff_unittest.o: bsdiff_unittest.cc bsdiff.h test_utils.h 65bspatch.o: bspatch.cc bspatch.h extents.h extents_file.h file_interface.h \ 66 file.h 67bspatch_main.o: bspatch_main.cc bspatch.h 68bspatch_unittest.o: bspatch_unittest.cc bspatch.h test_utils.h 69extents.o: extents.cc extents.h extents_file.h file_interface.h 70extents_file.o: extents_file.cc extents_file.h file_interface.h 71extents_file_unittest.o: extents_file_unittest.cc extents_file.h \ 72 file_interface.h 73extents_unittest.o: extents_unittest.cc extents.h extents_file.h \ 74 file_interface.h 75file.o: file.cc file.h file_interface.h 76memory_file.o: memory_file.cc memory_file.h file_interface.h 77testrunner.o: testrunner.cc 78test_utils.o: test_utils.cc test_utils.h 79 80install: 81 mkdir -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(MAN1DIR) 82 $(INSTALL_PROGRAM) $(BINARIES) $(DESTDIR)$(BINDIR) 83ifndef WITHOUT_MAN 84 $(INSTALL_MAN) $(BINARIES:=.1) $(DESTDIR)$(MAN1DIR) 85endif 86