Makefile.conf
author Dirk Zimmermann <dz@pep.security>
Thu, 11 Apr 2019 10:46:46 +0200
branchIOS-1482
changeset 3505 3fe4b41696d3
parent 3443 c43850c15b05
child 3580 7c757957849b
permissions -rw-r--r--
IOS-1482 close branch
     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 # Installation path for system.db
    43 SYSTEM_DB=/usr/local/share/pEp/system.db
    44 
    45 # Filename of the pEpEngine library
    46 ifeq ($(BUILD_FOR),Linux)
    47     TARGET=libpEpEngine.so
    48 else ifeq ($(BUILD_FOR),Darwin)
    49     TARGET=libpEpEngine.dylib
    50 endif
    51 
    52 # If empty, create a release build.
    53 # Otherwise, create a debug build.
    54 # This variable is ineffective when set anywhere else but here.
    55 DEBUG=placeholder
    56 
    57 # If empty, suppress compiler warnings.
    58 # Otherwise, print warnings.
    59 # This variable is ineffective when set anywhere else but here.
    60 WARN=placeholder
    61 
    62 
    63 ######### C and C++ #########
    64 TARGET_ARCH=
    65 
    66 # The following two variables will be appended to.
    67 # You can thus not set them to a final, fixed value here.
    68 ifeq ($(BUILD_FOR),Linux)
    69     LDFLAGS=
    70 else ifeq ($(BUILD_FOR),Darwin)
    71     # "-bind_at_load" helps find symbol resolution errors faster
    72     LDFLAGS=-bind_at_load
    73 endif
    74 
    75 LDLIBS=
    76 
    77 
    78 ######### C #########
    79 ifeq ($(BUILD_FOR),Linux)
    80     CC=gcc -std=c99 -pthread
    81 else ifeq ($(BUILD_FOR),Darwin)
    82     # clang issues a warning when "-pthread" is used for linking.
    83     # So, include it in CFLAGS, and not in CC
    84     CC=clang -std=c99
    85 endif
    86 
    87 ifeq ($(BUILD_FOR),Linux)
    88     CFLAGS=-fPIC -fstrict-aliasing -fdiagnostics-color=always
    89 else ifeq ($(BUILD_FOR),Darwin)
    90     CFLAGS=-pthread -fPIC -fstrict-aliasing -fcolor-diagnostics
    91 endif
    92 
    93 # The flag -DNDEBUG will always be removed from CFLAGS for compiling tests.
    94 # The tests do not work properly, if compiled with -DNDEBUG
    95 ifeq ($(BUILD_FOR),Linux)
    96     ifdef WARN
    97         CFLAGS+= -Wall -pedantic -Wstrict-aliasing=3
    98     else
    99         CFLAGS+= -w
   100     endif
   101     ifdef DEBUG
   102         CFLAGS+= -g -ggdb -DDEBUG_ERRORSTACK
   103     else
   104         CFLAGS+= -O3 -DNDEBUG
   105     endif
   106 else ifeq ($(BUILD_FOR),Darwin)
   107     ifdef WARN
   108         # FIXME Remove 'no-extended-offsetof' after ENGINE-236 is closed.
   109         CFLAGS+= -Wall -pedantic -Wno-extended-offsetof
   110     else
   111         CFLAGS+= -w
   112     endif
   113     ifdef DEBUG
   114         CFLAGS+= -O0 -g -DDEBUG_ERRORSTACK
   115     else
   116         CFLAGS+= -O3 -DNDEBUG
   117     endif
   118 endif
   119 
   120 # Additional CFLAGS used for compiling ASN1C-generated code
   121 ifeq ($(BUILD_FOR),Linux)
   122     # The '_DEFAULT_SOURCE' feature test macro is required to suppress the warning
   123     #   _BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE
   124     # otherwise printed during the compilation of every asn1c-generated C file.
   125     # It's a glibc specific warning, only present in few versions around ~2.19.
   126     # See https://lwn.net/Articles/590381/ for a discussion.
   127     CFLAGS_GENERATED=-D_DEFAULT_SOURCE
   128 else ifeq ($(BUILD_FOR),Darwin)
   129     CFLAGS_GENERATED=
   130 endif
   131 
   132 
   133 ######### C++ #########
   134 ifeq ($(BUILD_FOR),Linux)
   135     CXX=g++ -std=gnu++11 -pthread
   136 else ifeq ($(BUILD_FOR),Darwin)
   137     # clang issues a warning when "-pthread" is used for linking. So, include it in CXXFLAGS, and not in CXX
   138     CXX=clang -std=c++11
   139 endif
   140 
   141 # The flag -DNDEBUG will always be removed from CXXFLAGS for compiling tests.
   142 # The tests do not work properly, if compiled with -DNDEBUG
   143 ifeq ($(BUILD_FOR),Linux)
   144     CXXFLAGS=-fdiagnostics-color=always -I../src -I../asn.1 $(ETPAN_INC)
   145     ifdef WARN
   146         CXXFLAGS+=
   147     else
   148         CXXFLAGS+= -w
   149     endif
   150     ifdef DEBUG
   151         CXXFLAGS+= -g -ggdb
   152     else
   153         CXXFLAGS+= -O3 -DNDEBUG
   154     endif
   155 else ifeq ($(BUILD_FOR),Darwin)
   156     CXXFLAGS=-pthread -fcolor-diagnostics -I../src -I../asn.1 $(ETPAN_INC)
   157     ifdef WARN
   158         CXXFLAGS+=
   159     else
   160         CXXFLAGS+= -w
   161     endif
   162     ifdef DEBUG
   163         CXXFLAGS+= -O0 -g
   164     else
   165         CXXFLAGS+= -O3 -DNDEBUG
   166     endif
   167 endif
   168 
   169 
   170 ######### C and C++ #########
   171 CPPFLAGS=
   172 
   173 
   174 ######### YML2 #########
   175 YML2_PATH=$(HOME)/yml2
   176 
   177 YML2_PROC=$(YML2_PATH)/yml2proc $(YML2_OPTS)
   178 
   179 YML2_OPTS=--encoding=utf8
   180 
   181 
   182 ######### asn1c #########
   183 # asn1c binary
   184 ASN1C=asn1c
   185 
   186 # asn1c include search flag
   187 ASN1C_INC=
   188 #ASN1C_INC=-I$(HOME)/include
   189 
   190 
   191 ######### libetpan #########
   192 # libetpan library search flag
   193 ETPAN_LIB=
   194 #ETPAN_LIB=-L$(HOME)/lib
   195 
   196 # libetpan include search flag
   197 ETPAN_INC=
   198 #ETPAN_INC=-I$(HOME)/include
   199 
   200 
   201 ######### pEp MIME #########
   202 # set this to skip libetpan and use PEP_MIME instead
   203 # PEP_MIME=1
   204 #
   205 # pEp MIME library search flag
   206 PEP_MIME_LIB=
   207 # pEp MIME include search flag
   208 PEP_MIME_INC=
   209 
   210 
   211 ######### sqlite3 #########
   212 # If empty (or undefined), compile sqlite3 from the sources shipped with the pEp distribution.
   213 # Otherwise, use an sqlite3 implementation found in the OS's include/library paths.
   214 SQLITE3_FROM_OS=placeholder
   215 
   216 
   217 ######### OpenPGP #########
   218 # Path of GPG binary
   219 # 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.
   220 GPG_CMD:=$(shell gpgconf --list-components | awk -F: '/^gpg:/ { print $$3; exit 0; }')
   221 
   222 # Selects OpenPGP implementation. must be either `SEQUOIA`, `GPG` or `NETPGP`
   223 OPENPGP=GPG
   224 
   225 # Sequoia-specific variables
   226 SEQUOIA_CFLAGS=
   227 SEQUOIA_LDFLAGS=
   228 SEQUOIA_LIB=
   229 SEQUOIA_INC=
   230 
   231 # libGPGME filename
   232 ifeq ($(BUILD_FOR),Linux)
   233     LIBGPGME=libgpgme.so.11
   234 else ifeq ($(BUILD_FOR),Darwin)
   235     LIBGPGME=libgpgme.11.dylib
   236 endif
   237 
   238 # libGPGME library search flag
   239 GPGME_LIB=
   240 #GPGME_LIB=-L$(HOME)/lib
   241 
   242 # libGPGME include search flag
   243 GPGME_INC=
   244 #GPGME_INC=-I$(HOME)/include
   245 
   246 # NETPGP library search flag
   247 NETPGP_LIB=
   248 #NETPGP_LIB=-L$(HOME)/lib
   249 
   250 # libGPGME include search flag
   251 NETPGP_INC=
   252 #NETPGP_INC=-I$(HOME)/include
   253 
   254 
   255 
   256 ######### CppUnit #########
   257 # CppUnit library search flag
   258 CPPUNIT_LIB=
   259 #CPPUNIT_LIB=-L$(HOME)/local/lib
   260 
   261 # CppUnit include search flag
   262 CPPUNIT_INC=
   263 #CPPUNIT_INC=-I$(HOME)/local/inc
   264 
   265 
   266 ######### Engine internals #########
   267 # C macros (not environment variables) that can be overridden:
   268 # DEFAULT_KEYSERVER - string with default keyserver
   269 # CRASHDUMP_DEFAULT_LINES - number of log lines to deliver for crashdumps
   270 # Example:
   271 #    EXTRA_MACROS=-DDEFAULT_KEYSERVER=\"default-server.org\" -DCRASHDUMP_DEFAULT_LINES=23
   272 EXTRA_MACROS=
   273 
   274 
   275 ######### Misc #########
   276 # Add this for running tests in debugger
   277 #TEST_DEBUGGER=lldb --batch -o r
   278 
   279 # comma-separated list of tests to exclude from gensuite (relevant for running tests only)
   280 EXCLUDE=
   281 
   282 
   283 ######### Footer #########
   284 -include $(HERE)/local.conf
   285 
   286 ifdef BUILD_CONFIG
   287     include $(BUILD_CONFIG)
   288 endif
   289 
   290 ######### Post processing assignments ########
   291 # These variables are ineffective when set anywhere else but here.
   292 ifeq ($(OPENPGP),SEQUOIA)
   293     SEQUOIA_CFLAGS=$(shell pkg-config --cflags-only-other sequoia-openpgp)
   294     SEQUOIA_LDFLAGS=$(shell pkg-config --libs-only-l --libs-only-other sequoia-openpgp)
   295     SEQUOIA_LIB=$(shell pkg-config --libs-only-L sequoia-openpgp)
   296     SEQUOIA_INC=$(shell pkg-config --cflags-only-I sequoia-openpgp)
   297     CFLAGS+= $(SEQUOIA_CFLAGS)
   298     LD_FLAGS+= $(SEQUOIA_LDFLAGS)
   299 endif
   300 
   301 # YML_PATH is needed in the environment of every call to a program of the YML2 distribution
   302 export YML_PATH=$(YML2_PATH)