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