src/Makefile
author Krista Bennett <krista@pep-project.org>
Tue, 29 Aug 2017 17:51:51 +0200
branchENGINE-233
changeset 2021 c15acce7cee9
parent 2013 3ef02ca70fec
parent 2003 9af7ecb78779
child 2210 17c30881c885
permissions -rw-r--r--
merged in default
     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 -letpan -lasn1
    11 NO_SOURCE=
    12 
    13 ifeq ($(BUILD_ON),Darwin)
    14     ifeq ($(BUILD_FOR),Darwin)
    15         CFLAGS+= -DSQLITE_THREADSAFE=1
    16         LDLIBS+= -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         CFLAGS+= -DSQLITE_THREADSAFE=1 -D_GNU_SOURCE
    23         LDLIBS+= -ldl -luuid
    24     else
    25         $(error I don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
    26     endif
    27 else
    28     $(error I don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
    29 endif
    30 
    31 ifdef SQLITE3_FROM_OS
    32     NO_SOURCE+= sqlite3.c
    33     CFLAGS+= -DSQLITE3_FROM_OS
    34     LDLIBS+= -lsqlite3
    35 endif
    36 
    37 ifeq ($(OPENPGP),GPG)
    38     NO_SOURCE+= pgp_netpgp.c
    39     CFLAGS+= -DUSE_GPG $(GPGME_INC) -DLIBGPGME=\"$(LIBGPGME)\"
    40     LDFLAGS+= $(GPGME_LIB)
    41     # No extra LDLIBS are needed here, because GPGME is dynamically loaded
    42 else ifeq ($(OPENPGP),NETPGP)
    43     NO_SOURCE+= pgp_gpg.c
    44     CFLAGS+= -DUSE_NETPGP $(NETGPG_INC)
    45     LDFLAGS+= $(NETGPG_LIB)
    46     LDLIBS+= -lnetpgp -lcurl
    47 else
    48     $(error Unknown OpenPGP library: $(OPENPGP))
    49 endif
    50 
    51 ALL_SOURCE=$(filter-out $(NO_SOURCE),$(wildcard *.c))
    52 DEPENDS=$(subst .c,.d,$(ALL_SOURCE))
    53 ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE))
    54 
    55 .PHONY: all
    56 all: $(TARGET)
    57 
    58 -include Makefile.protocols
    59 
    60 %.d: %.c
    61 	@set -e; rm -f $@; \
    62 	$(CC) -MM $(CPPFLAGS) $(CFLAGS) $< > $@.$$$$; \
    63 	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
    64 	rm -f $@.$$$$
    65 
    66 # If only the goal 'clean' is given, do not generate and include the '%.d' files.
    67 ifneq ($(MAKECMDGOALS),clean)
    68     -include $(DEPENDS)
    69 endif
    70 
    71 $(TARGET): libpEpEngine.a
    72 	$(CC) $(ALL_OBJECTS) $(LDFLAGS) $(LDLIBS) -o $@
    73 
    74 .PHONY: objects
    75 objects: $(ALL_OBJECTS)
    76 
    77 libpEpEngine.a: $(ALL_OBJECTS)
    78 	ar -rc $@ $^
    79 
    80 .PHONY: clean
    81 clean:
    82 	rm -f *.d *.o *.a $(TARGET) *.dll *.so *.zip *.d.* *.def *~
    83 
    84 .PHONY: install
    85 install: $(TARGET)
    86 	mkdir -p "$(PREFIX)/lib/"
    87 	cp $< $(PREFIX)/lib/
    88 	mkdir -p $(PREFIX)/include/pEp
    89 	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/
    90 
    91 .PHONY: uninstall
    92 uninstall:
    93 	rm -f $(PREFIX)/lib/$(TARGET)
    94 	rm -rf $(PREFIX)/include/pEp