src/Makefile
author vb
Thu, 26 Jun 2014 18:24:56 +0200
changeset 3 bd4014e15899
parent 1 06e02338bdd8
child 38 271bea5552dc
permissions -rw-r--r--
fixing bug with Makefile
     1 include ../Makefile.conf
     2 
     3 ifeq ($(BUILD_ON),Darwin)
     4 ifeq ($(BUILD_FOR),Darwin)
     5 
     6 TARGET=libpEpEngine.dylib
     7 MACOSX_VERSION_MIN=10.6
     8 GPGME_IN=$(HOME)
     9 LIBGPGME=libgpgme-pthread.dylib
    10 CC=gcc -std=c99
    11 CFLAGS=-I$(GPGME_IN)/include -I/opt/local/include $(OPTIMIZE) -pedantic \
    12 	-DSYSTEM_DB=\"$(SYSTEM_DB)\" -DLIBGPGME=\"$(LIBGPGME)\"  -DSQLITE_THREADSAFE=1
    13 LDFLAGS=-lc -macosx_version_min $(MACOSX_VERSION_MIN) -dylib -arch x86_64
    14 
    15 else ifeq ($(BUILD_FOR),Windoze)
    16 
    17 TARGET=pEpEngine.dll
    18 GPGME_IN=$(HOME)
    19 LIBGPGME=libgpgme-11.dll
    20 CC=i686-w64-mingw32-gcc -std=c99
    21 CXX=i686-w64-mingw32-g++
    22 LD=i686-w64-mingw32-gcc
    23 CFLAGS=-I$(HOME)/i686-w64-mingw32/include -I$(GPGME_IN)/include $(OPTIMIZE) -pedantic \
    24 	-DLIBGPGME=\"$(LIBGPGME)\" -DWIN32 -DSQLITE_THREADSAFE=1
    25 LDFLAGS=-shared -L$(HOME)/i686-w64-mingw32/lib -llibstdc++ \
    26 	-Wl,--output-def,pEpEngine.def,--out-implib,libpEpEngine.a
    27 
    28 else
    29 $(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
    30 endif
    31 
    32 else ifeq ($(BUILD_ON),Linux)
    33 ifeq ($(BUILD_FOR),Linux)
    34 
    35 TARGET=libpEpEngine.so
    36 GPGME_IN=$(HOME)
    37 LIBGPGME=libgpgme.so.11
    38 CC=gcc -std=c99
    39 CFLAGS=-I$(GPGME_IN)/include $(OPTIMIZE) -fPIC -pedantic \
    40 	-DSYSTEM_DB=\"$(SYSTEM_DB)\" -DLIBGPGME=\"$(LIBGPGME)\" -DSQLITE_THREADSAFE=1
    41 LDFLAGS=-L$(GPGME_IN) -shared -lc -ldl
    42 
    43 else ifeq ($(BUILD_FOR),Windoze)
    44 
    45 TARGET=pEpEngine.dll
    46 GPGME_IN=$(HOME)
    47 LIBGPGME=libgpgme-11.dll
    48 CC=i686-w64-mingw32-gcc -std=c99
    49 CXX=i686-w64-mingw32-g++
    50 LD=i686-w64-mingw32-gcc
    51 CFLAGS=-I/usr/i686-w64-mingw32/include -I$(GPGME_IN)/include $(OPTIMIZE) -pedantic \
    52 	-DLIBGPGME=\"$(LIBGPGME)\" -DWIN32 -DSQLITE_THREADSAFE=1
    53 LDFLAGS=-shared -L/usr/i686-w64-mingw32/lib -llibstdc++ \
    54 	-Wl,--output-def,pEpEngine.def,--out-implib,libpEpEngine.a
    55 
    56 else
    57 $(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
    58 endif
    59 
    60 else ifeq ($(BUILD_ON),MINGW32_NT-6.1)
    61 
    62 TARGET=pEpEngine.dll
    63 GPGME_IN=/c/Program\ Files/GNU/GnuPG
    64 LIBGPGME=libgpgme-11.dll
    65 CC=gcc -std=gnu99
    66 CFLAGS=-I$(GPGME_IN)/include $(OPTIMIZE) -pedantic -DWIN32 -DSQLITE_THREADSAFE=1
    67 LD=gcc
    68 LDFLAGS=-shared -llibstdc++ -Wl,--output-def,pEpEngine.def,--out-implib,libpEpEngine.a
    69 
    70 else
    71 $(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
    72 endif
    73 
    74 ifeq ($(BUILD_FOR),Windoze)
    75 ALL_SOURCE=$(filter-out platform_unix.c,$(wildcard *.c))
    76 else ifeq ($(BUILD_FOR),MINGW32_NT-6.1)
    77 ALL_SOURCE=$(filter-out platform_unix.c,$(wildcard *.c))
    78 else
    79 ALL_SOURCE=$(wildcard *.c)
    80 endif
    81 
    82 DEPENDS=$(subst .c,.d,$(ALL_SOURCE))
    83 
    84 ifeq ($(BUILD_FOR),Windoze)
    85 ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE)) platform_windows.o
    86 else ifeq ($(BUILD_FOR),MINGW32_NT-6.1)
    87 ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE)) platform_windows.o
    88 else
    89 ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE))
    90 endif
    91 
    92 all: $(TARGET)
    93 
    94 %.d: %.c
    95 	@set -e; rm -f $@; \
    96 	$(CC) -MM $(CPPFLAGS) $(CFLAGS) $< > $@.$$$$; \
    97 	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
    98 	rm -f $@.$$$$
    99 
   100 -include $(DEPENDS)
   101 
   102 platform_windows.o: platform_windows.cpp
   103 	$(CXX) $(CXX_FLAGS) -o $@ -c $<
   104 
   105 $(TARGET): libpEpEngine.a
   106 	$(LD) $(ALL_OBJECTS) $(LDFLAGS) -o $@
   107 
   108 objects: $(ALL_OBJECTS)
   109 
   110 libpEpEngine.a: $(ALL_OBJECTS)
   111 	ar -r $@ $(ALL_OBJECTS)
   112 
   113 .PHONY: clean
   114 
   115 clean:
   116 	rm -f *.d *.o *.a $(TARGET) *.dll *.so *.zip *.d.* *.def *~
   117 
   118 install: $(TARGET)
   119 	cp $< $(PREFIX)/lib/
   120 
   121 uninstall:
   122 	rm -f $(PREFIX)/lib/$(TARGET)
   123