forked from ctabin/libzippp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
112 lines (83 loc) · 3.51 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
CFLAGS=-W -Wall -Wextra -ansi -pedantic -std=c++0x
OBJ=obj
LIB=lib
ZLIB_VERSION=1.2.11
ZLIB=$(LIB)/zlib-$(ZLIB_VERSION)
LIBZIP_VERSION=1.5.2
LIBZIP=$(LIB)/libzip-$(LIBZIP_VERSION)
LIBZIP_CMAKE=-DENABLE_COMMONCRYPTO=OFF -DENABLE_GNUTLS=OFF -DENABLE_MBEDTLS=OFF
CRYPTO_FLAGS=-lssl -lcrypto
# for optimal compilation speed, should be <nb_proc>+1
NBPROC=5
all: libzippp-static libzippp-shared
libzippp-compile:
rm -rf $(OBJ)
mkdir $(OBJ)
$(CXX) -g -fPIC -c -I$(LIBZIP)/lib -I$(LIBZIP)/build -o $(OBJ)/libzippp.o $(CFLAGS) src/libzippp.cpp
libzippp-static: libzippp-compile
ar rvs libzippp.a $(OBJ)/libzippp.o
libzippp-shared: libzippp-compile
$(CXX) -shared -o libzippp.so $(OBJ)/libzippp.o
libzippp-tests: libzippp-static libzippp-shared
if [ -d $(ZLIB) ]; then \
$(CXX) -o test_static -I$(ZLIB) -I$(LIBZIP)/lib -Isrc $(CFLAGS) tests/tests.cpp libzippp.a $(LIBZIP)/build/lib/libzip.a $(ZLIB)/libz.a -lbz2 $(CRYPTO_FLAGS); \
$(CXX) -o test_shared -I$(ZLIB) -I$(LIBZIP)/lib -Isrc $(CFLAGS) tests/tests.cpp -L. -L$(LIBZIP)/build/lib -L$(ZLIB) -lzippp -lzip -lz -lbz2 $(CRYPTO_FLAGS) -Wl,-rpath=.; \
else \
$(CXX) -o test_static -I$(LIBZIP)/lib -Isrc $(CFLAGS) tests/tests.cpp libzippp.a $(LIBZIP)/build/lib/libzip.a -lz -lbz2 $(CRYPTO_FLAGS); \
$(CXX) -o test_shared -I$(LIBZIP)/lib -Isrc $(CFLAGS) tests/tests.cpp -L. -L$(LIBZIP)/build/lib -lzippp -lzip -lz -lbz2 $(CRYPTO_FLAGS) -Wl,-rpath=.; \
fi;
clean-tests:
@rm -rf *.zip
tests: libzippp-tests clean-tests
LD_LIBRARY_PATH="$(LIBZIP)/build/lib" valgrind --suppressions=ld.supp ./test_shared
valgrind --suppressions=ld.supp ./test_static
clean:
@rm -rf libzippp.a libzippp.so
@rm -rf $(OBJ)
@rm -rf test_shared test_static
mrproper: clean
@rm -rf $(LIBZIP)
@rm -rf $(LIB)/libzip-$(LIBZIP_VERSION)
@rm -rf $(LIB)/zlib-$(ZLIB_VERSION)
@rm -rf $(LIB)/*.tar.gz
# ZLIB targets
zlib-init:
mkdir -p $(LIB)
zlib-download: zlib-init
wget -c -O "$(ZLIB).tar.gz" "http://zlib.net/zlib-$(ZLIB_VERSION).tar.gz"
zlib-unzip: zlib-download
cd $(LIB) && tar -xf zlib-$(ZLIB_VERSION).tar.gz
zlib-configure: zlib-unzip
cd $(ZLIB) && ./configure
zlib-compile: zlib-configure
cd $(ZLIB) && make -j$(NBPROC)
zlib: zlib-compile
# LIZIP targets
libzip-init:
mkdir -p $(LIB)
libzip-download: libzip-init
wget -c -O "$(LIBZIP).tar.gz" "http://www.nih.at/libzip/libzip-$(LIBZIP_VERSION).tar.gz"
libzip-unzip: libzip-download
cd $(LIB) && tar -xf libzip-$(LIBZIP_VERSION).tar.gz
libzip-patch: libzip-unzip
if [ -f $(LIB)/libzip-$(LIBZIP_VERSION)-linux.patch ]; then \
cd $(LIB)/libzip-$(LIBZIP_VERSION) && patch -p1 < ../libzip-$(LIBZIP_VERSION)-linux.patch; \
fi;
libzip-build-folder:
mkdir -p $(LIBZIP)/build;
libzip-build-shared: libzip-patch libzip-build-folder
if [ -d "$(ZLIB)" ]; then \
cd $(LIBZIP)/build && cmake .. -DZLIB_LIBRARY_RELEASE=../../../$(ZLIB)/libz.so -DZLIB_INCLUDE_DIR=../../../$(ZLIB) -DBUILD_SHARED_LIBS=ON $(LIBZIP_CMAKE) && make -j$(NBPROC); \
else \
cd $(LIBZIP)/build && cmake .. -DBUILD_SHARED_LIBS=ON $(LIBZIP_CMAKE) && make -j$(NBPROC); \
fi;
libzip-build-static: libzip-patch libzip-build-folder
if [ -d "$(ZLIB)" ]; then \
cd $(LIBZIP)/build && cmake .. -DZLIB_LIBRARY_RELEASE=../../../$(ZLIB)/libz.a -DZLIB_INCLUDE_DIR=../../../$(ZLIB) -DBUILD_SHARED_LIBS=OFF $(LIBZIP_CMAKE) && make -j$(NBPROC); \
else \
cd $(LIBZIP)/build && cmake .. -DBUILD_SHARED_LIBS=OFF $(LIBZIP_CMAKE) && make -j$(NBPROC); \
fi;
libzip: libzip-build-shared libzip-build-static
# LIBRARIES TARGET
libraries: zlib libzip
libraries-download: zlib-download libzip-download