src/Makefile
author Volker Birk <vb@pep-project.org>
Mon, 16 May 2016 17:53:24 +0200
changeset 637 d93d1fe6a24c
parent 609 a22a400611ca
child 639 0a2411d3d55a
permissions -rw-r--r--
test and Make
     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)\"
    16 LDFLAGS?=-lc -shared -arch x86_64 \
    17 	-L$(HOME)/lib -L/opt/local/lib -letpan -lsqlite3 -L../asn.1 -lasn1
    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
    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-pthread 
    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 sync_fsm.c: ../sync/sync.fsm
    63 	make -C ../sync
    64 
    65 %.d: %.c
    66 	@set -e; rm -f $@; \
    67 	$(CC) -MM $(CPPFLAGS) $(CFLAGS) $< > $@.$$$$; \
    68 	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
    69 	rm -f $@.$$$$
    70 
    71 -include $(DEPENDS)
    72 
    73 #platform_windows.o: platform_windows.cpp
    74 #	$(CXX) $(CXX_FLAGS) -o $@ -c $<
    75 
    76 $(TARGET): libpEpEngine.a
    77 	$(LD) $(ALL_OBJECTS) $(LDFLAGS) -o $@
    78 
    79 objects: $(ALL_OBJECTS)
    80 
    81 libpEpEngine.a: $(ALL_OBJECTS)
    82 	ar -r $@ $(ALL_OBJECTS)
    83 
    84 .PHONY: clean
    85 
    86 clean:
    87 	rm -f *.d *.o *.a $(TARGET) *.dll *.so *.zip *.d.* *.def *~
    88 
    89 install: $(TARGET)
    90 	cp $< $(PREFIX)/lib/
    91 	mkdir -p $(PREFIX)/include/pEp
    92 	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 $(PREFIX)/include/pEp/
    93 
    94 uninstall:
    95 	rm -f $(PREFIX)/lib/$(TARGET)
    96