Allow tinc to be built with miniupnpc on Windows.
authorEtienne Dechamps <etienne@edechamps.fr>
Sun, 15 Nov 2015 15:30:01 +0000 (15:30 +0000)
committerEtienne Dechamps <etienne@edechamps.fr>
Sat, 21 Nov 2015 16:18:01 +0000 (16:18 +0000)
Contrary to what I expected, it so happens that modern versions of MinGW
include an implementation of pthread natively by default, so there is no
need to introduce Win32-specific threading code. This means the only
changes required to make UPnP work on Windows are just build parameter
tuning.

This commit forces MinGW to be built statically. This makes linking
against miniupnpc simpler (otherwise we would have to handle the mess
of dllimport & co.) and it also prevents libwinpthread from being linked
dynamically (which it is by default), as this would require additional
DLLs to be distributed. Since static linking is how tinc is
traditionally built on Windows, I don't expect this to be a big deal.

configure.ac

index 4fe415e9ba2ad37e485254c863a0532f73874f00..005a24a4852b771675a76890cc6f7b55d8e03568 100644 (file)
@@ -67,7 +67,9 @@ case $host_os in
   *mingw*)
     mingw=true
     AC_DEFINE(HAVE_MINGW, 1, [MinGW])
-    LIBS="$LIBS -lws2_32 -lgdi32 -lcrypt32"
+    LIBS="$LIBS -lws2_32 -lgdi32 -lcrypt32 -liphlpapi"
+    LDFLAGS="$LDFLAGS -static"
+    CPPFLAGS="$CPPFLAGS -DMINIUPNP_STATICLIB"
   ;;
   *)
     AC_MSG_ERROR("Unknown operating system.")