Cleanup test/Makefile, fix src install target ENGINE-228
authorDamiano Boppart <damiano@pep-security.net>
Thu, 17 Aug 2017 16:01:20 +0000
branchENGINE-228
changeset 19709f55b8970727
parent 1969 ba5eb0aa23a4
child 1971 975a44e59f31
Cleanup test/Makefile, fix src install target
.hgignore
src/Makefile
test/Makefile
     1.1 --- a/.hgignore	Thu Aug 17 13:36:49 2017 +0000
     1.2 +++ b/.hgignore	Thu Aug 17 16:01:20 2017 +0000
     1.3 @@ -3,6 +3,7 @@
     1.4  ^asn\.1/Makefile\.am\.sample$
     1.5  ^asn\.1/libasn1\.a$
     1.6  .*xcuserdata/
     1.7 +^build/
     1.8  
     1.9  syntax: glob
    1.10  *.orig
     2.1 --- a/src/Makefile	Thu Aug 17 13:36:49 2017 +0000
     2.2 +++ b/src/Makefile	Thu Aug 17 16:01:20 2017 +0000
     2.3 @@ -78,6 +78,7 @@
     2.4  
     2.5  .PHONY: install
     2.6  install: $(TARGET)
     2.7 +	mkdir -p "$(PREFIX)/lib/"
     2.8  	cp $< $(PREFIX)/lib/
     2.9  	mkdir -p $(PREFIX)/include/pEp
    2.10  	cp pEpEngine.h keymanagement.h message_api.h dynamic_api.h stringlist.h timestamp.h identity_list.h bloblist.h stringpair.h message.h mime.h cryptotech.h sync.h sync_fsm.h sync_app.h blacklist.h openpgp_compat.h $(PREFIX)/include/pEp/
     3.1 --- a/test/Makefile	Thu Aug 17 13:36:49 2017 +0000
     3.2 +++ b/test/Makefile	Thu Aug 17 16:01:20 2017 +0000
     3.3 @@ -7,49 +7,59 @@
     3.4  
     3.5  include ../Makefile.conf
     3.6  
     3.7 -LDFLAGS+= $(ETPAN_LIB) -L../asn.1
     3.8 -LDLIBS?=-letpan -lpEpEngine -lstdc++ -lasn1
     3.9 +TARGET=pEpEngineTest
    3.10 +
    3.11 +unexport GNUPGHOME
    3.12 +TEST_HOME=$(HERE)/test_home
    3.13 +TEST_GNUPGHOME=$(TEST_HOME)/.gnupg
    3.14 +
    3.15 +LDFLAGS+= $(ETPAN_LIB) -L../asn.1 -L../src
    3.16 +LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1
    3.17 +
    3.18  ifeq ($(BUILD_FOR),Linux)
    3.19 -	LDLIBS+= -luuid
    3.20 +    LDLIBS+= -luuid
    3.21  endif
    3.22  
    3.23  ifeq ("$(OPENPGP)","NETPGP")
    3.24 -	LDLIBS+= -lnetpgp
    3.25 +    LDLIBS+= -lnetpgp
    3.26  endif
    3.27  
    3.28 -TARGET=pEpEngineTest
    3.29 +ifeq ($(shell uname),Darwin)
    3.30 +    LIBPATH=DYLD_LIBRARY_PATH
    3.31 +    LLDB_BIN=/Applications/Xcode.app/Contents/Developer/usr/bin/lldb
    3.32 +else
    3.33 +    LIBPATH=LD_LIBRARY_PATH
    3.34 +    LLDB_BIN=lldb
    3.35 +endif
    3.36 +
    3.37 +# Create a list of the extra library paths for the loader. We do not assume that the engine and its dependencies are not installed for testing.
    3.38 +# Note that += can not be used here, as it changes the amount of whitespace
    3.39 +EXTRA_LIB_PATHS=../src:
    3.40 +ifdef ETPAN_LIB
    3.41 +    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
    3.42 +endif
    3.43 +ifdef GPGME_LIB
    3.44 +    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
    3.45 +endif
    3.46 +ifdef NETPGP_LIB
    3.47 +    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)):
    3.48 +endif
    3.49 +# Remove trailing ':'
    3.50 +EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
    3.51 +
    3.52 +TEST_CMD_PFX=$(LIBPATH)=$(EXTRA_LIB_PATHS) HOME=$(TEST_HOME)
    3.53  
    3.54  UNIT_TESTS_SOURCE=$(wildcard *_test.cc)
    3.55  UNIT_TESTS=$(subst .cc,,$(UNIT_TESTS_SOURCE))
    3.56  UNIT_TESTS_RUN=$(subst .cc,_run,$(UNIT_TESTS_SOURCE))
    3.57  
    3.58 +.PHONY: all
    3.59  all: $(TARGET) $(UNIT_TESTS)
    3.60  
    3.61 -.PHONY: clean
    3.62 -
    3.63  # don't delete .o files!
    3.64  .PRECIOUS: %.o
    3.65  
    3.66 -unexport GNUPGHOME;
    3.67 -TEST_HOME=$(HERE)/test_home
    3.68 -TEST_GNUPGHOME=$(TEST_HOME)/.gnupg
    3.69 -
    3.70 -ifeq ($(shell which gpg2), )
    3.71 -    GPG_CMD = gpg
    3.72 -else
    3.73 -    GPG_CMD = gpg2
    3.74 -endif
    3.75 -
    3.76 -ifeq ($(shell uname), Darwin)
    3.77 -    LIBPATH = DYLD_LIBRARY_PATH
    3.78 -    LLDB_BIN = /Applications/Xcode.app/Contents/Developer/usr/bin/lldb
    3.79 -else
    3.80 -    LIBPATH = LD_LIBRARY_PATH
    3.81 -    LLDB_BIN = lldb
    3.82 -endif
    3.83 -
    3.84 -TEST_CMD_PFX = $(LIBPATH)=$(HOME)/lib:../src HOME=$(TEST_HOME)
    3.85 -
    3.86 +.PHONY: test_home_
    3.87  test_home_: 
    3.88  	-gpgconf --kill gpg-agent
    3.89  	-HOME=$(TEST_HOME) gpgconf --kill gpg-agent
    3.90 @@ -58,12 +68,14 @@
    3.91  	mkdir -p $(TEST_GNUPGHOME)/private-keys-v1.d
    3.92  	$(GPG_CMD) --import --batch --homedir $(TEST_GNUPGHOME) 0x*.asc *_sec.asc
    3.93  
    3.94 +.PHONY: clean
    3.95  clean:
    3.96  	rm -f *.o $(TARGET) *.a *~ $(UNIT_TESTS) pep_Dokument_Titel.pdf msg4.asc
    3.97  	rm -Rf *.dSYM $(TEST_HOME) pubring.gpg secring.gpg random_seed *.conf trustdb.gpg
    3.98  
    3.99 -test: pEpEngineTest test_home_
   3.100 -	$(TEST_CMD_PFX) ./pEpEngineTest
   3.101 +.PHONY: test
   3.102 +test: $(TARGET) test_home_
   3.103 +	$(TEST_CMD_PFX) ./$<
   3.104  
   3.105  %_test : %_test.o test_util.o
   3.106  	 $(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS)
   3.107 @@ -80,7 +92,10 @@
   3.108  %_gdb : % test_home_
   3.109  	$(TEST_CMD_PFX) gdb ./$<
   3.110  
   3.111 +.PHONY: unit_tests
   3.112  unit_tests: $(UNIT_TESTS) $(UNIT_TESTS_RUN)
   3.113  
   3.114 +# Installs the engine, not the test binaries
   3.115 +.PHONY: install
   3.116  install:
   3.117 -	make -C .. install
   3.118 +	$(MAKE) -C .. install