src/Makefile
author Krista 'DarthMama' Bennett <krista@pep.foundation>
Thu, 04 Jun 2020 11:18:45 +0200
changeset 4729 3df9a2a67597
parent 4559 7b966b4038c1
child 4577 ffae0defc0a4
child 4585 af441dfc1d2c
child 4605 4fb5fe24b46b
permissions -rw-r--r--
forgot test files
     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),SEQUOIA)
    53     CFLAGS+= -DUSE_SEQUOIA $(SEQUOIA_CFLAGS) $(SEQUOIA_INC)
    54     LDFLAGS+= $(SEQUOIA_LDFLAGS)
    55     LDLIBS+= $(SEQUOIA_LIB)
    56 else
    57     $(error Unknown OpenPGP library: $(OPENPGP))
    58 endif
    59 
    60 ALL_SOURCE=$(filter-out $(NO_SOURCE),$(wildcard *.c))
    61 DEPENDS=$(subst .c,.d,$(ALL_SOURCE))
    62 ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE))
    63 
    64 all: $(TARGET)
    65 
    66 -include Makefile.protocols
    67 
    68 %.d: %.c
    69 	@set -e; rm -f $@; \
    70 	$(CC) -MM $(CPPFLAGS) $(CFLAGS) $< > $@.$$$$; \
    71 	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
    72 	rm -f $@.$$$$
    73 
    74 # If only the goal 'clean' is given, do not generate and include the '%.d' files.
    75 ifneq ($(MAKECMDGOALS),clean)
    76     -include $(DEPENDS)
    77 endif
    78 
    79 $(TARGET): libpEpEngine.a
    80 	$(CC) $(CFLAGS) $(ALL_OBJECTS) $(LDFLAGS) $(LDLIBS) -o $@
    81 
    82 .PHONY: objects clean install_headers install uninstall beinstall
    83 
    84 objects: $(ALL_OBJECTS)
    85 
    86 libpEpEngine.a: $(ALL_OBJECTS)
    87 	$(AR) -rc $@ $^
    88 
    89 clean:
    90 	rm -f *.d *.o *.a $(TARGET) *.dll *.so *.zip *.d.* *.def *~
    91 	rm -Rf $(TARGET).dSYM
    92 	rm -f KeySync_fsm.* Sync_actions.c Sync_event.* Sync_func.* Sync_impl.* sync_codec.* distribution_codec.*
    93 
    94 # CAVEAT:
    95 # install_headers is needed for building pEp MIME
    96 
    97 install_headers: $(TARGET)
    98 	mkdir -p $(PREFIX)/include/pEp
    99 	cp pEpEngine.h keymanagement.h message_api.h dynamic_api.h stringlist.h \
   100 	   timestamp.h identity_list.h bloblist.h stringpair.h message.h mime.h \
   101 	   cryptotech.h sync_api.h blacklist.h pEp_string.h openpgp_compat.h mime.h \
   102 	   labeled_int_list.h key_reset.h base64.h sync_codec.h distribution_codec.h \
   103 	   status_to_string.h aux_mime_msg.h keyreset_command.h platform.h platform_unix.h ../asn.1/*.h \
   104  	   $(PREFIX)/include/pEp/
   105 
   106 install: $(TARGET) install_headers
   107 	mkdir -p "$(PREFIX)/lib/"
   108 	cp $< $(PREFIX)/lib/
   109 
   110 beinstall: install
   111 	cp platform*.h $(PREFIX)/include/pEp/
   112 
   113 uninstall:
   114 	rm -f $(PREFIX)/lib/$(TARGET)
   115 	rm -rf $(PREFIX)/include/pEp
   116 
   117 tags: $(wildcard *.c) $(wildcard *.h)
   118 	ctags --sort=yes *.c *.h
   119