src/Makefile
author Damiano Boppart <damiano.boppart@pep.security>
Sat, 22 Dec 2018 01:34:30 +0100
branchmake-cleanup
changeset 3204 fa2e7ead0f4e
parent 3202 3f440e46823c
child 3235 7633eeee2cd4
permissions -rw-r--r--
Minor makefile fixes
     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 	rm -Rf $(TARGET).dSYM
    84 	rm -f KeySync_fsm.* Sync_actions.c Sync_event.* Sync_func.* Sync_impl.* sync_codec.*
    85 
    86 .PHONY: install
    87 install: $(TARGET)
    88 	mkdir -p "$(PREFIX)/lib/"
    89 	cp $< $(PREFIX)/lib/
    90 	mkdir -p $(PREFIX)/include/pEp
    91 	cp pEpEngine.h keymanagement.h message_api.h dynamic_api.h stringlist.h \
    92 	   timestamp.h identity_list.h bloblist.h stringpair.h message.h mime.h \
    93 	   cryptotech.h sync_api.h blacklist.h pEp_string.h openpgp_compat.h \
    94 	   labeled_int_list.h key_reset.h base64.h sync_codec.h \
    95 	   ../asn.1/*.h $(PREFIX)/include/pEp/
    96 
    97 .PHONY: uninstall
    98 uninstall:
    99 	rm -f $(PREFIX)/lib/$(TARGET)
   100 	rm -rf $(PREFIX)/include/pEp
   101 
   102 .PHONY: tags
   103 tags:
   104 	ctags *.c *.h
   105