src/Makefile
author Damiano Boppart <damiano@pep-security.net>
Mon, 14 Aug 2017 02:26:09 +0200
branchENGINE-228
changeset 1958 433df9ee336d
parent 1955 8ec0b81a659f
child 1959 fe4d994a1105
permissions -rw-r--r--
More Makefile cleanup
damiano@1958
     1
# Copyright 2017, pEp Security SA
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@1958
    18
        $(error 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@1958
    26
        $(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
damiano@1958
    27
    endif
vb@1
    28
else
damiano@1958
    29
    $(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
vb@1
    30
endif
vb@1
    31
vb@1
    32
damiano@1958
    33
ifeq ($(OPENPGP),GPG)
damiano@1958
    34
    NO_SOURCE=pgp_netpgp.c
damiano@1958
    35
    CFLAGS+= -DUSE_GPG $(GPGME_INC) -DLIBGPGME=\"$(LIBGPGME)\"
damiano@1958
    36
    # FIXME Why was -lgpgme commented out?
damiano@1958
    37
    LDFLAGS+= $(GPGME_LIB)
damiano@1958
    38
else ifeq ($(OPENPGP),NETPGP)
damiano@1958
    39
    NO_SOURCE=pgp_gpg.c
damiano@1958
    40
    CFLAGS+= -DUSE_NETPGP $(NETGPG_INC)
damiano@1958
    41
    LDFLAGS+= $(NETGPG_LIB)
damiano@1958
    42
    LDLIBS+= -lnetpgp -lcurl
vb@1
    43
else
damiano@1958
    44
    $(error Unknown OpenPGP library: $(OPENPGP))
Edouard@168
    45
endif
Edouard@168
    46
vb@609
    47
ALL_SOURCE=$(subst $(NO_SOURCE),,$(wildcard *.c))
vb@1
    48
DEPENDS=$(subst .c,.d,$(ALL_SOURCE))
vb@1
    49
ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE))
vb@1
    50
damiano@1958
    51
.PHONY: all
vb@1
    52
all: $(TARGET)
vb@1
    53
damiano@1958
    54
# FIXME What is this?
vb@811
    55
include Makefile.protocols
vb@606
    56
vb@1
    57
%.d: %.c
vb@1
    58
	@set -e; rm -f $@; \
vb@3
    59
	$(CC) -MM $(CPPFLAGS) $(CFLAGS) $< > $@.$$$$; \
vb@1
    60
	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
vb@1
    61
	rm -f $@.$$$$
vb@1
    62
vb@1
    63
-include $(DEPENDS)
vb@1
    64
damiano@1958
    65
$(TARGET): libpEpEngine.a
damiano@1958
    66
	$(LD) $(ALL_OBJECTS) $(LDFLAGS) $(LDLIBS) -o $@
vb@1
    67
damiano@1958
    68
.PHONY: object
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)
vb@1
    80
	cp $< $(PREFIX)/lib/
vb@171
    81
	mkdir -p $(PREFIX)/include/pEp
edouard@1789
    82
	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
    83
damiano@1958
    84
.PHONY: uninstall
vb@1
    85
uninstall:
vb@1
    86
	rm -f $(PREFIX)/lib/$(TARGET)
damiano@1958
    87
	rm -rf $(PREFIX)/include/pEp
vb@1
    88