summaryrefslogtreecommitdiff
path: root/cross.mk
blob: 95f20a39aebe15f7f9c8ca3b000f799b40e2851e (plain)
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
SMP=-j4

GNUTLS_VERSION:=3.3.12
GNUTLS_FILE:=gnutls-$(GNUTLS_VERSION).tar.xz
GNUTLS_DIR:=gnutls-$(GNUTLS_VERSION)

OPENCONNECT_VERSION:=6.00
OPENCONNECT_FILE:=openconnect-$(OPENCONNECT_VERSION).tar.gz
OPENCONNECT_DIR:=openconnect-$(OPENCONNECT_VERSION)

GMP_VERSION=6.0.0
GMP_VERSIONA=6.0.0a
GMP_FILE:=gmp-$(GMP_VERSIONA).tar.bz2
GMP_SERV_DIR:=gmp-$(GMP_VERSIONA)
GMP_DIR:=gmp-$(GMP_VERSION)

XML2_VERSION=2.9.1
XML2_FILE:=libxml2-$(XML2_VERSION).tar.gz
XML2_DIR:=libxml2-$(XML2_VERSION)

LIBZ_VERSION=1.2.8
LIBZ_FILE:=zlib-$(LIBZ_VERSION).tar.gz
LIBZ_DIR:=zlib-$(LIBZ_VERSION)

P11_KIT_VERSION=0.20.7
P11_KIT_FILE:=p11-kit-$(P11_KIT_VERSION).tar.gz
P11_KIT_DIR:=p11-kit-$(P11_KIT_VERSION)

NETTLE_VERSION=2.7.1
NETTLE_FILE:=nettle-$(NETTLE_VERSION).tar.gz
NETTLE_DIR:=nettle-$(NETTLE_VERSION)

PKG_CONFIG_DIR:=$(PWD)/win32/lib/pkgconfig/
CROSS_DIR:=$(PWD)/win32
BIN_DIR:=$(CROSS_DIR)/bin
LIB_DIR:=$(CROSS_DIR)/lib
HEADERS_DIR:=$(CROSS_DIR)/include
DEVCPP_DIR:=$(PWD)/devcpp
LDFLAGS=
#doesn't seem to work
#LDFLAGS=-static-libgcc

all: update-gpg-keys gnutls-w32

upload: gnutls-w32 devpak
	../build-aux/gnupload --to ftp.gnu.org:gnutls/w32 $(GNUTLS_DIR)-w32.zip
	../build-aux/gnupload --to ftp.gnu.org:gnutls/w32 gnutls-$(GNUTLS_VERSION)-1gn.DevPak

update-gpg-keys:
	gpg --recv-keys 96865171 B565716F D92765AF A8F4C2FD DB899F46

$(GNUTLS_DIR)-w32.zip: $(LIB_DIR) $(BIN_DIR) $(GNUTLS_DIR)/.installed
	rm -rf $(CROSS_DIR)/etc $(CROSS_DIR)/share $(CROSS_DIR)/lib/include
	cd $(CROSS_DIR) && zip -r $(PWD)/$@ *
	gpg --sign --detach $(GNUTLS_DIR)-w32.zip

gnutls-$(GNUTLS_VERSION)-1gn.DevPak: $(GNUTLS_DIR)-w32.zip devcpp.tar
	rm -rf $(DEVCPP_DIR)
	mkdir -p $(DEVCPP_DIR)
	cd $(DEVCPP_DIR) && unzip ../$(GNUTLS_DIR)-w32.zip 
	cd $(DEVCPP_DIR) && tar xf ../devcpp.tar && sed -i 's/@VERSION@/$(GNUTLS_VERSION)/g' gnutls.DevPackage
	cd $(DEVCPP_DIR) && tar -cjf ../$@ .

devpak: gnutls-$(GNUTLS_VERSION)-1gn.DevPak

gnutls-w32: $(GNUTLS_DIR)-w32.zip

openconnect-w32: $(OPENCONNECT_DIR)/.installed

nettle: $(NETTLE_DIR)/.installed

gmp: $(GMP_DIR)/.installed

$(BIN_DIR):
	mkdir -p $(BIN_DIR)

$(LIB_DIR):
	mkdir -p $(LIB_DIR)

CONFIG_ENV := PKG_CONFIG_PATH="$(PKG_CONFIG_DIR)"
CONFIG_ENV += PKG_CONFIG_LIBDIR="$(PKG_CONFIG_DIR)"
CONFIG_FLAGS1 := --prefix=$(CROSS_DIR) --enable-shared \
	--libdir=$(LIB_DIR) --includedir=$(HEADERS_DIR)
CONFIG_FLAGS := --host=i686-w64-mingw32 $(CONFIG_FLAGS1) --disable-static --bindir=$(BIN_DIR) --sbindir=$(BIN_DIR) \
	 --enable-threads=win32 

