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