author Krista Bennett <krista@pep-project.org>
Fri, 21 Dec 2018 11:14:10 +0100
changeset 3200 329005a93c6a
parent 3199 e16d89af41ad
child 3201 105b50dfaf15
permissions -rw-r--r--
Response to test/Makefile comments for damiano
     2 # Copyright 2017, pEp Foundation
     3 # This file is part of pEpEngine
     4 # This file may be used under the terms of the GNU General Public License version 3
     5 # see LICENSE.txt
     7 include ../default.conf
     9 # This is done this way because we presume that users who don't have python3 installed are also not bothering with the generated parts of the test suite (i.e. non-devs).
    10 # Tests will totally build and run without it.
    11 PY_ENV:=$(shell command -v python3 2> /dev/null)
    13 # Since you 'include' before evaluating CURDIR, I think it's possible that CURDIR does not have the value you think it might have. Yes, make is awkward.
    14 # KB: These are probably redundant anyway. But it is supposed to correspond to the directory in src/TestDriver.cc, which is whatever the cwd is that TestDriver is running in.
    15 #     It's a pretty trivial point anyway - it's only used in the clean target, and only really matters if tests were interrupted because of a seg fault or non-test assert;
    16 #     in that case, the test directory not being cleaned up *might* be problematic, but really probably isn't.
    17 HERE:=$(CURDIR)
    18 TEST_HOME=$(HERE)/pEp_test_home
    20 TARGET=TestDriver
    22 SRCS := $(wildcard src/*.cc) $(wildcard src/*/*.cc)
    23 OBJS := $(addsuffix .o,$(basename $(SRCS)))
    24 DEPS := $(OBJS:.o=.d)
    26 # Using '/usr/local/include' is very much a "works on my machine" solution to the problem. Either, the compiler search paths are enough, otherwise define a BLA_INC and BLA_LIB path to make clear to other developers what you are looking for outside the standard paths.
    27 # KB: Sure. Then fix that - again, audience of 1-4, and we needed to make our tests work. This file tends to get hacked when settings from above don't end up in compilation.
    28 INC_DIRS := ./include /usr/local/include ../src ../sync ../asn.1
    29 # Whoa dude... addprefix is brilliant. Why didn't I find this before!? This could make setting all the *_INC and *_LIB so much nicer!
    30 INC_FLAGS := $(addprefix -I,$(INC_DIRS)) $(GPGME_INC) $(CPPUNIT_INC)
    32 # '+=' is a magic assignment operators. It ensures that there is exactly one space between the old value and the suffix. Yes, this means it might strip spaces. At any rate, there is no need to add a space after the operator.
    33 # KB: I doubt this was in any way intentional.
    34 LDFLAGS+=-L/usr/local/lib
    36 # For setting both C and C++ compiler flags, there is CPPFLAGS
    37 # KB: This was almost certainly desperation because something wasn't working as it should. 
    38 CFLAGS+=-Wno-deprecated
    39 CXXFLAGS+=-Wno-deprecated
    40 CFLAGS:=$(filter-out -Wall,$(CFLAGS))
    42 LDFLAGS+= $(ETPAN_LIB) $(CPPUNIT_LIB) -L../asn.1 -L../src
    43 LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1
    45 # Caution: you're using tab to indent here, but none of the lines from here to 60 are recipes. Indentation should be done with spaces. This only works because Make is such a gratious tool. (Yeah, right...)
    46 # KB: Feel free to change it.
    47 ifeq ($(BUILD_FOR),Linux)
    48 	LDLIBS+= -luuid
    49 endif
    51 ifeq ($(OPENPGP),NETPGP)
    52 	LDLIBS+= -lnetpgp
    54 ifeq ($(BUILD_FOR),Linux)
    55 	LDLIBS+= -ltre
    56 endif
    57 endif
    59 ifdef SQLITE3_FROM_OS
    60 	LDLIBS+= -lsqlite3
    61 endif
    63 # Looks like both LIBPATH and LLDB_BIN aren't needed any more.
    64 # KB: I don't know. Building on MacOS is tetchy, so if it works without it, feel free to remove it.
    65 #     But if you break Volker, prepare to hear about it :) Of all the Makefiles to be careful about optimising,
    66 #     this one is the worst, because it's the ones devs need to "just work" at all times.
    67 ifeq ($(shell uname),Darwin)
    69 	LLDB_BIN=/Applications/Xcode.app/Contents/Developer/usr/bin/lldb
    70 else
    72 	LLDB_BIN=lldb
    73 endif
    75 LDLIBS+= -lcpptest
    77 # Probably everything from here to 81 is not needed any more either...
    78 # Create a list of the extra library paths for the loader. I do not assume that the engine (and its dependencies) are installed for testing.
    79 # Note that += can not be used here, as it changes the amount of whitespace
    80 # KB: See above.
    81 EXTRA_LIB_PATHS=../src:
    82 ifdef ETPAN_LIB
    83 	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
    84 endif
    85 ifdef GPGME_LIB
    86 	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
    87 endif
    88 ifdef NETPGP_LIB
    89 	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)):
    90 endif
    92 # Remove trailing ':'
    95 CFLAGS:=$(filter-out -DNDEBUG,$(CFLAGS))
    96 ifneq ($(MAKECMDGOALS),clean)
    97 	ifneq (,$(findstring -DNDEBUG,$(CFLAGS)))
    98 		$(error The macro NDEBUG must not be defined for test compilation.)
    99 	endif
   100 endif
   102 CXXFLAGS:=$(filter-out -DNDEBUG,$(CXXFLAGS))
   103 ifneq ($(MAKECMDGOALS),clean)
   104 	ifneq (,$(findstring -DNDEBUG,$(CXXFLAGS)))
   105 		$(error The macro NDEBUG must not be defined for test compilation.)
   106 	endif
   107 endif
   111 # Forgot the phony for all?
   112 # KB: I have no idea. Again, was just making it work. I bow to the master ;)
   113 all: suitemaker $(TARGET) test_home_ scripts
   115 # There is probably a built-in rules that makes this redundant. Unless we're not using '.cc' or 'CPPFLAGS' as is canon in GNU Make land.
   116 # KB: NOPE. This had to be readded because the built-in rules did NOT use them. Leave it unless you can fix that. I didn't have time to
   117 #     investigate why not, I needed the tests to run with the right flags.
   118 #     You can do what you want here, as long as I get all the flags I expect to see :)
   119 %.o: %.cc
   120 	$(CXX) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
   122 $(TARGET): $(OBJS)
   123 	$(CXX) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS) -o $@
   125 .PHONY: suitemaker
   126 suitemaker:
   127 ifndef PY_ENV
   128 	@echo "WARNING: Can't find python3 - this is fine unless you're adding test suites. If so, please install python3."
   129 else
   130 ifndef EXCLUDE
   131 	$(PY_ENV) gensuitemaker.py
   132 else
   133 	# Comma-separated list, no spaces
   134 	$(PY_ENV) gensuitemaker.py --exclude=$(EXCLUDE)
   135 endif
   136 endif
   138 # This target does nothing.
   139 .PHONY: test_home_
   140 test_home_: 
   143 # So, if there is no python, then 'scripts' will trivially be up to date, because there is no recipe associated with this rule. That's probably not what you want.
   144 # KB: That is totally what I want here.
   145 .PHONY: scripts
   146 scripts: 
   147 ifdef PY_ENV
   148 	$(PY_ENV) genscripts.py
   149 endif
   151 # Ah, yes, here it is. Finally someone tripped over me introducing both Makefile.conf and default.conf. TEST_DEBUGGER is documented in one, but not the other Makefile. Yeah, I should clean this up, otherwise every time a new knob is added, it will only appear in either Makefile.conf or default.conf.
   152 # KB: Discuss with Volker and/or Neal. I don't use the TEST_DEBUGGER thing.
   153 .PHONY: test
   154 test: all
   155 	$(TEST_DEBUGGER) ./$(TARGET)
   157 .PHONY: clean
   158 clean:
   159 	$(RM) $(TARGET) $(OBJS) $(DEPS)
   160 	$(RM) $(HERE)/*Tests msg_2.0.asc
   164 # You know, I think we have this "compiler generates Makefiles" pattern in another makefile in the engine, but there it looks completly different. From reading just this makefile: are you sure, the compiler generated Makefiles are actually every generated? You don't have DEPS as a prerequisite anywhere. Is there some built-in rule that has %.d as a prerequisite? Without further investigation I am not convinced the %.d files are ever generated...
   165 # KB: This might be leftover.
   166 -include $(DEPS)