-
Notifications
You must be signed in to change notification settings - Fork 14
/
zlib.mk
52 lines (48 loc) · 1.63 KB
/
zlib.mk
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
EXTERNDIR = $(abs_top_builddir)/extern
ZLIBVER = 1.2.11
ZLIBBUILDROOT = $(EXTERNDIR)/zlib-src
ZLIBSOURCEDIR = $(ZLIBBUILDROOT)/zlib-$(ZLIBVER)
ZLIBGZFILE = zlib-$(ZLIBVER).tar.gz
ZLIBURL = http://zlib.net/$(ZLIBGZFILE)
ZLIBCFLAGS = -O3 -mcmodel=kernel -fno-pic -fno-pie \
-mno-red-zone -msse -msse2 -fno-exceptions \
-fno-common -fno-stack-protector -fbuiltin \
-fno-asynchronous-unwind-tables -ffreestanding
EXTERNINCLUDEDIR = $(EXTERNDIR)/include
ZLIBINCLUDEDIR = $(EXTERNINCLUDEDIR)/zlib
ZLIBHEADERS = zlib.h zconf.h
ZLIBHEADERSOURCES = $(ZLIBSOURCEDIR)/zlib.h $(ZLIBSOURCEDIR)/zconf.h
ZLIBPUBLICINCLUDES = $(ZLIBINCLUDEDIR)/zlib.h $(ZLIBINCLUDEDIR)/zconf.h
ZLIBCONFIGURE = $(ZLIBSOURCEDIR)/configure
ZLIBBUILDDIR = $(EXTERNDIR)/zlib-src/build
ZLIBLIBNAME = libz.a
ZLIBSTATICLIB = $(ZLIBBUILDDIR)/$(ZLIBLIBNAME)
ZLIBCONFIGUREFLAGS = --64 --static
ZLIBMAKEFILE = $(ZLIBBUILDDIR)/Makefile
ZLIBMAKE = $(MAKE)
# Make zlib
$(ZLIBSTATICLIB) $(ZLIBPUBLICINCLUDES) $(ZLIBHEADERSOURCES):
echo top build dir $(abs_top_builddir)
echo Downloading zlib
mkdir -p $(ZLIBBUILDROOT)
curl -o $(ZLIBBUILDROOT)/zlib.tar.gz $(ZLIBURL)
echo Extracting zlib
(cd $(ZLIBBUILDROOT) && tar -xzvf zlib.tar.gz)
echo Building zlib
mkdir -p $(@D)
mkdir -p $(ZLIBINCLUDEDIR)
+( \
( \
cd $(@D) && \
echo Configuring zlib && \
CFLAGS="$(ZLIBCFLAGS)" CXX=$(CXX) CC=$(CC) \
$(ZLIBBUILDROOT)/zlib-$(ZLIBVER)/configure \
$(ZLIBCONFIGUREFLAGS) && \
echo Invoking $(ZLIBMAKE) $(ZLIBLIBNAME) && \
$(ZLIBMAKE) $(ZLIBLIBNAME) \
) && \
mkdir -p $(ZLIBINCLUDEDIR) && \
for i in $(ZLIBHEADERS); do \
cp $(ZLIBSOURCEDIR)/$$i $(ZLIBINCLUDEDIR)/$$i;\
done \
)