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