src/Makefile
author Damiano Boppart <damiano@pep-security.net>
Thu, 17 Aug 2017 13:18:19 +0000
branchENGINE-228
changeset 1968 e30b1515b7b9
parent 1966 0329556f28ab
child 1970 9f55b8970727
permissions -rw-r--r--
Add some more in-line documentation for various Makefiles
damiano@1960
     1
# Copyright 2017, pEp Foundation
damiano@1958
     2
# This file is part of pEpEngine
damiano@1958
     3
# This file may be used under the terms of the GNU General Public License version 3
damiano@1958
     4
# see LICENSE.txt
damiano@1958
     5
vb@1
     6
include ../Makefile.conf
vb@1
     7
damiano@1958
     8
CFLAGS+= $(ETPAN_INC) -I../asn.1 -DSYSTEM_DB=\"$(SYSTEM_DB)\" $(EXTRA_MACROS)
damiano@1958
     9
LDFLAGS+= $(ETPAN_LIB) -L../asn.1 -shared
damiano@1958
    10
LDLIBS+= -lc -lasn1 -letpan 
Edouard@168
    11
vb@1
    12
ifeq ($(BUILD_ON),Darwin)
damiano@1958
    13
    ifeq ($(BUILD_FOR),Darwin)
damiano@1958
    14
        #CFLAGS+= -I/opt/local/include
damiano@1958
    15
        #LDFLAGS+= -L/opt/local/lib
damiano@1958
    16
        LDLIBS+= -lsqlite3 -lz -liconv
damiano@1958
    17
    else
damiano@1959
    18
        $(error I don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
damiano@1958
    19
    endif
damiano@1958
    20
else ifeq ($(BUILD_ON),Linux)
damiano@1958
    21
    ifeq ($(BUILD_FOR),Linux)
damiano@1958
    22
        # FIXME Find out if SQLITE_THREADSAFE is needed for both platform.
damiano@1958
    23
        CFLAGS+= -DSQLITE_THREADSAFE=1 -D_GNU_SOURCE
damiano@1958
    24
        LDLIBS+= -ldl -luuid
damiano@1958
    25
    else
damiano@1959
    26
        $(error I don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
damiano@1958
    27
    endif
vb@1
    28
else
damiano@1959
    29
    $(error I don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
vb@1
    30
endif
vb@1
    31
damiano@1958
    32
ifeq ($(OPENPGP),GPG)
damiano@1958
    33
    NO_SOURCE=pgp_netpgp.c
damiano@1958
    34
    CFLAGS+= -DUSE_GPG $(GPGME_INC) -DLIBGPGME=\"$(LIBGPGME)\"
damiano@1958
    35
    LDFLAGS+= $(GPGME_LIB)
damiano@1968
    36
    # No extra LDLIBS are needed here, because GPGME is dynamically loaded
damiano@1958
    37
else ifeq ($(OPENPGP),NETPGP)
damiano@1958
    38
    NO_SOURCE=pgp_gpg.c
damiano@1958
    39
    CFLAGS+= -DUSE_NETPGP $(NETGPG_INC)
damiano@1958
    40
    LDFLAGS+= $(NETGPG_LIB)
damiano@1958
    41
    LDLIBS+= -lnetpgp -lcurl
vb@1
    42
else
damiano@1958
    43
    $(error Unknown OpenPGP library: $(OPENPGP))
Edouard@168
    44
endif
Edouard@168
    45
vb@609
    46
ALL_SOURCE=$(subst $(NO_SOURCE),,$(wildcard *.c))
vb@1
    47
DEPENDS=$(subst .c,.d,$(ALL_SOURCE))
vb@1
    48
ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE))
vb@1
    49
damiano@1958
    50
.PHONY: all
vb@1
    51
all: $(TARGET)
vb@1
    52
damiano@1962
    53
-include Makefile.protocols
vb@606
    54
vb@1
    55
%.d: %.c
vb@1
    56
	@set -e; rm -f $@; \
vb@3
    57
	$(CC) -MM $(CPPFLAGS) $(CFLAGS) $< > $@.$$$$; \
vb@1
    58
	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
vb@1
    59
	rm -f $@.$$$$
vb@1
    60
damiano@1968
    61
# If only the goal 'clean' is given, do not generate and include the '%.d' files.
damiano@1966
    62
ifneq ($(MAKECMDGOALS),clean)
damiano@1966
    63
    -include $(DEPENDS)
damiano@1966
    64
endif
damiano@1966
    65
damiano@1958
    66
$(TARGET): libpEpEngine.a
damiano@1959
    67
	$(CC) $(ALL_OBJECTS) $(LDFLAGS) $(LDLIBS) -o $@
vb@1
    68
damiano@1959
    69
.PHONY: objects
vb@1
    70
objects: $(ALL_OBJECTS)
vb@1
    71
vb@1
    72
libpEpEngine.a: $(ALL_OBJECTS)
damiano@1958
    73
	ar -rc $@ $^
vb@1
    74
vb@1
    75
.PHONY: clean
vb@1
    76
clean:
vb@1
    77
	rm -f *.d *.o *.a $(TARGET) *.dll *.so *.zip *.d.* *.def *~
vb@1
    78
damiano@1958
    79
.PHONY: install
vb@1
    80
install: $(TARGET)
vb@1
    81
	cp $< $(PREFIX)/lib/
vb@171
    82
	mkdir -p $(PREFIX)/include/pEp
edouard@1789
    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/
vb@1
    84
damiano@1958
    85
.PHONY: uninstall
vb@1
    86
uninstall:
vb@1
    87
	rm -f $(PREFIX)/lib/$(TARGET)
damiano@1958
    88
	rm -rf $(PREFIX)/include/pEp