src/Makefile
author Damiano Boppart <damiano@pep-security.net>
Fri, 18 Aug 2017 14:29:51 +0000
branchENGINE-228
changeset 1971 975a44e59f31
parent 1970 9f55b8970727
child 1991 7dfc2771f082
permissions -rw-r--r--
Set the default SQLITE_THREADSAFE on both platforms
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@1971
    14
        CFLAGS+= -DSQLITE_THREADSAFE=1
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
        CFLAGS+= -DSQLITE_THREADSAFE=1 -D_GNU_SOURCE
damiano@1958
    23
        LDLIBS+= -ldl -luuid
damiano@1958
    24
    else
damiano@1959
    25
        $(error I don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
damiano@1958
    26
    endif
vb@1
    27
else
damiano@1959
    28
    $(error I don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
vb@1
    29
endif
vb@1
    30
damiano@1958
    31
ifeq ($(OPENPGP),GPG)
damiano@1958
    32
    NO_SOURCE=pgp_netpgp.c
damiano@1958
    33
    CFLAGS+= -DUSE_GPG $(GPGME_INC) -DLIBGPGME=\"$(LIBGPGME)\"
damiano@1958
    34
    LDFLAGS+= $(GPGME_LIB)
damiano@1968
    35
    # No extra LDLIBS are needed here, because GPGME is dynamically loaded
damiano@1958
    36
else ifeq ($(OPENPGP),NETPGP)
damiano@1958
    37
    NO_SOURCE=pgp_gpg.c
damiano@1958
    38
    CFLAGS+= -DUSE_NETPGP $(NETGPG_INC)
damiano@1958
    39
    LDFLAGS+= $(NETGPG_LIB)
damiano@1958
    40
    LDLIBS+= -lnetpgp -lcurl
vb@1
    41
else
damiano@1958
    42
    $(error Unknown OpenPGP library: $(OPENPGP))
Edouard@168
    43
endif
Edouard@168
    44
vb@609
    45
ALL_SOURCE=$(subst $(NO_SOURCE),,$(wildcard *.c))
vb@1
    46
DEPENDS=$(subst .c,.d,$(ALL_SOURCE))
vb@1
    47
ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE))
vb@1
    48
damiano@1958
    49
.PHONY: all
vb@1
    50
all: $(TARGET)
vb@1
    51
damiano@1962
    52
-include Makefile.protocols
vb@606
    53
vb@1
    54
%.d: %.c
vb@1
    55
	@set -e; rm -f $@; \
vb@3
    56
	$(CC) -MM $(CPPFLAGS) $(CFLAGS) $< > $@.$$$$; \
vb@1
    57
	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
vb@1
    58
	rm -f $@.$$$$
vb@1
    59
damiano@1968
    60
# If only the goal 'clean' is given, do not generate and include the '%.d' files.
damiano@1966
    61
ifneq ($(MAKECMDGOALS),clean)
damiano@1966
    62
    -include $(DEPENDS)
damiano@1966
    63
endif
damiano@1966
    64
damiano@1958
    65
$(TARGET): libpEpEngine.a
damiano@1959
    66
	$(CC) $(ALL_OBJECTS) $(LDFLAGS) $(LDLIBS) -o $@
vb@1
    67
damiano@1959
    68
.PHONY: objects
vb@1
    69
objects: $(ALL_OBJECTS)
vb@1
    70
vb@1
    71
libpEpEngine.a: $(ALL_OBJECTS)
damiano@1958
    72
	ar -rc $@ $^
vb@1
    73
vb@1
    74
.PHONY: clean
vb@1
    75
clean:
vb@1
    76
	rm -f *.d *.o *.a $(TARGET) *.dll *.so *.zip *.d.* *.def *~
vb@1
    77
damiano@1958
    78
.PHONY: install
vb@1
    79
install: $(TARGET)
damiano@1970
    80
	mkdir -p "$(PREFIX)/lib/"
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