From 03655f22832800fd7e688544c4d3fa147c437593 Mon Sep 17 00:00:00 2001 From: heck Date: Thu, 7 May 2020 02:29:42 +0200 Subject: [PATCH] Makefiles. More structure. More logging --- Makefile | 24 ++++---------------- Makefile.conf | 61 ++++++++++++++++++++++++++++----------------------- src/Makefile | 13 +++++++++++ 3 files changed, 51 insertions(+), 47 deletions(-) diff --git a/Makefile b/Makefile index 917566f..45acece 100644 --- a/Makefile +++ b/Makefile @@ -3,32 +3,16 @@ # This file may be used under the terms of the GNU General Public License version 3 # see LICENSE.txt -HERE_REL := $(notdir $(CURDIR)) - -include Makefile.conf - -ifneq ($(wildcard local.conf),) - $(info ================================================) - $(info Overrides in `local.conf` are used.) - $(info ================================================) -endif - -ifdef BUILD_CONFIG - $(info ================================================) - $(info Overrides in `$(BUILD_CONFIG)` are used.) - $(info ================================================) -endif - -.PHONY: all src test clean +.PHONY: all src test clean doxy-all doxy-cxx doxy-java doxy-clean all: src -test: src - $(MAKE) -C test/java/foundation/pEp/jniadapter/test/ compile - src: $(MAKE) -C src +test: src + $(MAKE) -C test/java/foundation/pEp/jniadapter/test/ compile + clean: $(MAKE) -C src clean $(MAKE) -C test/java/foundation/pEp/jniadapter/test/ clean clean-pep-home diff --git a/Makefile.conf b/Makefile.conf index 36bd911..15c9dde 100644 --- a/Makefile.conf +++ b/Makefile.conf @@ -6,28 +6,10 @@ HERE:=$(dir $(lastword $(MAKEFILE_LIST))) PLATFORM:=$(shell uname | tr A-Z a-z) -# Guessing JAVA_HOME -ifeq ($(PLATFORM),linux) - JAVA_HOME=$(subst /bin,,$(dir $(realpath /usr/bin/javac))) -endif - -######### C and C++ ######### -CXXFLAGS+=-O0 -std=c++11 -LDFLAGS+=-shared $(ENGINE_LIB) $(AD_LIB) - -LDLIBS=-lstdc++ -lpEpEngine -lpEpAdapter - -CXXFLAGS+=-fpermissive -fPIC -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/$(PLATFORM) $(AD_INC) $(ENGINE_INC) -ifneq (,$(findstring g++,$(CXX))) - CXXFLAGS+=-fdiagnostics-color=always -else ifneq (,$(findstring clang,$(CXX))) - CXXFLAGS+=-fcolor-diagnostics -endif - - # DEV ENV PATHS & CFG # The dev environment paths and configs are set to a default value which can be overridden by ./local.conf and overridden again by /local.conf -######### Default paths for dependencies ######### +######### Build Config Defaults ######### +DEBUG=1 YML2_PATH=$(HOME)/yml2 YML2_PROC=$(YML2_PATH)/yml2proc $(YML2_OPTS) YML2_OPTS=--encoding=utf8 @@ -35,22 +17,46 @@ ENGINE_LIB_PATH=$(HOME)/lib ENGINE_INC_PATH=$(HOME)/include AD_LIB_PATH=$(HOME)/lib AD_INC_PATH=$(HOME)/include -DEBUG=1 + +### Guessing JAVA_HOME +ifeq ($(PLATFORM),linux) + JAVA_HOME=$(subst /bin,,$(dir $(realpath /usr/bin/javac))) +endif + ######### Overrides from the config file(s) ######### --include $(HERE)/local.conf --include $(HERE)/src/local.conf +ifneq ("$(wildcard $(HERE)local.conf)","") + $(info including: $(HERE)local.conf) + -include $(HERE)local.conf +else + $(info Optional build config not found: $(HERE)local.conf) +endif + +ifneq ("$(wildcard $(HERE)src/local.conf)","") + $(info including: $(HERE)src/local.conf) + -include $(HERE)src/local.conf +else + $(info Optional build config not found: $(HERE)src/local.conf) +endif +### Apply config ENGINE_LIB=-L$(ENGINE_LIB_PATH) ENGINE_INC=-I$(ENGINE_INC_PATH) AD_LIB=-L$(AD_LIB_PATH) AD_INC=-I$(AD_INC_PATH) -ifdef BUILD_CONFIG - include $(BUILD_CONFIG) + +######### C and C++ ######### +CXXFLAGS+=-O0 -std=c++11 -fpermissive -fPIC -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/$(PLATFORM) $(AD_INC) $(ENGINE_INC) +LDFLAGS+=-shared $(ENGINE_LIB) $(AD_LIB) +LDLIBS=-lstdc++ -lpEpEngine -lpEpAdapter +ifneq (,$(findstring g++,$(CXX))) + CXXFLAGS+=-fdiagnostics-color=always +else ifneq (,$(findstring clang,$(CXX))) + CXXFLAGS+=-fcolor-diagnostics endif -# Debug or Release build +### Debug or Release build ifeq ($(DEBUG),1) $(info Debug build (set DEBUG=0 for release build)) CXXFLAGS+=-g @@ -59,5 +65,6 @@ else CXXFLAGS+=-DNDEBUG=1 endif -# YML_PATH is needed in the environment of every call to a program of the YML2 distribution +### YML_PATH is needed in the environment of every call to a program of the YML2 distribution export YML_PATH=$(YML2_PATH) + diff --git a/src/Makefile b/src/Makefile index e4ba5f5..29ba667 100644 --- a/src/Makefile +++ b/src/Makefile @@ -5,6 +5,19 @@ include ../Makefile.conf +$(info PLATFORM: $(PLATFORM)) +$(info DEBUG: $(DEBUG)) +$(info CXX: $(CXX)) +$(info JAVA_HOME: $(JAVA_HOME)) +$(info ENGINE_LIB_PATH: $(ENGINE_LIB_PATH)) +$(info ENGINE_INC_PATH: $(ENGINE_INC_PATH)) +$(info AD_LIB_PATH: $(AD_LIB_PATH)) +$(info AD_INC_PATH: $(AD_INC_PATH)) +$(info YML2_PATH: $(YML2_PATH)) +$(info CXXFLAGS: $(CXXFLAGS)) +$(info LDFLAGS: $(LDFLAGS)) +$(info LDLIBS: $(LDLIBS)) + ifndef JAVA_HOME $(error JAVA_HOME is not set!) endif