11.PHONY : all build deps cbind clean test \
22 test_multiformat_exts test_integration \
3- install_pinned pin unpin gen_multicodec format clean-nim nat_libs nat_pkg_dir_check
3+ install_pinned pin unpin gen_multicodec format clean-nim
44
55NIM_VERSION ?= 2.2.10
66NPH_VERSION ?= 0.7.0
@@ -102,56 +102,11 @@ tests/nimble.paths: $(wildcard tests/nimbledeps/pkgs2/*/*.nimble) $(wildcard tes
102102 done ; \
103103 done
104104
105- # nim-nat-traversal vendors miniupnpc and libnatpmp as C sources. The package's
106- # `before install` hook builds them, but the resulting .a files are not always
107- # preserved alongside the package dir (cross-OS cache reuse, different gcc
108- # versions). Rebuild them up-front against the host's toolchain.
109- NAT_PKG_DIR := $(firstword $(wildcard nimbledeps/pkgs2/nat_traversal-* ) $(wildcard nimbledeps/pkgs/nat_traversal-* ) )
110- NAT_PMP_LIB := $(NAT_PKG_DIR ) /vendor/libnatpmp-upstream/libnatpmp.a
111-
112- # Use gcc rather than `cc` so the linux-i386 wrapper (external/bin/gcc, which
113- # injects -m32) is picked up. On macOS and llvm-mingw, `gcc` is a clang
114- # compatibility shim, so this stays ABI-compatible with nim's choice.
115- NAT_CC ?= gcc
116-
117- # miniupnpc's unix Makefile drops the .a under `build/`, but its Windows
118- # Makefile.mingw drops it at the package root. Match each one.
119- ifeq ($(OS ) ,Windows_NT)
120- NAT_UPNP_LIB := $(NAT_PKG_DIR ) /vendor/miniupnp/miniupnpc/libminiupnpc.a
121- NAT_UPNP_MAKE_ARGS := -f Makefile.mingw CC=$(NAT_CC ) libminiupnpc.a
122- NAT_PMP_CFLAGS := -Wall -Os -fPIC -DENABLE_STRNATPMPERR -DNATPMP_MAX_RETRIES=4 -DWIN32 -DNATPMP_STATICLIB
123- # libnatpmp's Makefile only appends wingettimeofday.o to LIBOBJS when $(OS)
124- # contains mingw/cygwin/msys. The CI Windows runner passes through Windows_NT
125- # (the host env var), so that branch never matches — leaving
126- # natpmp_gettimeofday undefined at link time. Pass LIBOBJS explicitly.
127- NAT_PMP_MAKE_ARGS := LIBOBJS="natpmp.o getgateway.o wingettimeofday.o" libnatpmp.a
128- else
129- NAT_UPNP_LIB := $(NAT_PKG_DIR ) /vendor/miniupnp/miniupnpc/build/libminiupnpc.a
130- NAT_UPNP_MAKE_ARGS := CC=$(NAT_CC ) CFLAGS="-Os -fPIC" build/libminiupnpc.a
131- NAT_PMP_CFLAGS := -Wall -Os -fPIC -DENABLE_STRNATPMPERR -DNATPMP_MAX_RETRIES=4
132- NAT_PMP_MAKE_ARGS := libnatpmp.a
133- endif
134-
135- # Stamp-based rebuild: the stamp records "the .a files in this package dir were
136- # built by our recipe with the right compiler". Re-running install_pinned wipes
137- # the package dir (and thus the stamp), forcing a rebuild.
138- NAT_LIBS_STAMP := $(NAT_PKG_DIR ) /.libp2p-nat-libs.stamp
139-
140- nat_libs : $(NAT_LIBS_STAMP )
141-
142- nat_pkg_dir_check :
143- @test -n " $( NAT_PKG_DIR) " || \
144- (echo " Error: nat_traversal package not found under nimbledeps/pkgs2/ or nimbledeps/pkgs/. Run 'nimble install_pinned' first." && exit 1)
145-
146- $(NAT_LIBS_STAMP ) : | nat_pkg_dir_check
147- rm -f " $( NAT_UPNP_LIB) " " $( NAT_PMP_LIB) "
148- -$(MAKE ) -C " $( NAT_PKG_DIR) /vendor/miniupnp/miniupnpc" clean
149- -$(MAKE ) -C " $( NAT_PKG_DIR) /vendor/libnatpmp-upstream" clean
150- $(MAKE ) -C " $( NAT_PKG_DIR) /vendor/miniupnp/miniupnpc" $(NAT_UPNP_MAKE_ARGS )
151- $(MAKE ) -C " $( NAT_PKG_DIR) /vendor/libnatpmp-upstream" CC=$(NAT_CC ) CFLAGS=" $( NAT_PMP_CFLAGS) " $(NAT_PMP_MAKE_ARGS )
152- touch " $@ "
105+ # nim-libplum vendors libplum (PCP / NAT-PMP / UPnP-IGD) as a git submodule and
106+ # compiles its C sources into libp2p via nim's {.compile.} pragmas, so there is
107+ # no separate NAT library to build or link here.
153108
154- test : nimble.paths tests/nimble.paths nat_libs
109+ test : nimble.paths tests/nimble.paths
155110ifeq ($(TEST_PATH ) ,)
156111 $(NIMC) c $(NIM_FLAGS) \
157112 $(if $(CICOV),--nimcache:nimcache/test_all,) \
166121 ./tests/test_all $(RUNNER_FLAGS) --xml:tests/results_test_all.xml
167122endif
168123
169- test_multiformat_exts : nimble.paths tests/nimble.paths nat_libs
124+ test_multiformat_exts : nimble.paths tests/nimble.paths
170125 $(NIMC ) c $(NIM_FLAGS ) \
171126 --nimcache:nimcache/test_all_multiformat \
172127 -d:libp2p_multicodec_exts=../tests/libp2p/multiformat_exts/multicodec_exts.nim \
@@ -178,7 +133,7 @@ test_multiformat_exts: nimble.paths tests/nimble.paths nat_libs
178133 tests/test_all.nim
179134 ./tests/test_all $(RUNNER_FLAGS ) --xml:tests/results_test_all_multiformat.xml
180135
181- test_integration : nimble.paths tests/nimble.paths nat_libs
136+ test_integration : nimble.paths tests/nimble.paths
182137 $(NIMC ) c $(NIM_FLAGS ) \
183138 $(if $(CICOV ) ,--nimcache:nimcache/integration,) \
184139 tests/integration/test_all.nim
0 commit comments