src/Makefile
author Damiano Boppart <damiano@pep-security.net>
Wed, 23 Aug 2017 11:06:55 +0000
branchENGINE-228
changeset 1993 efaeadf3e6f0
parent 1991 7dfc2771f082
parent 1989 d3e5bc4a9854
child 1997 2c10033e2ade
permissions -rw-r--r--
Merge 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 
    12 ifeq ($(BUILD_ON),Darwin)
    13     ifeq ($(BUILD_FOR),Darwin)
    14         CFLAGS+= -DSQLITE_THREADSAFE=1
    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         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 ifeq ($(OPENPGP),GPG)
    32     NO_SOURCE=pgp_netpgp.c
    33     CFLAGS+= -DUSE_GPG $(GPGME_INC) -DLIBGPGME=\"$(LIBGPGME)\"
    34     LDFLAGS+= $(GPGME_LIB)
    35     # No extra LDLIBS are needed here, because GPGME is dynamically loaded
    36 else ifeq ($(OPENPGP),NETPGP)
    37     NO_SOURCE=pgp_gpg.c
    38     CFLAGS+= -DUSE_NETPGP $(NETGPG_INC)
    39     LDFLAGS+= $(NETGPG_LIB)
    40     LDLIBS+= -lnetpgp -lcurl
    41 else
    42     $(error Unknown OpenPGP library: $(OPENPGP))
    43 endif
    44 
    45 ALL_SOURCE=$(subst $(NO_SOURCE),,$(wildcard *.c))
    46 DEPENDS=$(subst .c,.d,$(ALL_SOURCE))
    47 ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE))
    48 
    49 .PHONY: all
    50 all: $(TARGET)
    51 
    52 -include Makefile.protocols
    53 
    54 %.d: %.c
    55 	@set -e; rm -f $@; \
    56 	$(CC) -MM $(CPPFLAGS) $(CFLAGS) $< > $@.$$$$; \
    57 	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
    58 	rm -f $@.$$$$
    59 
    60 # If only the goal 'clean' is given, do not generate and include the '%.d' files.
    61 ifneq ($(MAKECMDGOALS),clean)
    62     -include $(DEPENDS)
    63 endif
    64 
    65 $(TARGET): libpEpEngine.a
    66 	$(CC) $(ALL_OBJECTS) $(LDFLAGS) $(LDLIBS) -o $@
    67 
    68 .PHONY: objects
    69 objects: $(ALL_OBJECTS)
    70 
    71 libpEpEngine.a: $(ALL_OBJECTS)
    72 	ar -rc $@ $^
    73 
    74 .PHONY: clean
    75 clean:
    76 	rm -f *.d *.o *.a $(TARGET) *.dll *.so *.zip *.d.* *.def *~
    77 
    78 .PHONY: install
    79 install: $(TARGET)
    80 	mkdir -p "$(PREFIX)/lib/"
    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