src/Makefile
author Edouard Tisserant <edouard@pep-project.org>
Thu, 16 Mar 2017 22:08:12 +0100
changeset 1676 4184ee019f65
parent 1664 9263048febb8
child 1684 20643edc4c53
child 1789 c4d32b6525c7
permissions -rw-r--r--
Refactored GPGME/NetPGP config in src/Makefile
vb@1
     1
include ../Makefile.conf
vb@1
     2
edouard@1676
     3
ETPAN_IN?=$(HOME)
Edouard@168
     4
vb@1
     5
ifeq ($(BUILD_ON),Darwin)
vb@1
     6
ifeq ($(BUILD_FOR),Darwin)
vb@1
     7
vb@1089
     8
TARGET?=libpEpEngine.dylib
vb@1
     9
MACOSX_VERSION_MIN=10.6
vb@1425
    10
LIBGPGME?=libgpgme.dylib
vb@66
    11
CC?=clang -std=c99 -pthread
vb@66
    12
LD?=clang
edouard@1676
    13
CFLAGS?= -I$(ETPAN_IN)/include -I/opt/local/include $(OPTIMIZE) -pedantic \
edouard@1676
    14
	-DSYSTEM_DB=\"$(SYSTEM_DB)\" -I../asn.1 $(EXTRAMACROS)
edouard@1676
    15
LDFLAGS?= -lc -shared -arch x86_64 \
edouard@1676
    16
	-L$(ETPAN_IN)/lib -L/usr/lib -L/opt/local/lib -letpan -lsqlite3 -L../asn.1 -lasn1 -lz -liconv
vb@1
    17
vb@1
    18
else
vb@1
    19
$(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
vb@1
    20
endif
vb@1
    21
vb@1
    22
else ifeq ($(BUILD_ON),Linux)
vb@1
    23
ifeq ($(BUILD_FOR),Linux)
vb@1
    24
vb@1
    25
TARGET=libpEpEngine.so
edouard@1676
    26
LIBGPGME?=libgpgme.so.11
Edouard@188
    27
CC=gcc -std=c99
edouard@1676
    28
CFLAGS?= $(OPTIMIZE) -fPIC -pedantic -DSYSTEM_DB=\"$(SYSTEM_DB)\" \
edouard@1676
    29
	-DSQLITE_THREADSAFE=1 -D_GNU_SOURCE -I../asn.1 $(EXTRAMACROS)
edouard@1676
    30
LDFLAGS?= -L$(ETPAN_IN)/lib -shared -lc -ldl -letpan -lpthread -L../asn.1 -lasn1 -luuid
vb@1
    31
vb@1
    32
else
vb@1
    33
$(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
vb@1
    34
endif
vb@1
    35
vb@1
    36
else
vb@1
    37
$(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
vb@1
    38
endif
vb@1
    39
edouard@1676
    40
DEBUG?=NO
edouard@1676
    41
ifeq ("$(DEBUG)","NO")
edouard@1676
    42
    CFLAGS+= -DNDEBUG
edouard@1676
    43
endif
edouard@1676
    44
edouard@1676
    45
OPENPGP?=GPG
Edouard@168
    46
ifeq ("$(OPENPGP)","GPG")
edouard@1676
    47
    NO_SOURCE=pgp_netpgp.c
edouard@1676
    48
    GPGME_IN?=$(HOME)
edouard@1676
    49
    CFLAGS+= -DUSE_GPG -I$(GPGME_IN)/include -DLIBGPGME=\"$(LIBGPGME)\"
edouard@1676
    50
    #LDFLAGS+= -L$(GPGME_IN)/lib -lgpgme
Edouard@168
    51
else ifeq ("$(OPENPGP)","NETPGP")
edouard@1676
    52
    NO_SOURCE=pgp_gpg.c
edouard@1676
    53
    NETPGP_IN?=$(HOME)
edouard@1676
    54
    CFLAGS+= -DUSE_NETPGP -I$(NETPGP_IN)/include
edouard@1676
    55
    LDFLAGS+= -L$(NETPGP_IN)/lib -lnetpgp -lcurl
Edouard@168
    56
else
Edouard@168
    57
	$(error Unknown OpenPGP library : $(OPENPGP))
Edouard@168
    58
endif
Edouard@168
    59
vb@609
    60
ALL_SOURCE=$(subst $(NO_SOURCE),,$(wildcard *.c))
vb@609
    61
vb@1
    62
DEPENDS=$(subst .c,.d,$(ALL_SOURCE))
vb@1
    63
ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE))
vb@1
    64
vb@1
    65
all: $(TARGET)
vb@1
    66
vb@811
    67
include Makefile.protocols
vb@606
    68
vb@1
    69
%.d: %.c
vb@1
    70
	@set -e; rm -f $@; \
vb@3
    71
	$(CC) -MM $(CPPFLAGS) $(CFLAGS) $< > $@.$$$$; \
vb@1
    72
	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
vb@1
    73
	rm -f $@.$$$$
vb@1
    74
vb@1
    75
-include $(DEPENDS)
vb@1
    76
vb@46
    77
#platform_windows.o: platform_windows.cpp
vb@46
    78
#	$(CXX) $(CXX_FLAGS) -o $@ -c $<
vb@1
    79
vb@1
    80
$(TARGET): libpEpEngine.a
vb@1
    81
	$(LD) $(ALL_OBJECTS) $(LDFLAGS) -o $@
vb@1
    82
vb@1
    83
objects: $(ALL_OBJECTS)
vb@1
    84
vb@1
    85
libpEpEngine.a: $(ALL_OBJECTS)
vb@1
    86
	ar -r $@ $(ALL_OBJECTS)
vb@1
    87
vb@1
    88
.PHONY: clean
vb@1
    89
vb@1
    90
clean:
vb@1
    91
	rm -f *.d *.o *.a $(TARGET) *.dll *.so *.zip *.d.* *.def *~
vb@1
    92
vb@1
    93
install: $(TARGET)
vb@1
    94
	cp $< $(PREFIX)/lib/
vb@171
    95
	mkdir -p $(PREFIX)/include/pEp
vb@1360
    96
	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 blacklist.h openpgp_compat.h $(PREFIX)/include/pEp/
vb@1
    97
vb@1
    98
uninstall:
vb@1
    99
	rm -f $(PREFIX)/lib/$(TARGET)
vb@1
   100