src/Makefile
author Damiano Boppart <damiano@pep-security.net>
Thu, 17 Aug 2017 13:18:19 +0000
branchENGINE-228
changeset 1968 e30b1515b7b9
parent 1966 0329556f28ab
child 1970 9f55b8970727
permissions -rw-r--r--
Add some more in-line documentation for various Makefiles
     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 include ../Makefile.conf
     7 
     8 CFLAGS+= $(ETPAN_INC) -I../asn.1 -DSYSTEM_DB=\"$(SYSTEM_DB)\" $(EXTRA_MACROS)
     9 LDFLAGS+= $(ETPAN_LIB) -L../asn.1 -shared
    10 LDLIBS+= -lc -lasn1 -letpan 
    11 
    12 ifeq ($(BUILD_ON),Darwin)
    13     ifeq ($(BUILD_FOR),Darwin)
    14         #CFLAGS+= -I/opt/local/include
    15         #LDFLAGS+= -L/opt/local/lib
    16         LDLIBS+= -lsqlite3 -lz -liconv
    17     else
    18         $(error I don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
    19     endif
    20 else ifeq ($(BUILD_ON),Linux)
    21     ifeq ($(BUILD_FOR),Linux)
    22         # FIXME Find out if SQLITE_THREADSAFE is needed for both platform.
    23         CFLAGS+= -DSQLITE_THREADSAFE=1 -D_GNU_SOURCE
    24         LDLIBS+= -ldl -luuid
    25     else
    26         $(error I don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
    27     endif
    28 else
    29     $(error I don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
    30 endif
    31 
    32 ifeq ($(OPENPGP),GPG)
    33     NO_SOURCE=pgp_netpgp.c
    34     CFLAGS+= -DUSE_GPG $(GPGME_INC) -DLIBGPGME=\"$(LIBGPGME)\"
    35     LDFLAGS+= $(GPGME_LIB)
    36     # No extra LDLIBS are needed here, because GPGME is dynamically loaded
    37 else ifeq ($(OPENPGP),NETPGP)
    38     NO_SOURCE=pgp_gpg.c
    39     CFLAGS+= -DUSE_NETPGP $(NETGPG_INC)
    40     LDFLAGS+= $(NETGPG_LIB)
    41     LDLIBS+= -lnetpgp -lcurl
    42 else
    43     $(error Unknown OpenPGP library: $(OPENPGP))
    44 endif
    45 
    46 ALL_SOURCE=$(subst $(NO_SOURCE),,$(wildcard *.c))
    47 DEPENDS=$(subst .c,.d,$(ALL_SOURCE))
    48 ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE))
    49 
    50 .PHONY: all
    51 all: $(TARGET)
    52 
    53 -include Makefile.protocols
    54 
    55 %.d: %.c
    56 	@set -e; rm -f $@; \
    57 	$(CC) -MM $(CPPFLAGS) $(CFLAGS) $< > $@.$$$$; \
    58 	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
    59 	rm -f $@.$$$$
    60 
    61 # If only the goal 'clean' is given, do not generate and include the '%.d' files.
    62 ifneq ($(MAKECMDGOALS),clean)
    63     -include $(DEPENDS)
    64 endif
    65 
    66 $(TARGET): libpEpEngine.a
    67 	$(CC) $(ALL_OBJECTS) $(LDFLAGS) $(LDLIBS) -o $@
    68 
    69 .PHONY: objects
    70 objects: $(ALL_OBJECTS)
    71 
    72 libpEpEngine.a: $(ALL_OBJECTS)
    73 	ar -rc $@ $^
    74 
    75 .PHONY: clean
    76 clean:
    77 	rm -f *.d *.o *.a $(TARGET) *.dll *.so *.zip *.d.* *.def *~
    78 
    79 .PHONY: install
    80 install: $(TARGET)
    81 	cp $< $(PREFIX)/lib/
    82 	mkdir -p $(PREFIX)/include/pEp
    83 	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/
    84 
    85 .PHONY: uninstall
    86 uninstall:
    87 	rm -f $(PREFIX)/lib/$(TARGET)
    88 	rm -rf $(PREFIX)/include/pEp