src/Makefile
author Volker Birk <vb@pep-project.org>
Fri, 17 May 2019 17:59:06 +0200
branchsync
changeset 3720 9ed76a79d784
parent 3630 21530e16b1ed
child 4003 572e950593dc
permissions -rw-r--r--
...
     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) $(PEP_MIME_INC) -I../asn.1 -DSYSTEM_DB=\"$(SYSTEM_DB)\" $(EXTRA_MACROS)
     9 LDFLAGS+= $(ETPAN_LIB) $(PEP_MIME_LIB) -L../asn.1 -shared
    10 LDLIBS+= -lc -lasn1
    11 NO_SOURCE=
    12 
    13 ifndef PEP_MIME
    14 LDLIBS+= -letpan
    15 else
    16 LDLIBS+= -lpEpMIME
    17 NO_SOURCE+= etpan_mime.c
    18 endif
    19 
    20 ifeq ($(BUILD_ON),Darwin)
    21     ifeq ($(BUILD_FOR),Darwin)
    22         CFLAGS+= -DSQLITE_THREADSAFE=1
    23         LDLIBS+= -lz -liconv
    24     else
    25         $(error I do not know how to make for $(BUILD_FOR) on $(BUILD_ON))
    26     endif
    27 else ifeq ($(BUILD_ON),Linux)
    28     ifeq ($(BUILD_FOR),Linux)
    29         CFLAGS+= -DSQLITE_THREADSAFE=1 -D_GNU_SOURCE
    30         LDLIBS+= -ldl -luuid
    31     else
    32         $(error I do not know how to make for $(BUILD_FOR) on $(BUILD_ON))
    33     endif
    34 else
    35     $(error I do not know how to make for $(BUILD_FOR) on $(BUILD_ON))
    36 endif
    37 
    38 ifdef SQLITE3_FROM_OS
    39     NO_SOURCE+= sqlite3.c
    40     CFLAGS+= -DSQLITE3_FROM_OS
    41     LDLIBS+= -lsqlite3
    42 endif
    43 
    44 ifeq ($(OPENPGP),GPG)
    45     NO_SOURCE+= pgp_netpgp.c pgp_sequoia.c
    46     CFLAGS+= -DUSE_GPG $(GPGME_INC) -DLIBGPGME=\"$(LIBGPGME)\"
    47     LDFLAGS+= $(GPGME_LIB)
    48     # No extra LDLIBS are needed here, because GPGME is dynamically loaded
    49 else ifeq ($(OPENPGP),NETPGP)
    50     NO_SOURCE+= pgp_gpg.c pgp_sequoia.c
    51     CFLAGS+= -DUSE_NETPGP $(NETGPG_INC)
    52     LDFLAGS+= $(NETGPG_LIB)
    53     LDLIBS+= -lnetpgp -lcurl
    54 else ifeq ($(OPENPGP),SEQUOIA)
    55     NO_SOURCE+= pgp_gpg.c pgp_netpgp.c
    56     CFLAGS+= -DUSE_SEQUOIA $(SEQUOIA_CFLAGS) $(SEQUOIA_INC)
    57     LDFLAGS+= $(SEQUOIA_LDFLAGS)
    58     LDLIBS+= $(SEQUOIA_LIB)
    59 else
    60     $(error Unknown OpenPGP library: $(OPENPGP))
    61 endif
    62 
    63 ALL_SOURCE=$(filter-out $(NO_SOURCE),$(wildcard *.c))
    64 DEPENDS=$(subst .c,.d,$(ALL_SOURCE))
    65 ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE))
    66 
    67 all: $(TARGET)
    68 
    69 -include Makefile.protocols
    70 
    71 %.d: %.c
    72 	@set -e; rm -f $@; \
    73 	$(CC) -MM $(CPPFLAGS) $(CFLAGS) $< > $@.$$$$; \
    74 	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
    75 	rm -f $@.$$$$
    76 
    77 # If only the goal 'clean' is given, do not generate and include the '%.d' files.
    78 ifneq ($(MAKECMDGOALS),clean)
    79     -include $(DEPENDS)
    80 endif
    81 
    82 $(TARGET): libpEpEngine.a
    83 	$(CC) $(CFLAGS) $(ALL_OBJECTS) $(LDFLAGS) $(LDLIBS) -o $@
    84 
    85 .PHONY: objects clean install_headers install uninstall
    86 
    87 objects: $(ALL_OBJECTS)
    88 
    89 libpEpEngine.a: $(ALL_OBJECTS)
    90 	$(AR) -rc $@ $^
    91 
    92 clean:
    93 	rm -f *.d *.o *.a $(TARGET) *.dll *.so *.zip *.d.* *.def *~
    94 	rm -Rf $(TARGET).dSYM
    95 	rm -f KeySync_fsm.* Sync_actions.c Sync_event.* Sync_func.* Sync_impl.* sync_codec.*
    96 
    97 # CAVEAT:
    98 # install_headers is needed for building pEp MIME
    99 
   100 install_headers:
   101 	mkdir -p $(PREFIX)/include/pEp
   102 	cp pEpEngine.h keymanagement.h message_api.h dynamic_api.h stringlist.h \
   103 	   timestamp.h identity_list.h bloblist.h stringpair.h message.h mime.h \
   104 	   cryptotech.h sync_api.h blacklist.h pEp_string.h openpgp_compat.h \
   105 	   labeled_int_list.h key_reset.h base64.h sync_codec.h status_to_string.h\
   106 	   aux_mime_msg.h ../asn.1/*.h $(PREFIX)/include/pEp/
   107 
   108 install: $(TARGET) install_headers
   109 	mkdir -p "$(PREFIX)/lib/"
   110 	cp $< $(PREFIX)/lib/
   111 
   112 uninstall:
   113 	rm -f $(PREFIX)/lib/$(TARGET)
   114 	rm -rf $(PREFIX)/include/pEp
   115 
   116 tags: $(wildcard *.c) $(wildcard *.h)
   117 	ctags *.c *.h
   118