diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2012-12-21 14:41:48 -0500 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2013-01-23 10:42:46 -0500 |
commit | b1024662eafddd5560fbfbac29333e5e967ca0f8 (patch) | |
tree | a8bdd5a1adf525847c8f7df4b2b62268f8d0a738 /src/makefile.mingw | |
parent | 8aef119f43ee3b4e75e0f3bd7ea28cf7b29bb582 (diff) |
Port leveldb to MinGW32
Several changes to make the native windows leveldb code compile
with mingw32 and run on 32-bit Windows:
* Remove -std=c++0x dependency (modified code to use NULL instead of
nullptr)
* Link with -lshlwapi
* Only #define snprintf/etc if compiling with Visual Studio
* Do not link against DbgHelp.lib (wrote a CreateDir instead of using
DbgHelp's MakeSureDirectoryPathExists
* Define WINVER=0x0500 so MinGW32 can use the 64-bit-filesystem Windows
api calls
* Define __USE_MINGW_ANSI_STDIO=1 to use MinGW's printf (which supports
%ll)
I also cleaned up makefile.mingw, assuming that dependencies would be in
the standard /usr/local/{include,lib} by default but allowing overriding
with make DEPSDIR=... etc
Diffstat (limited to 'src/makefile.mingw')
-rw-r--r-- | src/makefile.mingw | 57 |
1 files changed, 36 insertions, 21 deletions
diff --git a/src/makefile.mingw b/src/makefile.mingw index a7a57a2a24..366d32bd86 100644 --- a/src/makefile.mingw +++ b/src/makefile.mingw @@ -2,25 +2,41 @@ # Distributed under the MIT/X11 software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. -USE_UPNP:=0 +# Makefile for the MinGW g++ compiler/toolchain +# +# Assumes Berkeley DB, Boost, and OpenSSL have all been compiled and installed +# into /usr/local (/usr/local/include, /usr/local/lib). +# +# If dependencies are somewhere else, run 'make DEPSDIR=/path/' +# +# Boost libraries are given wacky names that include the particular version of +# boost you're using; set BOOST_SUFFIX appropriately. +# +# 'make clean' assumes it is running inside a MSYS shell, and uses 'rm' +# to remove files. + +USE_UPNP:=- USE_IPV6:=1 +DEPSDIR?=/usr/local +BOOST_SUFFIX?=-mgw46-mt-sd-1_52 + INCLUDEPATHS= \ - -I"C:\boost-1.50.0-mgw" \ - -I"C:\db-4.8.30.NC-mgw\build_unix" \ - -I"C:\openssl-1.0.1c-mgw\include" + -I"$(CURDIR)" \ + -I"$(DEPSDIR)/include" LIBPATHS= \ - -L"C:\boost-1.50.0-mgw\stage\lib" \ - -L"C:\db-4.8.30.NC-mgw\build_unix" \ - -L"C:\openssl-1.0.1c-mgw" + -L"$(CURDIR)/leveldb" \ + -L"$(DEPSDIR)/lib" LIBS= \ - -l boost_system-mgw45-mt-s-1_50 \ - -l boost_filesystem-mgw45-mt-s-1_50 \ - -l boost_program_options-mgw45-mt-s-1_50 \ - -l boost_thread-mgw45-mt-s-1_50 \ - -l boost_chrono-mgw45-mt-s-1_50 \ + -l leveldb \ + -l memenv \ + -l boost_system$(BOOST_SUFFIX) \ + -l boost_filesystem$(BOOST_SUFFIX) \ + -l boost_program_options$(BOOST_SUFFIX) \ + -l boost_thread$(BOOST_SUFFIX) \ + -l boost_chrono$(BOOST_SUFFIX) \ -l db_cxx \ -l ssl \ -l crypto @@ -37,8 +53,6 @@ ifndef USE_UPNP override USE_UPNP = - endif ifneq (${USE_UPNP}, -) - INCLUDEPATHS += -I"C:\miniupnpc-1.6-mgw" - LIBPATHS += -L"C:\miniupnpc-1.6-mgw" LIBS += -l miniupnpc -l iphlpapi DEFS += -DSTATICLIB -DUSE_UPNP=$(USE_UPNP) endif @@ -94,12 +108,12 @@ test check: test_bitcoin.exe FORCE # # LevelDB support # -LIBS += $(CURDIR)/leveldb/libleveldb.a $(CURDIR)/leveldb/libmemenv.a DEFS += $(addprefix -I,$(CURDIR)/leveldb/include) DEFS += $(addprefix -I,$(CURDIR)/leveldb/helpers) -# TODO: If this fails, try adding a ranlib libleveldb.a && ranlib libmemenv.a + leveldb/libleveldb.a: - cd leveldb && $(MAKE) libleveldb.a libmemenv.a && cd .. + cd leveldb && $(MAKE) OPT="$(DEBUGFLAGS)" TARGET_OS=NATIVE_WINDOWS libleveldb.a libmemenv.a && cd .. + obj/leveldb.o: leveldb/libleveldb.a obj/%.o: %.cpp $(HEADERS) @@ -114,11 +128,12 @@ obj-test/%.o: test/%.cpp $(HEADERS) g++ -c $(TESTDEFS) $(CFLAGS) -o $@ $< test_bitcoin.exe: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%)) - g++ $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPATHS) $^ -lboost_unit_test_framework $(LIBS) + g++ $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPATHS) $^ -lboost_unit_test_framework$(BOOST_SUFFIX) $(LIBS) clean: - -del /Q bitcoind test_bitcoin - -del /Q obj\* - -del /Q obj-test\* + rm -f bitcoind.exe test_bitcoin.exe + rm -f obj/* + rm -f obj-test/* + cd leveldb && $(MAKE) TARGET_OS=NATIVE_WINDOWS clean && cd .. FORCE: |