src/makefile.mingw
# Copyright (c) 2009-2010 Satoshi Nakamoto
# Distributed under the MIT/X11 software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
USE_UPNP:=1
USE_WALLET:=1
INCLUDEPATHS= \
-I"C:\Develop\deps\boost_1_59_0" \
-I"C:\Develop\deps\db-4.8.30.NC\build_unix" \
-I"C:\Develop\deps\openssl-1.0.2d\include" \
-I"$(abspath obj)"
TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)
LIBPATHS= \
-L"C:\Develop\deps\boost_1_59_0\bin.v2\libs" \
-L"C:\Develop\deps\db-4.8.30.NC\build_unix" \
-L"C:\Develop\deps\openssl-1.0.2d\lib" \
LIBS= \
-l boost_system-mgw49-mt-s-1_59 \
-l boost_filesystem-mgw49-mt-s-1_59 \
-l boost_program_options-mgw49-mt-s-1_59 \
-l boost_thread-mgw49-mt-s-1_59 \
-l boost_chrono-mgw49-mt-s-1_59 \
-l db_cxx \
-l ssl \
-l crypto \
-l z
DEFS=-DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE
DEBUGFLAGS=-g
CFLAGS=-mthreads -O3 -msse2 -w -Wall -Wextra -Wno-ignored-qualifiers -Wformat -Wformat-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
LDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat -static -static-libgcc -static-libstdc++
TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)
ifndef USE_UPNP
override USE_UPNP = -
endif
ifneq (${USE_UPNP}, -)
INCLUDEPATHS += -I"C:\Develop\deps\miniupnpc-1.9\include"
LIBPATHS += -L"C:\Develop\deps\miniupnpc-1.9\lib"
LIBS += -l miniupnpc -l iphlpapi
DEFS += -DMINIUPNP_STATICLIB -DSTATICLIB -DUSE_UPNP=$(USE_UPNP)
endif
LIBS += -l kernel32 -l user32 -l gdi32 -l comdlg32 -l winspool -l winmm -l shell32 -l comctl32 -l ole32 -l oleaut32 -l uuid -l rpcrt4 -l advapi32 -l ws2_32 -l mswsock -l shlwapi
# Hardening
# Make some classes of vulnerabilities unexploitable in case one is discovered.
#
# This is a workaround for Ubuntu bug #691722, the default -fstack-protector causes
# -fstack-protector-all to be ignored unless -fno-stack-protector is used first.
# see: https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/691722
HARDENING=-fno-stack-protector
# Stack Canaries
# Put numbers at the beginning of each stack frame and check that they are the same.
# If a stack buffer if overflowed, it writes over the canary number and then on return
# when that number is checked, it won't be the same and the program will exit with
# a "Stack smashing detected" error instead of being exploited.
HARDENING+=-fstack-protector-all -Wstack-protector
# Make some important things such as the global offset table read only as soon as
# the dynamic linker is finished building it. This will prevent overwriting of addresses
# which would later be jumped to.
LDHARDENING+=-Wl,-z,relro -Wl,-z,now
# -D_FORTIFY_SOURCE=2 does some checking for potentially exploitable code patterns in
# the source such overflowing a statically defined buffer.
HARDENING+=-D_FORTIFY_SOURCE=2
#
DEBUGFLAGS=-g
# TODO: make the mingw builds smarter about dependencies, like the linux/osx builds are
HEADERS = $(wildcard *.h)
OBJS= \
obj/alert.o \
obj/version.o \
obj/checkpoints.o \
obj/netbase.o \
obj/addrman.o \
obj/crypter.o \
obj/key.o \
obj/eckey.o \
obj/extkey.o \
obj/db.o \
obj/init.o \
obj/shadowcoind.o \
obj/keystore.o \
obj/miner.o \
obj/main.o \
obj/net.o \
obj/protocol.o \
obj/rpcprotocol.o \
obj/rpcserver.o \
obj/rpcclient.o \
obj/rpcdump.o \
obj/rpcnet.o \
obj/rpcmining.o \
obj/rpcwallet.o \
obj/rpcblockchain.o \
obj/rpcrawtransaction.o \
obj/rpcsmessage.o \
obj/rpcextkey.o \
obj/rpcmnemonic.o \
obj/script.o \
obj/sync.o \
obj/util.o \
obj/hash.o \
obj/wallet.o \
obj/walletdb.o \
obj/noui.o \
obj/kernel.o \
obj/pbkdf2.o \
obj/scrypt.o \
obj/scrypt-arm.o \
obj/scrypt-x86.o \
obj/scrypt-x86_64.o \
obj/smessage.o \
obj/stealth.o \
obj/ringsig.o \
obj/core.o \
obj/txmempool.o \
obj/chainparams.o \
obj/state.o \
obj/bloom.o
all: shadowcoind.exe
test check: test_shadow FORCE
./test_shadow
LIBS += $(CURDIR)/leveldb/libleveldb.a $(CURDIR)/leveldb/libmemenv.a
DEFS += $(addprefix -I,$(CURDIR)/leveldb/include)
DEFS += $(addprefix -I,$(CURDIR)/leveldb/helpers)
OBJS += obj/txdb-leveldb.o
leveldb/libleveldb.a:
@echo "Building LevelDB ..." && cd leveldb TARGET_OS=NATIVE_WINDOWS make libleveldb.a libmemenv.a cd ..
obj/txdb-leveldb.o: leveldb/libleveldb.a
obj/build.h: FORCE
sh ../share/genbuild.sh obj/build.h
version.cpp: obj/build.h
DEFS += -DHAVE_BUILD_INFO
obj/%.o: %.cpp $(HEADERS)
$(CXX) -c $(CFLAGS) -o $@ $<
shadowcoind.exe: $(OBJS:obj/%=obj/%)
$(CXX) $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) -lshlwapi
strip shadowcoind.exe
obj/scrypt-x86.o: scrypt-x86.S
$(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
obj/scrypt-x86_64.o: scrypt-x86_64.S
$(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
obj/scrypt-arm.o: scrypt-arm.S
$(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp))
xTESTCXXFLAGS = -std=c++11
obj-test/%.o: test/%.cpp
$(CXX) -c $(TESTDEFS) $(xTESTCXXFLAGS) $(xCXXFLAGS) $(CFLAGS) $(LDFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $<
@cp $(@:%.o=%.d) $(@:%.o=%.P); \
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
rm -f $(@:%.o=%.d)
test_shadow.exe: $(TESTOBJS) $(filter-out obj/init.o obj/shadowcoind.o,$(OBJS:obj/%=obj/%))
$(LINK) $(xCXXFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPATHS) $^ $(TESTLIBS) $(xLDFLAGS) $(LIBS)
clean:
-rm -f obj/*.o
-rm -f shadowcoind.exe
-rm -f obj/build.h
cd leveldb && TARGET_OS=NATIVE_WINDOWS $(MAKE) clean && cd ..
-rm -f test_shadow.exe
-rm -f obj-test/*.o
-rm -f obj-test/*.P
FORCE: