Browse Source

More Makefile cleanup

ENGINE-228
Damiano Boppart 5 years ago
parent
commit
b32eea0652
10 changed files with 102 additions and 93 deletions
  1. +3
    -1
      Makefile
  2. +6
    -7
      Makefile.conf
  3. +1
    -1
      asn.1/Makefile
  4. +3
    -3
      build-config/Darwin.conf
  5. +3
    -2
      build-config/Linux.conf
  6. +32
    -13
      build-config/common.conf
  7. +4
    -2
      db/Makefile
  8. +40
    -53
      src/Makefile
  9. +3
    -1
      sync/Makefile
  10. +7
    -10
      test/Makefile

+ 3
- 1
Makefile View File

@ -1,4 +1,6 @@
# this file is under GNU General Public License v3.0
# Copyright 2017, pEp Security SA
# This file is part of pEpEngine
# This file may be used under the terms of the GNU General Public License version 3
# see LICENSE.txt
include Makefile.conf


+ 6
- 7
Makefile.conf View File

@ -5,14 +5,13 @@
# To use custom build configuration variables, put them in a new file at `build-config/<name>.conf`. Execute `export PLATFORM_OVERRIDE=<name>` before running make. If this environment variable is not set, make will load a default configuration for your platform.
BUILD_CONFIG=build-config
include $(BUILD_CONFIG)/common.conf
ifdef PLATFORM_OVERRIDE
include $(BUILD_CONFIG)/$(PLATFORM_OVERRIDE).conf
include build-config/common.conf
# cross-compiling is currently not supported, but maybe you can hack something with `PLATFORM_OVERRIDE`
else ifeq ($(BUILD_ON),$(BUILD_FOR))
include $(BUILD_CONFIG)/$(BUILD_ON).conf
ifeq ($(BUILD_ON),$(BUILD_FOR))
include build-config/$(BUILD_ON).conf
else
$(error I don't know how to build for $(BUILD_FOR) on $(BUILD_ON))
endif
ifdef PLATFORM_OVERRIDE
include build-config/$(PLATFORM_OVERRIDE).conf
endif

+ 1
- 1
asn.1/Makefile View File

@ -16,7 +16,7 @@ generate: Sync-Protocols.c
rm -f converter-sample.c
%.o: %.c %.h
$(CC) $(CFLAGS) -I. -I$(ASN1C_INCLUDE) -c $< -o $@
$(CC) $(CFLAGS) -I. $(ASN1C_INC) -c $< -o $@
Sync-Protocols.c: pEp.asn1 devicegroup.asn1 protocols.asn1
$(ASN1C) -gen-PER -fincludes-quoted -fcompound-names -pdu=PEP.Message $^


+ 3
- 3
build-config/Darwin.conf View File

@ -8,8 +8,7 @@ TARGET=libpEpEngine.dylib
######### C #########
CC=clang -std=c99 -pthread
# FIXME I think -fPIC is not available in clang
CFLAGS= -fPIC -fstrict-aliasing -fcolor-diagnostics
CFLAGS=-fPIC -fstrict-aliasing -fcolor-diagnostics
ifdef WARN
CFLAGS+= -Wall -pedantic -Wstrict-aliasing=3
else
@ -23,7 +22,7 @@ endif
######### C++ #########
CXX=clang -std=c++11
CXXFLAGS= -fcolor-diagnostics
CXXFLAGS=-fcolor-diagnostics -I../src -I../asn.1 $(ETPAN_INC)
ifdef WARN
CXXFLAGS+=
else
@ -44,6 +43,7 @@ endif
######### libetpan #########
######### OpenPGP #########
LIBGPGME=libgpgme.dylib
######### Engine internals #########


+ 3
- 2
build-config/Linux.conf View File

@ -8,7 +8,7 @@ TARGET=libpEpEngine.so
######### C #########
CC=gcc -std=c99
CFLAGS= -fPIC -fstrict-aliasing -fdiagnostics-color=always
CFLAGS=-fPIC -fstrict-aliasing -fdiagnostics-color=always
ifdef WARN
CFLAGS+= -Wall -pedantic -Wstrict-aliasing=3
else
@ -22,7 +22,7 @@ endif
######### C++ #########
CXX=g++ -std=gnu++11 -pthread
CXXFLAGS= -fdiagnostics-color=always
CXXFLAGS=-fdiagnostics-color=always -I../src -I../asn.1 $(ETPAN_INC)
ifdef WARN
CXXFLAGS+=
else
@ -43,6 +43,7 @@ endif
######### libetpan #########
######### OpenPGP #########
LIBGPGME=libgpgme.so.11
######### Engine internals #########


+ 32
- 13
build-config/common.conf View File

@ -24,10 +24,15 @@ CPPFLAGS=
######### C++ #########
#CXX This option is platform-specific
# CXXFLAGS is used for the tests only
#CXXFLAGS This option is platform-specific
######### C and C++ #########
#LD=
# LD will be overwritten for test/Makefile
LD=$(CC)
# The following two variables will be appended to, you can thus not set them here to fixed value.
LDFLAGS=
LDLIBS=
######### YML2 #########
YML2_PATH=$(HOME)/yml2
@ -35,35 +40,49 @@ YML2_PROC=$(YML2_PATH)/yml2proc
YML2_OPTS=--encoding=utf8
######### asn1c #########
# asn1c binary path
# asn1c binary
ASN1C=asn1c
ASN1C_INCLUDE=/usr/include
# asn1c include search flag
ASN1C_INC=
#ASN1C_INC= -I$(HOME)/include
######### libetpan #########
# libetpan distribution path
ETPAN_IN=$(HOME)
# libetpan library search flag
ETPAN_LIB=-L$(PREFIX)/lib
# libetpan include search flag
ETPAN_INC=-I$(PREFIX)/include
######### OpenPGP #########
# Selects OpenPGP implementation. must be either `GPG` or `NETPGP`
OPENPGP=GPG
# Path of libGPGME binary
#LIBGPGME=/opt/local/lib/libgpgme.11.dylib
# Path of GPG binary
GPG_CMD=gpg
ifneq ($(shell which gpg2),)
GPG_CMD = gpg2
endif
# Selects OpenPGP implementation. must be either `GPG` or `NETPGP`
OPENPGP=GPG
# Path of libGPGME binary
#LIBGPGME This option is platform-specific
# libGPGME library search flag
GPGME_LIB=
#GPGME_LIB=-L$(PREFIX)/lib
# libGPGME include search flag
GPGME_INC=
#GPGME_INC=-I$(PREFIX)/include
# NETPGP library search flag
NETPGP_LIB=
#NETPGP_LIB=-L$(PREFIX)/lib
# libGPGME include search flag
NETPGP_INC=
#NETPGP_INC=-I$(PREFIX)/include
######### Engine internals #########
# C macros (not environment variables) that can be overridden:
# DEFAULT_KEYSERVER - string with default keyserver
# CRASHDUMP_DEFAULT_LINES - number of log lines to deliver for crashdumps
# Example:
# EXTRAMACROS= -DDEFAULT_KEYSERVER=\"default-server.org\" -DCRASHDUMP_DEFAULT_LINES=23
EXTRAMACROS=
# EXTRA_MACROS= -DDEFAULT_KEYSERVER=\"default-server.org\" -DCRASHDUMP_DEFAULT_LINES=23
EXTRA_MACROS=
######### Misc #########
# Maybe include these variables here. Check how they are used throughout the project before setting them here
#LDFLAGS=
#LDLIBS=
#LLDB_BIN

+ 4
- 2
db/Makefile View File

@ -1,4 +1,6 @@
# This file is under GNU General Public License 3.0
# Copyright 2017, pEp Security SA
# This file is part of pEpEngine
# This file may be used under the terms of the GNU General Public License version 3
# see LICENSE.txt
include ../Makefile.conf
@ -21,4 +23,4 @@ install: system.db
.PHONY: clean
clean:
-rm -f system.db system.db~
rm -f system.db system.db~

+ 40
- 53
src/Makefile View File

@ -1,70 +1,57 @@
include ../Makefile.conf
# Copyright 2017, pEp Security SA
# This file is part of pEpEngine
# This file may be used under the terms of the GNU General Public License version 3
# see LICENSE.txt
LD?=$(CC)
include ../Makefile.conf
ETPAN_IN?=$(HOME)
CFLAGS+= $(ETPAN_INC) -I../asn.1 -DSYSTEM_DB=\"$(SYSTEM_DB)\" $(EXTRA_MACROS)
LDFLAGS+= $(ETPAN_LIB) -L../asn.1 -shared
LDLIBS+= -lc -lasn1 -letpan
ifeq ($(BUILD_ON),Darwin)
ifeq ($(BUILD_FOR),Darwin)
TARGET?=libpEpEngine.dylib
MACOSX_VERSION_MIN=10.6
LIBGPGME?=libgpgme.dylib
CC?=clang -std=c99 -pthread
CFLAGS?= -I$(ETPAN_IN)/include -I/opt/local/include -pedantic \
-DSYSTEM_DB=\"$(SYSTEM_DB)\" -I../asn.1 $(EXTRAMACROS)
LDFLAGS?= -lc -shared -arch x86_64 \
-L$(ETPAN_IN)/lib -L/usr/lib -L/opt/local/lib -letpan -lsqlite3 -L../asn.1 -lasn1 -lz -liconv
else
$(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
endif
ifeq ($(BUILD_FOR),Darwin)
#CFLAGS+= -I/opt/local/include
#LDFLAGS+= -L/opt/local/lib
LDLIBS+= -lsqlite3 -lz -liconv
else
$(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
endif
else ifeq ($(BUILD_ON),Linux)
ifeq ($(BUILD_FOR),Linux)
TARGET=libpEpEngine.so
LIBGPGME?=libgpgme.so.11
CC=gcc -std=c99
CFLAGS?= -I$(ETPAN_IN)/include -fPIC -pedantic -DSYSTEM_DB=\"$(SYSTEM_DB)\" \
-DSQLITE_THREADSAFE=1 -D_GNU_SOURCE -I../asn.1 $(EXTRAMACROS)
LDFLAGS?= -L$(ETPAN_IN)/lib -shared -lc -ldl -letpan -lpthread -L../asn.1 -lasn1 -luuid
else
$(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
endif
ifeq ($(BUILD_FOR),Linux)
# FIXME Find out if SQLITE_THREADSAFE is needed for both platform.
CFLAGS+= -DSQLITE_THREADSAFE=1 -D_GNU_SOURCE
LDLIBS+= -ldl -luuid
else
$(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
endif
else
$(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
$(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
endif
DEBUG?=NO
ifeq ("$(DEBUG)","NO")
CFLAGS+= -DNDEBUG
endif
OPENPGP?=GPG
ifeq ("$(OPENPGP)","GPG")
ifeq ($(OPENPGP),GPG)
NO_SOURCE=pgp_netpgp.c
GPGME_IN?=$(HOME)
CFLAGS+= -DUSE_GPG -I$(GPGME_IN)/include -DLIBGPGME=\"$(LIBGPGME)\"
#LDFLAGS+= -L$(GPGME_IN)/lib -lgpgme
else ifeq ("$(OPENPGP)","NETPGP")
CFLAGS+= -DUSE_GPG $(GPGME_INC) -DLIBGPGME=\"$(LIBGPGME)\"
# FIXME Why was -lgpgme commented out?
LDFLAGS+= $(GPGME_LIB)
else ifeq ($(OPENPGP),NETPGP)
NO_SOURCE=pgp_gpg.c
NETPGP_IN?=$(HOME)
CFLAGS+= -DUSE_NETPGP -I$(NETPGP_IN)/include
LDFLAGS+= -L$(NETPGP_IN)/lib -lnetpgp -lcurl
CFLAGS+= -DUSE_NETPGP $(NETGPG_INC)
LDFLAGS+= $(NETGPG_LIB)
LDLIBS+= -lnetpgp -lcurl
else
$(error Unknown OpenPGP library : $(OPENPGP))
$(error Unknown OpenPGP library: $(OPENPGP))
endif
ALL_SOURCE=$(subst $(NO_SOURCE),,$(wildcard *.c))
DEPENDS=$(subst .c,.d,$(ALL_SOURCE))
ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE))
.PHONY: all
all: $(TARGET)
# FIXME What is this?
include Makefile.protocols
%.d: %.c
@ -75,27 +62,27 @@ include Makefile.protocols
-include $(DEPENDS)
#platform_windows.o: platform_windows.cpp
# $(CXX) $(CXX_FLAGS) -o $@ -c $<
$(TARGET): libpEpEngine.a
$(LD) $(ALL_OBJECTS) $(LDFLAGS) -o $@
$(LD) $(ALL_OBJECTS) $(LDFLAGS) $(LDLIBS) -o $@
.PHONY: object
objects: $(ALL_OBJECTS)
libpEpEngine.a: $(ALL_OBJECTS)
ar -r $@ $(ALL_OBJECTS)
ar -rc $@ $^
.PHONY: clean
clean:
rm -f *.d *.o *.a $(TARGET) *.dll *.so *.zip *.d.* *.def *~
.PHONY: install
install: $(TARGET)
cp $< $(PREFIX)/lib/
mkdir -p $(PREFIX)/include/pEp
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/
.PHONY: uninstall
uninstall:
rm -f $(PREFIX)/lib/$(TARGET)
rm -rf $(PREFIX)/include/pEp

+ 3
- 1
sync/Makefile View File

@ -1,4 +1,6 @@
# This file is under GNU General Public License 3.0
# Copyright 2017, pEp Security SA
# This file is part of pEpEngine
# This file may be used under the terms of the GNU General Public License version 3
# see LICENSE.txt
include ../Makefile.conf


+ 7
- 10
test/Makefile View File

@ -1,21 +1,18 @@
# This file is under GNU General Public License 3.0
# Copyright 2017, pEp Security SA
# This file is part of pEpEngine
# This file may be used under the terms of the GNU General Public License version 3
# see LICENSE.txt
HERE := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
LD?=$(CXX)
HERE:=$(CURDIR)
include ../Makefile.conf
CC?=g++ -std=gnu++11 -pthread
CXX?=g++ -std=gnu++11 -pthread
LDFLAGS?=-L$(HOME)/lib
LDLIBS?=-letpan -lpEpEngine -lstdc++ -L../asn.1 -lasn1
LD=$(CXX)
LDFLAGS+= $(ETPAN_LIB) -L../asn.1
LDLIBS?=-letpan -lpEpEngine -lstdc++ -lasn1
ifeq ($(BUILD_FOR),Linux)
LDLIBS+= -luuid
endif
CXXFLAGS?=-std=c++11 -g -O0 -I../src -I../asn.1
# CXXFLAGS=-O3 -DNDEBUG
ifeq ("$(OPENPGP)","NETPGP")
LDLIBS+= -lnetpgp


Loading…
Cancel
Save