2018-10-23 15:50:22 +00:00
|
|
|
# makefile for windows bootstrap
|
|
|
|
# requires mbedtls to be installed somewhere, for both native and windows targets
|
|
|
|
# requires wget to be installed for ca bundle download
|
|
|
|
|
|
|
|
# to build:
|
|
|
|
# $ [g]make prepare;[g]make lokinet-bootstrap
|
|
|
|
|
|
|
|
# set this beforehand if you use clang
|
|
|
|
CC ?= i686-w64-mingw32-gcc
|
|
|
|
NATIVE_CC ?= cc
|
|
|
|
|
|
|
|
# set these for the native system
|
|
|
|
INCLUDE ?=
|
|
|
|
LIBS ?=
|
|
|
|
|
|
|
|
# set these for 32-bit windows if cross-compiling
|
|
|
|
WINNT_INCLUDE ?=
|
|
|
|
WINNT_LIBS ?=
|
|
|
|
|
2019-01-25 16:07:01 +00:00
|
|
|
ifdef LTO
|
|
|
|
LTO_FLAG = -flto
|
|
|
|
LTO_LDFLAG = -flto -march=nocona -mfpmath=sse -Ofast
|
|
|
|
endif
|
|
|
|
|
2018-10-23 15:50:22 +00:00
|
|
|
.PHONY: download prepare all default
|
|
|
|
|
|
|
|
# windows target only
|
|
|
|
.c.o:
|
2019-01-25 16:07:01 +00:00
|
|
|
$(CC) $(WINNT_INCLUDE) -Iinclude $(LTO_FLAG) -Ofast -march=nocona -mfpmath=sse $< -c
|
2018-10-23 15:50:22 +00:00
|
|
|
|
|
|
|
zpipe: zpipe.c miniz.c
|
2019-01-24 00:47:36 +00:00
|
|
|
$(NATIVE_CC) $(INCLUDE) -Iinclude $(LIBS) $^ -s -static -o $@
|
2018-10-23 15:50:22 +00:00
|
|
|
|
|
|
|
base64enc: base64enc.c
|
2019-01-24 00:47:36 +00:00
|
|
|
$(NATIVE_CC) $(INCLUDE) -Iinclude $(LIBS) $^ -s -static -o $@ -lmbedx509 -lmbedtls -lmbedcrypto
|
2018-10-23 15:50:22 +00:00
|
|
|
|
|
|
|
download:
|
|
|
|
wget -O ./cacert.pem https://curl.haxx.se/ca/cacert.pem
|
|
|
|
|
2019-01-23 23:56:16 +00:00
|
|
|
# I *think* this only work with GNU sed...
|
2018-10-23 15:50:22 +00:00
|
|
|
prepare: zpipe base64enc download
|
|
|
|
./zpipe < cacert.pem > data.enc
|
|
|
|
./base64enc < data.enc > out.bin
|
|
|
|
sed -ie "s/.\{76\}/&\n/g" out.bin
|
|
|
|
sed -i 's/.*/\"&\"/g' out.bin
|
2019-01-25 16:07:01 +00:00
|
|
|
sed -i '61,2268d' bootstrap.c
|
2018-10-23 15:50:22 +00:00
|
|
|
echo ';' >> out.bin
|
2019-01-25 16:07:01 +00:00
|
|
|
sed -i '60r out.bin' bootstrap.c
|
2018-10-23 15:50:22 +00:00
|
|
|
|
2019-01-24 00:07:00 +00:00
|
|
|
prepare-testnet: zpipe base64enc download
|
|
|
|
./zpipe < cacert.pem > data.enc
|
|
|
|
./base64enc < data.enc > out.bin
|
|
|
|
sed -ie "s/.\{76\}/&\n/g" out.bin
|
|
|
|
sed -i 's/.*/\"&\"/g' out.bin
|
2019-01-25 16:07:01 +00:00
|
|
|
sed -i '58,2144d' testnet.c
|
2019-01-24 00:07:00 +00:00
|
|
|
echo ';' >> out.bin
|
2019-01-25 16:07:01 +00:00
|
|
|
sed -i '57r out.bin' testnet.c
|
2019-01-24 00:07:00 +00:00
|
|
|
|
2018-10-23 15:50:22 +00:00
|
|
|
lokinet-bootstrap: bootstrap.o miniz.o
|
2019-01-25 16:07:01 +00:00
|
|
|
$(CC) $(WINNT_LIBS) -s -static $^ -o $@.exe $(LTO_LDFLAG) -lmbedx509 -lmbedtls -lmbedcrypto -lws2_32
|
2018-10-23 15:50:22 +00:00
|
|
|
|
2019-01-24 00:07:00 +00:00
|
|
|
lokinet-bootstrap-testnet: testnet.o miniz.o
|
2019-01-25 16:07:01 +00:00
|
|
|
$(CC) $(WINNT_LIBS) -s -static $^ -o $@.exe $(LTO_LDFLAG) -lmbedx509 -lmbedtls -lmbedcrypto -lws2_32
|
2018-10-23 15:50:22 +00:00
|
|
|
clean:
|
2019-01-24 00:07:00 +00:00
|
|
|
-@rm lokinet*.exe
|
2018-10-23 15:50:22 +00:00
|
|
|
-@rm base64enc
|
|
|
|
-@rm zpipe
|
|
|
|
-@rm cacert.pem
|
|
|
|
-@rm data.enc
|
|
|
|
-@rm out.*
|
|
|
|
-@rm *.o
|