$(P11_KIT_DIR)/.configured:
	test -f $(P11_KIT_FILE) || wget http://p11-glue.freedesktop.org/releases/$(P11_KIT_FILE)
	test -f $(P11_KIT_FILE).sig || wget http://p11-glue.freedesktop.org/releases/$(P11_KIT_FILE).sig
	gpg --verify $(P11_KIT_FILE).sig
	test -d $(P11_KIT_DIR) || tar -xf $(P11_KIT_FILE)
	cd $(P11_KIT_DIR) && LDFLAGS="$(LDFLAGS)" $(CONFIG_ENV) ./configure $(CONFIG_FLAGS) --without-libffi --without-libtasn1 && cd ..
	touch $@

$(P11_KIT_DIR)/.installed: $(P11_KIT_DIR)/.configured
	make -C $(P11_KIT_DIR) $(SMP)
	make -C $(P11_KIT_DIR) install -i
	-rm -rf $(HEADERS_DIR)/p11-kit
	-mv $(HEADERS_DIR)/p11-kit-1/p11-kit $(HEADERS_DIR)
	-rm -rf $(HEADERS_DIR)/p11-kit-1
	rm -f $(BIN_DIR)/p11-kit.exe
	touch $@

$(GMP_DIR)/.configured: 
	test -f $(GMP_FILE) || wget ftp://ftp.gmplib.org/pub/$(GMP_DIR)/$(GMP_FILE)
	test -f $(GMP_FILE).sig || wget ftp://ftp.gmplib.org/pub/$(GMP_DIR)/$(GMP_FILE).sig
	gpg --verify $(GMP_FILE).sig
	test -d $(GMP_DIR) || tar -xf $(GMP_FILE)
	cd $(GMP_DIR) && LDFLAGS="$(LDFLAGS)" $(CONFIG_ENV) ./configure $(CONFIG_FLAGS) --enable-fat --exec-prefix=$(LIB_DIR)  --oldincludedir=$(HEADERS_DIR) && cd ..
	cp $(GMP_DIR)/COPYING.LESSERv3 $(CROSS_DIR)/COPYING.GMP
	touch $@

