diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6553db7 --- /dev/null +++ b/Makefile @@ -0,0 +1,24 @@ +# Copyright 2021, pEp Foundation +# This file is part of lib pEp Datatypes +# This file may be used under the terms of the GNU General Public License version 3 +# see LICENSE + +.PHONY: src test install uninstall clean + +all: src + +src: + $(MAKE) -C src + +#test: src +# $(MAKE) -C test + +clean: + $(MAKE) -C src clean +# $(MAKE) -C test clean + +install: + $(MAKE) -C src install + +uninstall: + $(MAKE) -C src uninstall diff --git a/Makefile.conf b/Makefile.conf new file mode 100644 index 0000000..2b61b84 --- /dev/null +++ b/Makefile.conf @@ -0,0 +1,46 @@ +# Copyright 2021, pEp Foundation +# This file is part of libpEpDatatypes +# This file may be used under the terms of the GNU General Public License version 3 +# see LICENSE.txt + +HERE:=$(dir $(lastword $(MAKEFILE_LIST))) + +TARGET=libpEpDatatypes.a + +# Defaults +DEBUG=1 +PREFIX?=$(HOME) +ENGINE_LIB_PATH=$(PREFIX)/lib +ENGINE_INC_PATH=$(PREFIX)/include + +CXXFLAGS+=-std=c++14 -fPIC + +# Build target +BUILD_FOR:=$(shell uname) + +ifneq (,$(findstring g++,$(CXX))) + CXXFLAGS+=-fdiagnostics-color=always +else ifneq (,$(findstring clang,$(CXX))) + CXXFLAGS+=-fcolor-diagnostics +endif + + +######### Overrides ######### +-include $(HERE)local.conf + +ifeq ($(DEBUG),1) + CXXFLAGS+=-g -O0 +else + CXXFLAGS+=-DNDEBUG=1 -O3 +endif + +# Add -L Prefixes to LIB/INC paths, +# if not already explicitly set in local.conf +ifndef ENGINE_LIB + ENGINE_LIB=-L$(ENGINE_LIB_PATH) +endif +ifndef ENGINE_INC + ENGINE_INC=-I$(ENGINE_INC_PATH) +endif + +CXXFLAGS += $(ENGINE_INC) diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..fe3eacb --- /dev/null +++ b/src/Makefile @@ -0,0 +1,37 @@ +# Copyright 2021, pEp Foundation +# This file is part of lib pEp Datatypes +# This file may be used under the terms of the GNU General Public License version 3 +# see LICENSE + +include ../Makefile.conf + +SOURCE=$(wildcard *.cc) +HEADERS=$(wildcard *.hh *.hxx) +OBJECTS=$(subst .cc,.o,$(SOURCE)) +DEPENDS=$(subst .cc,.d,$(SOURCE)) +CXXFLAGS+= -MMD -MP + +ifneq ($(MAKECMDGOALS),clean) + -include $(DEPENDS) +endif + +.PHONY: install uninstall clean + +all: $(TARGET) + +$(TARGET): $(OBJECTS) + $(AR) -rc $@ $^ + +clean: + rm -vf $(TARGET) $(OBJECTS) $(DEPENDS) + rm -f *.d.* + +install: $(TARGET) + mkdir -p $(PREFIX)/include/pEp + mkdir -p $(PREFIX)/lib + cp -v $(HEADERS) $(PREFIX)/include/pEp/ + cp -v $(TARGET) $(PREFIX)/lib/ + +uninstall: + cd $(PREFIX)/include/pEp && rm -vf $(HEADERS) + cd $(PREFIX)/lib && rm -vf $(TARGET)