Makefile.conf
author Volker Birk <vb@pep-project.org>
Wed, 20 Nov 2019 16:03:44 +0100
branchsync
changeset 4211 1e909e9a4548
parent 4124 1ebe4c90edf3
permissions -rw-r--r--
or not to update, that is the question
     1 # Copyright 2017, pEp Foundation
     2 # This file is part of pEpEngine
     3 # This file may be used under the terms of the GNU General Public License version 3
     4 # see LICENSE.txt
     5 
     6 # See `doc/build-<your platform>.md` for documentation on how to build, and customize your build.
     7 
     8 # This file sets all the make variables that allow you to customize a build.
     9 # There are 3 ways in which you can customize your build:
    10 # 1) Edit the variable assignments in this file (this is a tracked file, so your repository will be dirty)
    11 # 2) Create `local.conf` and fill it with variable assignments.
    12 # 3) Set the environment variable `BUILD_CONFIG` to an absolute path.
    13 #    The variable assignments found in the make file at the path indicated by `BUILD_CONFIG` will be evaluated.
    14 # Customization options are applied in the order given above. Later variable assignments take precedence over earlier ones.
    15 # It is possible to use multiple variants simultaniously.
    16 # If nothing is changed according to these 3 methods, a default configuration for your platform (specified below) will be used for the build.
    17 
    18 
    19 ######### Header #########
    20 HERE:=$(dir $(lastword $(MAKEFILE_LIST)))
    21 
    22 
    23 ######### General #########
    24 # To use (only) system libraries, set all the *_INC and *_LIB variables to the empty string.
    25 # All the *_INC and *_LIB variables are command line flags, not paths.
    26 # Thus, all *_INC variables' values must start with "-I", and all *_LIB variables' values must start with "-L".
    27 
    28 BUILD_ON:=$(shell uname)
    29 
    30 # This variable specifies the platform that the engine should be cross-compiled for.
    31 BUILD_FOR=$(BUILD_ON)
    32 
    33 # Cross-compiling is currently not supported.
    34 # Maybe you can hack something with `local.conf`.
    35 ifneq ($(BUILD_ON),$(BUILD_FOR))
    36     $(error I don't know how to build for $(BUILD_FOR) on $(BUILD_ON).)
    37 endif
    38 
    39 # Installation path prefix for libraries and binaries, except for system.db
    40 PREFIX=$(HOME)
    41 
    42 # pEp files and directories
    43 #
    44 # the PER_USER_DIRECTORY will be in $(HOME), respectively
    45 # in debug builds the PER_USER_DIRECTORY will be in $(PEP_HOME) instead if set
    46 #
    47 # PER_MACHINE_DIRECTORY is calculated depending on platform; overwrite if
    48 # necessary
    49 
    50 #PER_USER_DIRECTORY=.pEp
    51 PER_MACHINE_DIRECTORY:=/usr/local/share/pEp
    52 
    53 # Filename of the pEpEngine library
    54 ifeq ($(BUILD_FOR),Linux)
    55     TARGET=libpEpEngine.so
    56 else ifeq ($(BUILD_FOR),Darwin)
    57     TARGET=libpEpEngine.dylib
    58 endif
    59 
    60 # If empty, create a release build.
    61 # Otherwise, create a debug build.
    62 # This variable is ineffective when set anywhere else but here.
    63 DEBUG=placeholder
    64 
    65 # If empty, suppress compiler warnings.
    66 # Otherwise, print warnings.
    67 # This variable is ineffective when set anywhere else but here.
    68 WARN=placeholder
    69 
    70 
    71 ######### C and C++ #########
    72 TARGET_ARCH=
    73 
    74 # The following two variables will be appended to.
    75 # You can thus not set them to a final, fixed value here.
    76 ifeq ($(BUILD_FOR),Linux)
    77     LDFLAGS=
    78 else ifeq ($(BUILD_FOR),Darwin)
    79     # "-bind_at_load" helps find symbol resolution errors faster
    80     LDFLAGS=-bind_at_load
    81 endif
    82 
    83 LDLIBS=
    84 
    85 
    86 ######### C #########
    87 ifeq ($(BUILD_FOR),Linux)
    88     CC=gcc -std=c99 -pthread
    89 else ifeq ($(BUILD_FOR),Darwin)
    90     # clang issues a warning when "-pthread" is used for linking.
    91     # So, include it in CFLAGS, and not in CC
    92     CC=clang -std=c99
    93 endif
    94 
    95 ifeq ($(BUILD_FOR),Linux)
    96     CFLAGS=-fPIC -fstrict-aliasing -fdiagnostics-color=always
    97 else ifeq ($(BUILD_FOR),Darwin)
    98     CFLAGS=-pthread -fPIC -fstrict-aliasing -fcolor-diagnostics
    99 endif
   100 
   101 # The flag -DNDEBUG will always be removed from CFLAGS for compiling tests.
   102 # The tests do not work properly, if compiled with -DNDEBUG
   103 ifeq ($(BUILD_FOR),Linux)
   104     ifdef WARN
   105         CFLAGS+= -Wall -pedantic -Wstrict-aliasing=3
   106     else
   107         CFLAGS+= -w
   108     endif
   109     ifdef DEBUG
   110         CFLAGS+= -g -ggdb -DDEBUG_ERRORSTACK
   111     else
   112         CFLAGS+= -O3 -DNDEBUG
   113     endif
   114 else ifeq ($(BUILD_FOR),Darwin)
   115     ifdef WARN
   116         CFLAGS+= -Wall -pedantic
   117     else
   118         CFLAGS+= -w
   119     endif
   120     ifdef DEBUG
   121         CFLAGS+= -O0 -g -DDEBUG_ERRORSTACK
   122     else
   123         CFLAGS+= -O3 -DNDEBUG
   124     endif
   125 endif
   126 
   127 # Additional CFLAGS used for compiling ASN1C-generated code
   128 ifeq ($(BUILD_FOR),Linux)
   129     # The '_DEFAULT_SOURCE' feature test macro is required to suppress the warning
   130     #   _BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE
   131     # otherwise printed during the compilation of every asn1c-generated C file.
   132     # It's a glibc specific warning, only present in few versions around ~2.19.
   133     # See https://lwn.net/Articles/590381/ for a discussion.
   134     CFLAGS_GENERATED=-D_DEFAULT_SOURCE
   135 else ifeq ($(BUILD_FOR),Darwin)
   136     CFLAGS_GENERATED=
   137 endif
   138 
   139 
   140 ######### C++ #########
   141 ifeq ($(BUILD_FOR),Linux)
   142     CXX=g++ -std=gnu++11 -pthread
   143 else ifeq ($(BUILD_FOR),Darwin)
   144     # clang issues a warning when "-pthread" is used for linking. So, include it in CXXFLAGS, and not in CXX
   145     CXX=clang -std=c++11
   146 endif
   147 
   148 # The flag -DNDEBUG will always be removed from CXXFLAGS for compiling tests.
   149 # The tests do not work properly, if compiled with -DNDEBUG
   150 ifeq ($(BUILD_FOR),Linux)
   151     CXXFLAGS=-fdiagnostics-color=always -I../src -I../asn.1 $(ETPAN_INC)
   152     ifdef WARN
   153         CXXFLAGS+=
   154     else
   155         CXXFLAGS+= -w
   156     endif
   157     ifdef DEBUG
   158         CXXFLAGS+= -g -ggdb
   159     else
   160         CXXFLAGS+= -O3 -DNDEBUG
   161     endif
   162 else ifeq ($(BUILD_FOR),Darwin)
   163     CXXFLAGS=-pthread -fcolor-diagnostics -I../src -I../asn.1 $(ETPAN_INC)
   164     ifdef WARN
   165         CXXFLAGS+=
   166     else
   167         CXXFLAGS+= -w
   168     endif
   169     ifdef DEBUG
   170         CXXFLAGS+= -O0 -g
   171     else
   172         CXXFLAGS+= -O3 -DNDEBUG
   173     endif
   174 endif
   175 
   176 
   177 ######### C and C++ #########
   178 ifeq ($(BUILD_FOR),Darwin)
   179     CPPFLAGS=-D_DARWIN_C_SOURCE
   180 else
   181     CPPFLAGS=
   182 endif
   183 
   184 
   185 
   186 ######### YML2 #########
   187 YML2_PATH=$(HOME)/yml2
   188 
   189 YML2_PROC=$(YML2_PATH)/yml2proc $(YML2_OPTS)
   190 
   191 YML2_OPTS=--encoding=utf8
   192 
   193 
   194 ######### asn1c #########
   195 # asn1c binary
   196 ASN1C=asn1c
   197 
   198 # asn1c include search flag
   199 ASN1C_INC=
   200 #ASN1C_INC=-I$(HOME)/include
   201 
   202 
   203 ######### libetpan #########
   204 # libetpan library search flag
   205 ETPAN_LIB=
   206 #ETPAN_LIB=-L$(HOME)/lib
   207 
   208 # libetpan include search flag
   209 ETPAN_INC=
   210 #ETPAN_INC=-I$(HOME)/include
   211 
   212 
   213 ######### pEp MIME #########
   214 # set this to skip libetpan and use PEP_MIME instead
   215 # PEP_MIME=1
   216 #
   217 # pEp MIME library search flag
   218 PEP_MIME_LIB=
   219 # pEp MIME include search flag
   220 PEP_MIME_INC=
   221 
   222 
   223 ######### sqlite3 #########
   224 # If empty (or undefined), compile sqlite3 from the sources shipped with the pEp distribution.
   225 # Otherwise, use an sqlite3 implementation found in the OS's include/library paths.
   226 SQLITE3_FROM_OS=placeholder
   227 
   228 
   229 ######### OpenPGP #########
   230 # Path of GPG binary
   231 # gpgconf is not available for old version of GPG, for example GPG 2.0.30. Override this variable, if you compile the engine for such an old version.
   232 GPG_CMD:=$(shell gpgconf --list-components | awk -F: '/^gpg:/ { print $$3; exit 0; }')
   233 
   234 # Selects OpenPGP implementation. must be either `SEQUOIA`, `GPG` or `NETPGP`
   235 OPENPGP=GPG
   236 
   237 # Sequoia-specific variables
   238 SEQUOIA_CFLAGS=
   239 SEQUOIA_LDFLAGS=
   240 SEQUOIA_LIB=
   241 SEQUOIA_INC=
   242 
   243 # libGPGME filename
   244 ifeq ($(BUILD_FOR),Linux)
   245     LIBGPGME=libgpgme.so.11
   246 else ifeq ($(BUILD_FOR),Darwin)
   247     LIBGPGME=libgpgme.11.dylib
   248 endif
   249 
   250 # libGPGME library search flag
   251 GPGME_LIB=
   252 #GPGME_LIB=-L$(HOME)/lib
   253 
   254 # libGPGME include search flag
   255 GPGME_INC=
   256 #GPGME_INC=-I$(HOME)/include
   257 
   258 # NETPGP library search flag
   259 NETPGP_LIB=
   260 #NETPGP_LIB=-L$(HOME)/lib
   261 
   262 # libGPGME include search flag
   263 NETPGP_INC=
   264 #NETPGP_INC=-I$(HOME)/include
   265 
   266 
   267 
   268 ######### CppUnit #########
   269 # CppUnit library search flag
   270 CPPUNIT_LIB=
   271 #CPPUNIT_LIB=-L$(HOME)/local/lib
   272 
   273 # CppUnit include search flag
   274 CPPUNIT_INC=
   275 #CPPUNIT_INC=-I$(HOME)/local/inc
   276 
   277 
   278 ######### Engine internals #########
   279 # C macros (not environment variables) that can be overridden:
   280 # DEFAULT_KEYSERVER - string with default keyserver
   281 # CRASHDUMP_DEFAULT_LINES - number of log lines to deliver for crashdumps
   282 # Example:
   283 #    EXTRA_MACROS=-DDEFAULT_KEYSERVER=\"default-server.org\" -DCRASHDUMP_DEFAULT_LINES=23
   284 EXTRA_MACROS=
   285 
   286 
   287 ######### Misc #########
   288 # FIXME Maybe include these variables here.
   289 # Check how they are used throughout the project before setting them here
   290 #LLDB_BIN
   291 
   292 # Add this for running tests in debugger
   293 #TEST_DEBUGGER=lldb --batch -o r
   294 
   295 # comma-separated list of tests to exclude from gensuite (relevant for running tests only)
   296 EXCLUDE=
   297 
   298 
   299 ######### Footer #########
   300 -include $(HERE)/local.conf
   301 
   302 ifdef BUILD_CONFIG
   303     include $(BUILD_CONFIG)
   304 endif
   305 
   306 ######### Post processing assignments ########
   307 # These variables are ineffective when set anywhere else but here.
   308 ifeq ($(OPENPGP),SEQUOIA)
   309     SEQUOIA_CFLAGS=$(shell pkg-config --cflags-only-other sequoia-openpgp)
   310     SEQUOIA_LDFLAGS=$(shell pkg-config --libs-only-l --libs-only-other sequoia-openpgp)
   311     SEQUOIA_LIB=$(shell pkg-config --libs-only-L sequoia-openpgp)
   312     SEQUOIA_INC=$(shell pkg-config --cflags-only-I sequoia-openpgp)
   313     CFLAGS+= $(SEQUOIA_CFLAGS)
   314     LD_FLAGS+= $(SEQUOIA_LDFLAGS)
   315 endif
   316 
   317 # YML_PATH is needed in the environment of every call to a program of the YML2 distribution
   318 export YML_PATH=$(YML2_PATH)