Browse Source

First attempt at gtest in Makefile without hardcoding paths

JSON-80
Damiano Boppart 5 years ago
parent
commit
6c70a9beeb
3 changed files with 20 additions and 18 deletions
  1. +2
    -0
      README.md
  2. +14
    -17
      server/Makefile
  3. +4
    -1
      server/Makefile.conf

+ 2
- 0
README.md View File

@ -73,6 +73,7 @@ macOS 10.12:
~~~~~
PREFIX=$(HOME)/code/json-ad/build
HTML_DIRECTORY=$(PREFIX)/share/pEp/json-adapter/html
GTEST_DIR=$(HOME)/code/gtest/googletest
BOOST_INC=-I$(HOME)/Cellar/boost/1.65.1/include
BOOST_LIB=-L$(HOME)/Cellar/boost/1.65.1/lib
@ -98,6 +99,7 @@ Debian 9:
~~~~~
PREFIX=$(HOME)/code/json-ad/build
HTML_DIRECTORY=$(PREFIX)/share/pEp/json-adapter/html
GTEST_DIR=$(HOME)/code/gtest/googletest
ENGINE_INC=-I$(HOME)/code/engine/build/include
ENGINE_LIB=-L$(HOME)/code/engine/build/lib


+ 14
- 17
server/Makefile View File

@ -78,16 +78,14 @@ endif
all: $(TARGET) $(TARGET_TEST) $(TARGET_GTEST)
$(TARGET): main.o libjson-adapter.a
$(CXX) $^ $(LDFLAGS) $(LDLIBS) -o $@
$(CXX) $(CPPFLAGS) $^ $(LDFLAGS) $(LDLIBS) -o $@
$(TARGET)-static: main.o libjson-adapter.a
$(CXX) $^ $(LDFLAGS) $(LDLIBS) -static -o $@
$(CXX) $(CPPFLAGS) $^ $(LDFLAGS) $(LDLIBS) -static -o $@
$(TARGET_TEST): servertest.o libjson-adapter.a
$(CXX) $^ $(LDFLAGS) $(LDLIBS) -o $@
$(TARGET_GTEST): unittest_json.o gtest-all.o gtest_main.o libjson-adapter.a
$(CXX) $^ $(LDFLAGS) $(LDLIBS) -o $@
$(CXX) $(CPPFLAGS) $^ $(LDFLAGS) $(LDLIBS) -o $@
libjson-adapter.a: $(ALL_OBJECTS)
ar rcs $@ $^
@ -95,24 +93,22 @@ libjson-adapter.a: $(ALL_OBJECTS)
prefix-config.cc:
echo '// This file is generated by make. Edit the Makefile, not this file!\n#include "prefix-config.hh" \nconst char* const html_directory = "'$(HTML_DIRECTORY)'";\n' > $@
gtest-all.o: /usr/src/googletest/googletest/src/gtest-all.cc
$(CXX) $(CXXFLAGS) -I/usr/src/googletest/googletest/ -o $@ -c $<
gtest_main.o: /usr/src/googletest/googletest/src/gtest_main.cc
$(CXX) $(CXXFLAGS) -I/usr/src/googletest/googletest/ -o $@ -c $<
gtest-all.o: $(GTEST_DIR)/src/gtest-all.cc
gtest_main.o: $(GTEST_DIR)/src/gtest_main.cc
$(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -o $@ -c $<
%.o: %.cc %.hh
$(CXX) $(CXXFLAGS) -c $<
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $<
%.d: %.cpp
@set -e; rm -f $@; \
$(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< > $@.$$$$; \
$(CXX) $(CPPFLAGS) -MM $(CXXFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
%.d: %.cc
@set -e; rm -f $@; \
$(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< > $@.$$$$; \
$(CXX) $(CPPFLAGS) -MM $(CXXFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
@ -137,12 +133,13 @@ clean:
rm -vf *.d json_spirit/*.d
rm -vf prefix-config.cc
.PHONY: run | install
run:
.PHONY: run
run: | install
@echo "The adapter must be installed for $< to work"
$(CMD_PFX) "$(PREFIX)/bin/$(TARGET)"
.PHONY: test | install
test:
.PHONY: test
test: | install
@echo "The adapter must be installed for $< to work"
$(CMD_PFX) "$(PREFIX)/bin/$(TARGET_TEST)"
$(CMD_PFX) "$(PREFIX)/bin/$(TARGET_GTEST)"

+ 4
- 1
server/Makefile.conf View File

@ -60,7 +60,7 @@ else ifeq ($(BUILD_FOR),Darwin)
CXX=c++ -std=c++11 -fPIC
endif
CPPFLAGS=
CPPFLAGS=-isystem $(GTEST_DIR)/include
ifeq ($(BUILD_FOR),Linux)
CXXFLAGS=-fstack-protector-all -fdiagnostics-color=always
@ -96,6 +96,9 @@ else ifeq ($(BUILD_FOR),Darwin)
LDLIBS+= -levent -lpEpEngine -lboost_system-mt -lboost_filesystem-mt -lboost_program_options-mt -lboost_thread-mt
endif
######### Google Test #########
GTEST_DIR=
######### boost #########
BOOST_INC=


Loading…
Cancel
Save