src/Makefile
author Volker Birk <vb@pep-project.org>
Fri, 05 Apr 2019 20:04:11 +0200
branchsync
changeset 3445 d5bea8ccf7a5
parent 3444 b02aedcd6a50
child 3447 859cffbe72b8
permissions -rw-r--r--
correcting double build
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@3201
     6
include ../Makefile.conf
vb@1
     7
vb@3443
     8
CFLAGS+= $(ETPAN_INC) $(PEP_MIME_INC) -I../asn.1 -DSYSTEM_DB=\"$(SYSTEM_DB)\" $(EXTRA_MACROS)
vb@3443
     9
LDFLAGS+= $(ETPAN_LIB) $(PEP_MIME_LIB) -L../asn.1 -shared
vb@3443
    10
LDLIBS+= -lc -lasn1
damiano@1997
    11
NO_SOURCE=
Edouard@168
    12
vb@3443
    13
ifndef PEP_MIME
vb@3443
    14
LDLIBS+= -letpan
vb@3443
    15
else
vb@3443
    16
LDLIBS+= -lpEpMIME
vb@3443
    17
NO_SOURCE+= etpan_mime.c
vb@3443
    18
endif
vb@3443
    19
vb@1
    20
ifeq ($(BUILD_ON),Darwin)
damiano@1958
    21
    ifeq ($(BUILD_FOR),Darwin)
damiano@1971
    22
        CFLAGS+= -DSQLITE_THREADSAFE=1
damiano@2003
    23
        LDLIBS+= -lz -liconv
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
damiano@1958
    27
else ifeq ($(BUILD_ON),Linux)
damiano@1958
    28
    ifeq ($(BUILD_FOR),Linux)
damiano@1958
    29
        CFLAGS+= -DSQLITE_THREADSAFE=1 -D_GNU_SOURCE
damiano@1958
    30
        LDLIBS+= -ldl -luuid
damiano@1958
    31
    else
damiano@1959
    32
        $(error I don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
damiano@1958
    33
    endif
vb@1
    34
else
damiano@1959
    35
    $(error I don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
vb@1
    36
endif
vb@1
    37
damiano@1997
    38
ifdef SQLITE3_FROM_OS
damiano@1997
    39
    NO_SOURCE+= sqlite3.c
damiano@1997
    40
    CFLAGS+= -DSQLITE3_FROM_OS
damiano@2003
    41
    LDLIBS+= -lsqlite3
damiano@1997
    42
endif
damiano@1997
    43
damiano@1958
    44
ifeq ($(OPENPGP),GPG)
neal@3191
    45
    NO_SOURCE+= pgp_netpgp.c pgp_sequoia.c
damiano@1958
    46
    CFLAGS+= -DUSE_GPG $(GPGME_INC) -DLIBGPGME=\"$(LIBGPGME)\"
damiano@1958
    47
    LDFLAGS+= $(GPGME_LIB)
damiano@1968
    48
    # No extra LDLIBS are needed here, because GPGME is dynamically loaded
damiano@1958
    49
else ifeq ($(OPENPGP),NETPGP)
neal@3191
    50
    NO_SOURCE+= pgp_gpg.c pgp_sequoia.c
damiano@1958
    51
    CFLAGS+= -DUSE_NETPGP $(NETGPG_INC)
damiano@1958
    52
    LDFLAGS+= $(NETGPG_LIB)
damiano@1958
    53
    LDLIBS+= -lnetpgp -lcurl
neal@3191
    54
else ifeq ($(OPENPGP),SEQUOIA)
neal@3191
    55
    NO_SOURCE+= pgp_gpg.c pgp_netpgp.c
neal@3191
    56
    CFLAGS+= -DUSE_SEQUOIA $(SEQUOIA_CFLAGS) $(SEQUOIA_INC)
neal@3191
    57
    LDFLAGS+= $(SEQUOIA_LDFLAGS)
neal@3191
    58
    LDLIBS+= $(SEQUOIA_LIB)
krista@1989
    59
else
damiano@1958
    60
    $(error Unknown OpenPGP library: $(OPENPGP))
Edouard@168
    61
endif
Edouard@168
    62
damiano@1997
    63
ALL_SOURCE=$(filter-out $(NO_SOURCE),$(wildcard *.c))
vb@1
    64
DEPENDS=$(subst .c,.d,$(ALL_SOURCE))
vb@1
    65
ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE))
vb@1
    66
vb@1
    67
all: $(TARGET)
vb@1
    68
damiano@1962
    69
-include Makefile.protocols
vb@606
    70
vb@1
    71
%.d: %.c
vb@1
    72
	@set -e; rm -f $@; \
vb@3
    73
	$(CC) -MM $(CPPFLAGS) $(CFLAGS) $< > $@.$$$$; \
vb@1
    74
	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
vb@1
    75
	rm -f $@.$$$$
vb@1
    76
damiano@1968
    77
# If only the goal 'clean' is given, do not generate and include the '%.d' files.
damiano@1966
    78
ifneq ($(MAKECMDGOALS),clean)
damiano@1966
    79
    -include $(DEPENDS)
damiano@1966
    80
endif
vb@1
    81
vb@1
    82
$(TARGET): libpEpEngine.a
damiano@1959
    83
	$(CC) $(ALL_OBJECTS) $(LDFLAGS) $(LDLIBS) -o $@
vb@1
    84
vb@1
    85
objects: $(ALL_OBJECTS)
vb@1
    86
vb@1
    87
libpEpEngine.a: $(ALL_OBJECTS)
roker@3324
    88
	$(AR) -rc $@ $^
vb@1
    89
vb@1
    90
.PHONY: clean
vb@1
    91
clean:
vb@1
    92
	rm -f *.d *.o *.a $(TARGET) *.dll *.so *.zip *.d.* *.def *~
vb@2342
    93
	rm -Rf $(TARGET).dSYM
damiano@3195
    94
	rm -f KeySync_fsm.* Sync_actions.c Sync_event.* Sync_func.* Sync_impl.* sync_codec.*
vb@1
    95
vb@1
    96
install: $(TARGET)
damiano@1970
    97
	mkdir -p "$(PREFIX)/lib/"
vb@1
    98
	cp $< $(PREFIX)/lib/
vb@171
    99
	mkdir -p $(PREFIX)/include/pEp
damiano@3204
   100
	cp pEpEngine.h keymanagement.h message_api.h dynamic_api.h stringlist.h \
damiano@3204
   101
	   timestamp.h identity_list.h bloblist.h stringpair.h message.h mime.h \
damiano@3204
   102
	   cryptotech.h sync_api.h blacklist.h pEp_string.h openpgp_compat.h \
damiano@3204
   103
	   labeled_int_list.h key_reset.h base64.h sync_codec.h \
damiano@3204
   104
	   ../asn.1/*.h $(PREFIX)/include/pEp/
vb@1
   105
damiano@1958
   106
.PHONY: uninstall
vb@1
   107
uninstall:
vb@1
   108
	rm -f $(PREFIX)/lib/$(TARGET)
damiano@1958
   109
	rm -rf $(PREFIX)/include/pEp
vb@2871
   110
vb@2871
   111
.PHONY: tags
vb@2871
   112
tags:
vb@2871
   113
	ctags *.c *.h
vb@2871
   114