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