14384370cec4c917dd5d093546ac524b13e8d7dbaAlex Deymo# Default options 24384370cec4c917dd5d093546ac524b13e8d7dbaAlex DeymoUSE_BSDIFF ?= y 34384370cec4c917dd5d093546ac524b13e8d7dbaAlex Deymo 4ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex DeymoEXECUTABLES-y := bspatch 5ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex DeymoLIBRARIES-y := libbspatch.so 6ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex DeymoEXECUTABLES-$(USE_BSDIFF) += bsdiff 7ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex DeymoLIBRARIES-$(USE_BSDIFF) += libbsdiff.so 84384370cec4c917dd5d093546ac524b13e8d7dbaAlex Deymo 9ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex DeymoBINARIES := $(EXECUTABLES-y) $(LIBRARIES-y) 10c285feace7a051368d4c5069cc6e0f30cd769f0dThe Android Open Source Project 1199b5374de3cf896b8b77779798218be279bda210Gilad ArnoldINSTALL = install 12ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex DeymoCPPFLAGS += -Iinclude 13ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex DeymoCXXFLAGS += -std=c++11 -O3 -Wall -Werror -fPIC 14c285feace7a051368d4c5069cc6e0f30cd769f0dThe Android Open Source Project 1599b5374de3cf896b8b77779798218be279bda210Gilad ArnoldDESTDIR ?= 1699b5374de3cf896b8b77779798218be279bda210Gilad ArnoldPREFIX = /usr 1799b5374de3cf896b8b77779798218be279bda210Gilad ArnoldBINDIR = $(PREFIX)/bin 1899b5374de3cf896b8b77779798218be279bda210Gilad ArnoldDATADIR = $(PREFIX)/share 1999b5374de3cf896b8b77779798218be279bda210Gilad ArnoldMANDIR = $(DATADIR)/man 2099b5374de3cf896b8b77779798218be279bda210Gilad ArnoldMAN1DIR = $(MANDIR)/man1 21ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex DeymoINCLUDEDIR ?= $(PREFIX)/include 22ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex DeymoGENTOO_LIBDIR ?= lib 23ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex DeymoLIBDIR ?= $(PREFIX)/$(GENTOO_LIBDIR) 2499b5374de3cf896b8b77779798218be279bda210Gilad ArnoldINSTALL_PROGRAM ?= $(INSTALL) -c -m 755 2599b5374de3cf896b8b77779798218be279bda210Gilad ArnoldINSTALL_MAN ?= $(INSTALL) -c -m 444 2699b5374de3cf896b8b77779798218be279bda210Gilad Arnold 27ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo.PHONY: all test clean install 2899b5374de3cf896b8b77779798218be279bda210Gilad Arnoldall: $(BINARIES) 29ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymotest: bsdiff_unittest 3099b5374de3cf896b8b77779798218be279bda210Gilad Arnoldclean: 31ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo rm -f *.o $(BINARIES) bsdiff_unittest 32ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo 33ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo### List of source files for each project. Keep in sync with the Android.mk. 34ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo# "bsdiff" program. 35ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymobsdiff_src_files := \ 36ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo bsdiff.cc 37ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo 38ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo# "bspatch" program. 39ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymobspatch_src_files := \ 40ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo bspatch.cc \ 41ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo buffer_file.cc \ 42ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo extents.cc \ 43ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo extents_file.cc \ 44ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo file.cc \ 45ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo memory_file.cc \ 46ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo sink_file.cc 47ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo 48ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo# Unit test files. 49ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymobsdiff_common_unittests := \ 50ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo bsdiff_unittest.cc \ 51ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo bspatch_unittest.cc \ 52ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo extents_file_unittest.cc \ 53ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo extents_unittest.cc \ 54ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo test_utils.cc \ 55ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo testrunner.cc 56ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo 57ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo 58ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex DeymoBSDIFF_LIBS := -lbz2 -ldivsufsort -ldivsufsort64 59ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex DeymoBSDIFF_OBJS := $(bsdiff_src_files:.cc=.o) 60ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo 61ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex DeymoBSPATCH_LIBS := -lbz2 62ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex DeymoBSPATCH_OBJS := $(bspatch_src_files:.cc=.o) 63a5cff2283b9bc60da9f4e74ba07a2119f5616653Alex Deymo 645b372b684ac4f9585fb2a00098d77f959bec0074Sen JiangUNITTEST_LIBS = -lgmock -lgtest -lpthread 65ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex DeymoUNITTEST_OBJS := $(bsdiff_common_unittests:.cc=.o) 66a5cff2283b9bc60da9f4e74ba07a2119f5616653Alex Deymo 67a5cff2283b9bc60da9f4e74ba07a2119f5616653Alex Deymobsdiff: $(BSDIFF_OBJS) bsdiff_main.o 68a5cff2283b9bc60da9f4e74ba07a2119f5616653Alex Deymobsdiff: LDLIBS += $(BSDIFF_LIBS) 69ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymolibbsdiff.so: $(BSDIFF_OBJS) 70ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymolibbsdiff.so: LDLIBS += $(BSDIFF_LIBS) 71a5cff2283b9bc60da9f4e74ba07a2119f5616653Alex Deymo 72a5cff2283b9bc60da9f4e74ba07a2119f5616653Alex Deymobspatch: $(BSPATCH_OBJS) bspatch_main.o 73a5cff2283b9bc60da9f4e74ba07a2119f5616653Alex Deymobspatch: LDLIBS += $(BSPATCH_LIBS) 74ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymolibbspatch.so: $(BSPATCH_OBJS) 75ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymolibbspatch.so: LDLIBS += $(BSPATCH_LIBS) 76ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo 77ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymobsdiff_unittest: LDLIBS += $(BSDIFF_LIBS) $(BSPATCH_LIBS) $(UNITTEST_LIBS) 78ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymobsdiff_unittest: $(BSPATCH_OBJS) $(BSDIFF_OBJS) $(UNITTEST_OBJS) 79a5cff2283b9bc60da9f4e74ba07a2119f5616653Alex Deymo 80ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymobsdiff_unittest bsdiff bspatch: 81ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo $(CXX) $(CXXFLAGS) -o $@ $^ $(LDLIBS) 8203f1debab429e673ba5e9e317c5a04e36e850cefAlex Deymo 83ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymolibbsdiff.so libbspatch.so: 84ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo $(CXX) $(CXXFLAGS) $(LDFLAGS) -Wl,-soname,$@ -shared -o $@ $^ $(LDLIBS) 85a5cff2283b9bc60da9f4e74ba07a2119f5616653Alex Deymo 86a5cff2283b9bc60da9f4e74ba07a2119f5616653Alex Deymo# Source file dependencies. 87ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymobspatch.o: bspatch.cc include/bsdiff/bspatch.h \ 88ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo include/bsdiff/extents_file.h include/bsdiff/file_interface.h \ 89ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo buffer_file.h extents.h file.h memory_file.h sink_file.h 90ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymobspatch_main.o: bspatch_main.cc include/bsdiff/bspatch.h \ 91ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo include/bsdiff/extents_file.h include/bsdiff/file_interface.h 92ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymobspatch_unittest.o: bspatch_unittest.cc include/bsdiff/bspatch.h \ 93ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo include/bsdiff/extents_file.h include/bsdiff/file_interface.h \ 94ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo test_utils.h 95ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymobuffer_file.o: buffer_file.cc buffer_file.h \ 96ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo include/bsdiff/file_interface.h include/bsdiff/bspatch.h \ 97ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo include/bsdiff/extents_file.h 98ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymoextents.o: extents.cc extents.h include/bsdiff/extents_file.h \ 99ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo include/bsdiff/file_interface.h 100ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymoextents_file.o: extents_file.cc include/bsdiff/extents_file.h \ 101ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo include/bsdiff/file_interface.h 102ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymoextents_file_unittest.o: extents_file_unittest.cc \ 103ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo include/bsdiff/extents_file.h include/bsdiff/file_interface.h 104ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymoextents_unittest.o: extents_unittest.cc extents.h \ 105ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo include/bsdiff/extents_file.h include/bsdiff/file_interface.h 106ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymofile.o: file.cc file.h include/bsdiff/file_interface.h 107ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymomemory_file.o: memory_file.cc memory_file.h \ 108ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo include/bsdiff/file_interface.h 109ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymosink_file.o: sink_file.cc sink_file.h include/bsdiff/file_interface.h 110ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymotestrunner.o: testrunner.cc test_utils.h 111a5cff2283b9bc60da9f4e74ba07a2119f5616653Alex Deymotest_utils.o: test_utils.cc test_utils.h 112c285feace7a051368d4c5069cc6e0f30cd769f0dThe Android Open Source Project 113c285feace7a051368d4c5069cc6e0f30cd769f0dThe Android Open Source Projectinstall: 114ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo mkdir -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(MAN1DIR) \ 115ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo $(DESTDIR)/$(INCLUDEDIR)/bsdiff 116ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo $(INSTALL_PROGRAM) $(EXECUTABLES-y) $(DESTDIR)$(BINDIR) 117ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo $(INSTALL_PROGRAM) $(LIBRARIES-y) $(DESTDIR)$(LIBDIR) 118ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo $(INSTALL) -c -m 644 include/bsdiff/*.h $(DESTDIR)/$(INCLUDEDIR)/bsdiff 11999b5374de3cf896b8b77779798218be279bda210Gilad Arnoldifndef WITHOUT_MAN 120ddf9db52938e67d4dcbf7c4f159b094eaddbabebAlex Deymo $(INSTALL_MAN) $(EXECUTABLES-y:=.1) $(DESTDIR)$(MAN1DIR) 12199b5374de3cf896b8b77779798218be279bda210Gilad Arnoldendif 122