Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Tril on May 01, 2011, 05:55:54 AM



Title: [PATCH] build without UPNP
Post by: Tril on May 01, 2011, 05:55:54 AM
Building without UPNP didn't work (on Linux), so I made the below changes.
Two new #ifdef's, and you definitely can't define something :=0 and expect it to
act as if undefined (GNU make).

I can make this into a github pull request later if need be.

Index: net.cpp
===================================================================
--- net.cpp     (revision 251)
+++ net.cpp     (working copy)
@@ -887,6 +887,7 @@
     printf("ThreadMapPort exiting\n");
 }
 
+#ifdef USE_UPNP
 void ThreadMapPort2(void* parg)
 {
     printf("ThreadMapPort started\n");
@@ -947,6 +948,7 @@
         }
     }
 }
+#endif
 
 void MapPort(bool fMapPort)
 {
Index: makefile.unix
===================================================================
--- makefile.unix       (revision 251)
+++ makefile.unix       (working copy)
@@ -8,7 +8,7 @@
 
 WXLIBS=$(shell wx-config --libs)
 
-USE_UPNP:=0
+#USE_UPNP:=1
 
 DEFS=-DNOPCH -DFOURWAYSSE2 -DUSE_SSL
 
Index: db.cpp
===================================================================
--- db.cpp      (revision 251)
+++ db.cpp      (working copy)
@@ -807,8 +807,10 @@
     printf("fMinimizeOnClose = %d\n", fMinimizeOnClose);
     printf("fUseProxy = %d\n", fUseProxy);
     printf("addrProxy = %s\n", addrProxy.ToString().c_str());
+#ifdef USE_UPNP
     if (fHaveUPnP)
         printf("fUseUPnP = %d\n", fUseUPnP);
+#endif
 
 
     // Upgrade


Title: Re: [PATCH] build without UPNP
Post by: kseistrup on May 01, 2011, 06:49:29 AM
Building without UPNP didn't work (on Linux)

All I did was commenting out the USE_UPNP stanzas in the makefile and then adding a -UUSE_UPNP to the DEFS variable:

Code:

--- makefile.unix 2011-05-01 08:46:17.405173473 +0200
+++ makefile.linux 2011-05-01 08:47:22.833923365 +0200
@@ -8,9 +8,9 @@
 
 WXLIBS=$(shell wx-config --libs)
 
-USE_UPNP:=0
+#USE_UPNP:=0
 
-DEFS=-DNOPCH -DFOURWAYSSE2 -DUSE_SSL
+DEFS=-DNOPCH -DFOURWAYSSE2 -DUSE_SSL -UUSE_UPNP
 
 # for boost 1.37, add -mt to the boost libraries
 LIBS= \
@@ -23,10 +23,10 @@
    -l ssl \
    -l crypto
 
-ifdef USE_UPNP
- LIBS += -l miniupnpc
- DEFS += -DUSE_UPNP=$(USE_UPNP)
-endif
+#ifdef USE_UPNP
+# LIBS += -l miniupnpc
+# DEFS += -DUSE_UPNP=$(USE_UPNP)
+#endif
 
 LIBS+= \
  -Wl,-Bdynamic \

Cheers,


Title: Re: [PATCH] build without UPNP
Post by: trentzb on May 01, 2011, 07:08:54 AM
Yea that bit me too. I had also thought that USE_UPNP in the Makefile was compile time not run time option. To build without just comment it in the Makefile. I would have thought that a compile time def would not be used for a run time option. But I am not a programmer so...


Title: Re: [PATCH] build without UPNP
Post by: Matt Corallo on May 01, 2011, 09:25:13 AM
Building without UPNP didn't work (on Linux), so I made the below changes.
Two new #ifdef's, and you definitely can't define something :=0 and expect it to
act as if undefined (GNU make).
Actually you can.  The intended way to build bitcoin without UPnP support is make -f makefile.unix USE_UPNP=
That will successfully build bitcoin without UPnP support and without miniupnpc installed.