src/Makefile
author Krista Bennett <krista@pep-project.org>
Fri, 04 May 2018 16:30:21 +0200
branchlocal_cpptest
changeset 2652 43b913f99a27
parent 2400 424f37a81a6b
child 2847 930626fcac04
child 3016 bd2796d69c13
permissions -rw-r--r--
Shelving broken things to break other things
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
damiano@2210
     6
include ../default.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@1991
    10
LDLIBS+= -lc -letpan -lasn1
damiano@1997
    11
NO_SOURCE=
Edouard@168
    12
vb@1
    13
ifeq ($(BUILD_ON),Darwin)
damiano@1958
    14
    ifeq ($(BUILD_FOR),Darwin)
damiano@1971
    15
        CFLAGS+= -DSQLITE_THREADSAFE=1
damiano@2003
    16
        LDLIBS+= -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@1997
    31
ifdef SQLITE3_FROM_OS
damiano@1997
    32
    NO_SOURCE+= sqlite3.c
damiano@1997
    33
    CFLAGS+= -DSQLITE3_FROM_OS
damiano@2003
    34
    LDLIBS+= -lsqlite3
damiano@1997
    35
endif
damiano@1997
    36
damiano@1958
    37
ifeq ($(OPENPGP),GPG)
damiano@1997
    38
    NO_SOURCE+= pgp_netpgp.c
damiano@1958
    39
    CFLAGS+= -DUSE_GPG $(GPGME_INC) -DLIBGPGME=\"$(LIBGPGME)\"
damiano@1958
    40
    LDFLAGS+= $(GPGME_LIB)
damiano@1968
    41
    # No extra LDLIBS are needed here, because GPGME is dynamically loaded
damiano@1958
    42
else ifeq ($(OPENPGP),NETPGP)
damiano@1997
    43
    NO_SOURCE+= pgp_gpg.c
damiano@1958
    44
    CFLAGS+= -DUSE_NETPGP $(NETGPG_INC)
damiano@1958
    45
    LDFLAGS+= $(NETGPG_LIB)
damiano@1958
    46
    LDLIBS+= -lnetpgp -lcurl
krista@1989
    47
else
damiano@1958
    48
    $(error Unknown OpenPGP library: $(OPENPGP))
Edouard@168
    49
endif
Edouard@168
    50
damiano@1997
    51
ALL_SOURCE=$(filter-out $(NO_SOURCE),$(wildcard *.c))
vb@1
    52
DEPENDS=$(subst .c,.d,$(ALL_SOURCE))
vb@1
    53
ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE))
vb@1
    54
damiano@1958
    55
.PHONY: all
vb@1
    56
all: $(TARGET)
vb@1
    57
damiano@1962
    58
-include Makefile.protocols
vb@606
    59
vb@1
    60
%.d: %.c
vb@1
    61
	@set -e; rm -f $@; \
vb@3
    62
	$(CC) -MM $(CPPFLAGS) $(CFLAGS) $< > $@.$$$$; \
vb@1
    63
	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
vb@1
    64
	rm -f $@.$$$$
vb@1
    65
damiano@1968
    66
# If only the goal 'clean' is given, do not generate and include the '%.d' files.
damiano@1966
    67
ifneq ($(MAKECMDGOALS),clean)
damiano@1966
    68
    -include $(DEPENDS)
damiano@1966
    69
endif
vb@1
    70
vb@1
    71
$(TARGET): libpEpEngine.a
damiano@1959
    72
	$(CC) $(ALL_OBJECTS) $(LDFLAGS) $(LDLIBS) -o $@
vb@1
    73
damiano@1959
    74
.PHONY: objects
vb@1
    75
objects: $(ALL_OBJECTS)
vb@1
    76
vb@1
    77
libpEpEngine.a: $(ALL_OBJECTS)
damiano@1958
    78
	ar -rc $@ $^
vb@1
    79
vb@1
    80
.PHONY: clean
vb@1
    81
clean:
vb@1
    82
	rm -f *.d *.o *.a $(TARGET) *.dll *.so *.zip *.d.* *.def *~
vb@2342
    83
	rm -Rf $(TARGET).dSYM
vb@1
    84
damiano@1958
    85
.PHONY: install
vb@1
    86
install: $(TARGET)
damiano@1970
    87
	mkdir -p "$(PREFIX)/lib/"
vb@1
    88
	cp $< $(PREFIX)/lib/
vb@171
    89
	mkdir -p $(PREFIX)/include/pEp
roker@2400
    90
	cp -v pEpEngine.h keymanagement.h message_api.h dynamic_api.h stringlist.h \
roker@2400
    91
	      timestamp.h identity_list.h bloblist.h stringpair.h message.h mime.h \
roker@2400
    92
	      cryptotech.h sync.h sync_fsm.h sync_app.h blacklist.h pEp_string.h \
roker@2400
    93
	      openpgp_compat.h $(PREFIX)/include/pEp/
vb@1
    94
damiano@1958
    95
.PHONY: uninstall
vb@1
    96
uninstall:
vb@1
    97
	rm -f $(PREFIX)/lib/$(TARGET)
damiano@1958
    98
	rm -rf $(PREFIX)/include/pEp