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