src/Makefile
changeset 1989 d3e5bc4a9854
parent 1988 ea7bceda4dc8
child 1993 efaeadf3e6f0
     1.1 --- a/src/Makefile	Tue Aug 22 15:34:17 2017 +0200
     1.2 +++ b/src/Makefile	Tue Aug 22 15:57:25 2017 +0200
     1.3 @@ -1,55 +1,70 @@
     1.4 -# Copyright 2017, pEp Foundation
     1.5 -# This file is part of pEpEngine
     1.6 -# This file may be used under the terms of the GNU General Public License version 3
     1.7 -# see LICENSE.txt
     1.8 -
     1.9  include ../Makefile.conf
    1.10  
    1.11 -CFLAGS+= $(ETPAN_INC) -I../asn.1 -DSYSTEM_DB=\"$(SYSTEM_DB)\" $(EXTRA_MACROS)
    1.12 -LDFLAGS+= $(ETPAN_LIB) -L../asn.1 -shared
    1.13 -LDLIBS+= -lc -lasn1 -letpan 
    1.14 +ETPAN_IN?=$(HOME)
    1.15  
    1.16  ifeq ($(BUILD_ON),Darwin)
    1.17 -    ifeq ($(BUILD_FOR),Darwin)
    1.18 -        CFLAGS+= -DSQLITE_THREADSAFE=1
    1.19 -        #LDFLAGS+= -L/opt/local/lib
    1.20 -        LDLIBS+= -lsqlite3 -lz -liconv
    1.21 -    else
    1.22 -        $(error I don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
    1.23 -    endif
    1.24 -else ifeq ($(BUILD_ON),Linux)
    1.25 -    ifeq ($(BUILD_FOR),Linux)
    1.26 -        CFLAGS+= -DSQLITE_THREADSAFE=1 -D_GNU_SOURCE
    1.27 -        LDLIBS+= -ldl -luuid
    1.28 -    else
    1.29 -        $(error I don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
    1.30 -    endif
    1.31 +ifeq ($(BUILD_FOR),Darwin)
    1.32 +
    1.33 +TARGET?=libpEpEngine.dylib
    1.34 +MACOSX_VERSION_MIN=10.6
    1.35 +LIBGPGME?=libgpgme.dylib
    1.36 +CC?=clang -std=c99 -pthread
    1.37 +LD?=clang
    1.38 +CFLAGS?= -I$(ETPAN_IN)/include -I/opt/local/include $(OPTIMIZE) -pedantic \
    1.39 +	-DSYSTEM_DB=\"$(SYSTEM_DB)\" -I../asn.1 $(EXTRAMACROS)
    1.40 +LDFLAGS?= -lc -shared -arch x86_64 \
    1.41 +	-L$(ETPAN_IN)/lib -L/usr/lib -L/opt/local/lib -letpan -lsqlite3 -L../asn.1 -lasn1 -lz -liconv
    1.42 +
    1.43  else
    1.44 -    $(error I don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
    1.45 +$(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
    1.46  endif
    1.47  
    1.48 -ifeq ($(OPENPGP),GPG)
    1.49 +else ifeq ($(BUILD_ON),Linux)
    1.50 +ifeq ($(BUILD_FOR),Linux)
    1.51 +
    1.52 +TARGET=libpEpEngine.so
    1.53 +LIBGPGME?=libgpgme.so.11
    1.54 +CC=gcc -std=c99
    1.55 +CFLAGS?= -I$(ETPAN_IN)/include $(OPTIMIZE) -fPIC -pedantic -DSYSTEM_DB=\"$(SYSTEM_DB)\" \
    1.56 +	-DSQLITE_THREADSAFE=1 -D_GNU_SOURCE -I../asn.1 $(EXTRAMACROS)
    1.57 +LDFLAGS?= -L$(ETPAN_IN)/lib -shared -lc -ldl -letpan -lpthread -L../asn.1 -lasn1 -luuid
    1.58 +
    1.59 +else
    1.60 +$(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
    1.61 +endif
    1.62 +
    1.63 +else
    1.64 +$(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
    1.65 +endif
    1.66 +
    1.67 +DEBUG?=NO
    1.68 +ifeq ("$(DEBUG)","NO")
    1.69 +    CFLAGS+= -DNDEBUG
    1.70 +endif
    1.71 +
    1.72 +OPENPGP?=GPG
    1.73 +ifeq ("$(OPENPGP)","GPG")
    1.74      NO_SOURCE=pgp_netpgp.c
    1.75 -    CFLAGS+= -DUSE_GPG $(GPGME_INC) -DLIBGPGME=\"$(LIBGPGME)\"
    1.76 -    LDFLAGS+= $(GPGME_LIB)
    1.77 -    # No extra LDLIBS are needed here, because GPGME is dynamically loaded
    1.78 -else ifeq ($(OPENPGP),NETPGP)
    1.79 +    GPGME_IN?=$(HOME)
    1.80 +    CFLAGS+= -DUSE_GPG -I$(GPGME_IN)/include -DLIBGPGME=\"$(LIBGPGME)\"
    1.81 +    #LDFLAGS+= -L$(GPGME_IN)/lib -lgpgme
    1.82 +else ifeq ("$(OPENPGP)","NETPGP")
    1.83      NO_SOURCE=pgp_gpg.c
    1.84 -    CFLAGS+= -DUSE_NETPGP $(NETGPG_INC)
    1.85 -    LDFLAGS+= $(NETGPG_LIB)
    1.86 -    LDLIBS+= -lnetpgp -lcurl
    1.87 +    NETPGP_IN?=$(HOME)
    1.88 +    CFLAGS+= -DUSE_NETPGP -I$(NETPGP_IN)/include
    1.89 +    LDFLAGS+= -L$(NETPGP_IN)/lib -lnetpgp -lcurl
    1.90  else
    1.91 -    $(error Unknown OpenPGP library: $(OPENPGP))
    1.92 +	$(error Unknown OpenPGP library : $(OPENPGP))
    1.93  endif
    1.94  
    1.95  ALL_SOURCE=$(subst $(NO_SOURCE),,$(wildcard *.c))
    1.96 +
    1.97  DEPENDS=$(subst .c,.d,$(ALL_SOURCE))
    1.98  ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE))
    1.99  
   1.100 -.PHONY: all
   1.101  all: $(TARGET)
   1.102  
   1.103 --include Makefile.protocols
   1.104 +include Makefile.protocols
   1.105  
   1.106  %.d: %.c
   1.107  	@set -e; rm -f $@; \
   1.108 @@ -57,32 +72,29 @@
   1.109  	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
   1.110  	rm -f $@.$$$$
   1.111  
   1.112 -# If only the goal 'clean' is given, do not generate and include the '%.d' files.
   1.113 -ifneq ($(MAKECMDGOALS),clean)
   1.114 -    -include $(DEPENDS)
   1.115 -endif
   1.116 +-include $(DEPENDS)
   1.117 +
   1.118 +#platform_windows.o: platform_windows.cpp
   1.119 +#	$(CXX) $(CXX_FLAGS) -o $@ -c $<
   1.120  
   1.121  $(TARGET): libpEpEngine.a
   1.122 -	$(CC) $(ALL_OBJECTS) $(LDFLAGS) $(LDLIBS) -o $@
   1.123 +	$(LD) $(ALL_OBJECTS) $(LDFLAGS) -o $@
   1.124  
   1.125 -.PHONY: objects
   1.126  objects: $(ALL_OBJECTS)
   1.127  
   1.128  libpEpEngine.a: $(ALL_OBJECTS)
   1.129 -	ar -rc $@ $^
   1.130 +	ar -r $@ $(ALL_OBJECTS)
   1.131  
   1.132  .PHONY: clean
   1.133 +
   1.134  clean:
   1.135  	rm -f *.d *.o *.a $(TARGET) *.dll *.so *.zip *.d.* *.def *~
   1.136  
   1.137 -.PHONY: install
   1.138  install: $(TARGET)
   1.139 -	mkdir -p "$(PREFIX)/lib/"
   1.140  	cp $< $(PREFIX)/lib/
   1.141  	mkdir -p $(PREFIX)/include/pEp
   1.142  	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/
   1.143  
   1.144 -.PHONY: uninstall
   1.145  uninstall:
   1.146  	rm -f $(PREFIX)/lib/$(TARGET)
   1.147 -	rm -rf $(PREFIX)/include/pEp
   1.148 +