$(GMP_DIR)/.installed: $(GMP_DIR)/.configured
	make -C $(GMP_DIR) $(SMP)
	make -C $(GMP_DIR) install -i
	-mkdir -p $(HEADERS_DIR)
	mv $(LIB_DIR)/include/* $(HEADERS_DIR)/
	rmdir $(LIB_DIR)/include/
	touch $@

$(NETTLE_DIR)/.configured: $(GMP_DIR)/.installed
	test -f $(NETTLE_FILE) || wget http://www.lysator.liu.se/~nisse/archive/$(NETTLE_FILE)
	test -f $(NETTLE_FILE).sig || wget http://www.lysator.liu.se/~nisse/archive/$(NETTLE_FILE).sig
	gpg --verify $(NETTLE_FILE).sig
	test -d $(NETTLE_DIR) || tar -xf $(NETTLE_FILE)
	cd $(NETTLE_DIR) && CFLAGS="-I$(HEADERS_DIR)" CXXFLAGS="-I$(HEADERS_DIR)" LDFLAGS="$(LDFLAGS)" $(CONFIG_ENV) ./configure $(CONFIG_FLAGS) --with-lib-path=$(LIB_DIR) && cd ..
	touch $@

#nettle messes up installation
$(NETTLE_DIR)/.installed: $(NETTLE_DIR)/.configured
	make -C $(NETTLE_DIR) $(SMP) -i
	make -C $(NETTLE_DIR) install -i
	rm -f $(LIB_DIR)/libnettle.a $(LIB_DIR)/libhogweed.a $(BIN_DIR)/nettle-hash.exe $(BIN_DIR)/nettle-lfib-stream.exe $(BIN_DIR)/pkcs1-conv.exe $(BIN_DIR)/sexp-conv.exe
	cp $(NETTLE_DIR)/libnettle.dll.a $(NETTLE_DIR)/libhogweed.dll.a $(LIB_DIR)/
	cp $(NETTLE_DIR)/libnettle*.dll $(NETTLE_DIR)/libhogweed*.dll $(BIN_DIR)/
	touch $@

GCC_DLLS=/usr/lib/gcc/i686-w64-mingw32/4.9-win32/libgcc_s_sjlj-1.dll

$(GNUTLS_DIR)/.installed: $(GNUTLS_DIR)/.configured
	make -C $(GNUTLS_DIR) $(SMP)
	-cp $(GCC_DLLS) $(GNUTLS_DIR)/tests
	-cp $(GCC_DLLS) $(GNUTLS_DIR)/tests/safe-renegotiation
	-cp $(GCC_DLLS) $(GNUTLS_DIR)/tests/slow
	sed -i 's/^"$$@" >$$log_file/echo $$@|grep exe >\/dev\/null; if [ $$? == 0 ];then wine "$$@" >$$log_file;else \/bin\/true >$$log_file;fi/g' $(GNUTLS_DIR)/build-aux/test-driver
	make -C $(GNUTLS_DIR)/tests check $(SMP)
	make -C $(GNUTLS_DIR) install -i
	cp $(GNUTLS_DIR)/COPYING $(GNUTLS_DIR)/COPYING.LESSER $(CROSS_DIR)
	-cp $(GCC_DLLS) $(BIN_DIR)/
	touch $@

$(GNUTLS_DIR)/.configured: $(NETTLE_DIR)/.installed $(P11_KIT_DIR)/.installed
	test -f $(GNUTLS_FILE) || wget ftp://ftp.gnutls.org/gcrypt/gnutls/v3.3/$(GNUTLS_FILE)
	test -f $(GNUTLS_FILE).sig || wget ftp://ftp.gnutls.org/gcrypt/gnutls/v3.3/$(GNUTLS_FILE).sig
	gpg --verify $(GNUTLS_FILE).sig
	test -d $(GNUTLS_DIR) || tar -xf $(GNUTLS_FILE)
	cd $(GNUTLS_DIR) && \
		$(CONFIG_ENV) LDFLAGS="$(LDFLAGS) -L$(LIB_DIR)" CFLAGS="-I$(HEADERS_DIR)" CXXFLAGS="-I$(HEADERS_DIR)" \
		./configure $(CONFIG_FLAGS) --enable-local-libopts --disable-cxx \
		--without-zlib --disable-nls --enable-gcc-warnings --disable-libdane --disable-openssl-compatibility --with-included-libtasn1 && cd ..
	touch $@

$(OPENCONNECT_DIR)/.installed: $(OPENCONNECT_DIR)/.configured
	make -C $(OPENCONNECT_DIR) $(SMP)
	make -C $(OPENCONNECT_DIR) install -i
	touch $@

$(OPENCONNECT_DIR)/.configured: $(GNUTLS_DIR)/.installed $(XML2_DIR)/.installed
	test -f $(OPENCONNECT_FILE) || wget ftp://ftp.infradead.org/pub/openconnect/$(OPENCONNECT_FILE)
	test -f $(OPENCONNECT_FILE).sig || wget ftp://ftp.infradead.org/pub/openconnect/$(OPENCONNECT_FILE).asc
	gpg --verify $(OPENCONNECT_FILE).asc
	test -d $(OPENCONNECT_DIR) || tar -xf $(OPENCONNECT_FILE)
	cd $(OPENCONNECT_DIR) && \
		$(CONFIG_ENV) LDFLAGS="$(LDFLAGS) -L$(LIB_DIR)" CFLAGS="-I$(HEADERS_DIR)" CXXFLAGS="-I$(HEADERS_DIR)" \
		./configure $(CONFIG_FLAGS) && cd ..
	sed -i 's/-Werror-implicit-function-declaration//g' $(OPENCONNECT_DIR)/Makefile
	touch $@

$(XML2_DIR)/.configured: $(GMP_DIR)/.installed
	test -f $(XML2_FILE) || wget ftp://xmlsoft.org/libxml2/$(XML2_FILE)
	#test -f $(XML2_FILE).sig || wget ftp://xmlsoft.org/libxml2//$(XML2_FILE).sig
	#gpg --verify $(XML2_FILE).sig
	test -d $(XML2_DIR) || tar -xf $(XML2_FILE)
	cd $(XML2_DIR) && CFLAGS="-I$(HEADERS_DIR)" CXXFLAGS="-I$(HEADERS_DIR)" LDFLAGS="$(LDFLAGS)" $(CONFIG_ENV) ./configure $(CONFIG_FLAGS) --without-python --without-legacy --without-python --without-http --without-ftp --with-lib-path=$(LIB_DIR) && cd ..
	touch $@

$(XML2_DIR)/.installed: $(XML2_DIR)/.configured
	make -C $(XML2_DIR) $(SMP)
	make -C $(XML2_DIR) install
	touch $@

clean:
	rm -rf $(CROSS_DIR) $(XML2_DIR)/.installed $(GNUTLS_DIR)/.installed $(OPENCONNECT_DIR)/.installed $(NETTLE_DIR)/.installed $(GMP_DIR)/.installed $(P11_KIT_DIR)/.installed

dirclean:
	rm -rf $(CROSS_DIR) $(GNUTLS_DIR) $(NETTLE_DIR) $(GMP_DIR) $(P11_KIT_DIR)