src/Makefile
author Damiano Boppart <damiano@pep-security.net>
Wed, 16 Aug 2017 15:27:54 +0000
branchENGINE-228
changeset 1966 0329556f28ab
parent 1962 b88394894238
child 1968 e30b1515b7b9
permissions -rw-r--r--
Remove the CPP warnings for asn1c generated code. Do not generate .d files when the goal is clean.
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
    # FIXME Why was -lgpgme commented out?
damiano@1958
    36
    LDFLAGS+= $(GPGME_LIB)
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@1966
    61
# If only the goal 'clean' is given, do not include the generated 'X.d' files.
damiano@1966
    62
ifneq ($(MAKECMDGOALS),clean)
damiano@1966
    63
    -include $(DEPENDS)
damiano@1966
    64
endif
damiano@1966
    65
damiano@1966
    66
vb@1
    67
damiano@1958
    68
$(TARGET): libpEpEngine.a
damiano@1959
    69
	$(CC) $(ALL_OBJECTS) $(LDFLAGS) $(LDLIBS) -o $@
vb@1
    70
damiano@1959
    71
.PHONY: objects
vb@1
    72
objects: $(ALL_OBJECTS)
vb@1
    73
vb@1
    74
libpEpEngine.a: $(ALL_OBJECTS)
damiano@1958
    75
	ar -rc $@ $^
vb@1
    76
vb@1
    77
.PHONY: clean
vb@1
    78
clean:
vb@1
    79
	rm -f *.d *.o *.a $(TARGET) *.dll *.so *.zip *.d.* *.def *~
vb@1
    80
damiano@1958
    81
.PHONY: install
vb@1
    82
install: $(TARGET)
vb@1
    83
	cp $< $(PREFIX)/lib/
vb@171
    84
	mkdir -p $(PREFIX)/include/pEp
edouard@1789
    85
	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
    86
damiano@1958
    87
.PHONY: uninstall
vb@1
    88
uninstall:
vb@1
    89
	rm -f $(PREFIX)/lib/$(TARGET)
damiano@1958
    90
	rm -rf $(PREFIX)/include/pEp