Skip to content

Commit c0a7deb

Browse files
Adapt makefile for libwaku windows (#3648)
1 parent 454b098 commit c0a7deb

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ ifeq ($(detected_OS),Windows)
4343

4444
LIBS = -lws2_32 -lbcrypt -liphlpapi -luserenv -lntdll -lminiupnpc -lnatpmp -lpq
4545
NIM_PARAMS += $(foreach lib,$(LIBS),--passL:"$(lib)")
46+
47+
export PATH := /c/msys64/usr/bin:/c/msys64/mingw64/bin:/c/msys64/usr/lib:/c/msys64/mingw64/lib:$(PATH)
48+
4649
endif
4750

4851
##########
@@ -424,13 +427,13 @@ docker-liteprotocoltester-push:
424427

425428
STATIC ?= 0
426429

427-
428430
libwaku: | build deps librln
429431
rm -f build/libwaku*
430432

431433
ifeq ($(STATIC), 1)
432434
echo -e $(BUILD_MSG) "build/[email protected]" && $(ENV_SCRIPT) nim libwakuStatic $(NIM_PARAMS) waku.nims
433435
else ifeq ($(detected_OS),Windows)
436+
make -f scripts/libwaku_windows_setup.mk windows-setup
434437
echo -e $(BUILD_MSG) "build/[email protected]" && $(ENV_SCRIPT) nim libwakuDynamic $(NIM_PARAMS) waku.nims
435438
else
436439
echo -e $(BUILD_MSG) "build/[email protected]" && $(ENV_SCRIPT) nim libwakuDynamic $(NIM_PARAMS) waku.nims
@@ -546,3 +549,4 @@ release-notes:
546549
sed -E 's@#([0-9]+)@[#\1](https://github.com/waku-org/nwaku/issues/\1)@g'
547550
# I could not get the tool to replace issue ids with links, so using sed for now,
548551
# asked here: https://github.com/bvieira/sv4git/discussions/101
552+

scripts/libwaku_windows_setup.mk

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# ---------------------------------------------------------
2+
# Windows Setup Makefile
3+
# ---------------------------------------------------------
4+
5+
# Extend PATH (Make preserves environment variables)
6+
export PATH := /c/msys64/usr/bin:/c/msys64/mingw64/bin:/c/msys64/usr/lib:/c/msys64/mingw64/lib:$(PATH)
7+
8+
# Tools required
9+
DEPS = gcc g++ make cmake cargo upx rustc python
10+
11+
# Default target
12+
.PHONY: windows-setup
13+
windows-setup: check-deps update-submodules create-tmp libunwind miniupnpc libnatpmp
14+
@echo "Windows setup completed successfully!"
15+
16+
.PHONY: check-deps
17+
check-deps:
18+
@echo "Checking libwaku build dependencies..."
19+
@for dep in $(DEPS); do \
20+
if ! which $$dep >/dev/null 2>&1; then \
21+
echo "✗ Missing dependency: $$dep"; \
22+
exit 1; \
23+
else \
24+
echo "✓ Found: $$dep"; \
25+
fi; \
26+
done
27+
28+
.PHONY: update-submodules
29+
update-submodules:
30+
@echo "Updating libwaku git submodules..."
31+
git submodule update --init --recursive
32+
33+
.PHONY: create-tmp
34+
create-tmp:
35+
@echo "Creating tmp directory..."
36+
mkdir -p tmp
37+
38+
.PHONY: libunwind
39+
libunwind:
40+
@echo "Building libunwind..."
41+
cd vendor/nim-libbacktrace && make all V=1
42+
43+
.PHONY: miniupnpc
44+
miniupnpc:
45+
@echo "Building miniupnpc..."
46+
cd vendor/nim-nat-traversal/vendor/miniupnp/miniupnpc && \
47+
make -f Makefile.mingw CC=gcc CXX=g++ libminiupnpc.a V=1
48+
49+
.PHONY: libnatpmp
50+
libnatpmp:
51+
@echo "Building libnatpmp..."
52+
cd vendor/nim-nat-traversal/vendor/libnatpmp-upstream && \
53+
make CC="gcc -fPIC -D_WIN32_WINNT=0x0600 -DNATPMP_STATICLIB" libnatpmp.a V=1

0 commit comments

Comments
 (0)