1 # Copyright (c) 2009-2010 Satoshi Nakamoto
2 # Distributed under the MIT/X11 software license, see the accompanying
3 # file license.txt or http://www.opensource.org/licenses/mit-license.php.
7 WXINCLUDEPATHS=$(shell wx-config --cxxflags)
9 WXLIBS=$(shell wx-config --libs)
13 DEFS=-DNOPCH -DUSE_SSL
15 # for boost 1.37, add -mt to the boost libraries
20 -l boost_program_options \
28 DEFS += -DUSE_UPNP=$(USE_UPNP)
39 # Make some classes of vulnerabilities unexploitable in case one is discovered.
41 # This is a workaround for Ubuntu bug #691722, the default -fstack-protector causes
42 # -fstack-protector-all to be ignored unless -fno-stack-protector is used first.
43 # see: https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/691722
44 HARDENING=-fno-stack-protector
47 # Put numbers at the beginning of each stack frame and check that they are the same.
48 # If a stack buffer if overflowed, it writes over the canary number and then on return
49 # when that number is checked, it won't be the same and the program will exit with
50 # a "Stack smashing detected" error instead of being exploited.
51 HARDENING+=-fstack-protector-all -Wstack-protector
53 # Make some important things such as the global offset table read only as soon as
54 # the dynamic linker is finished building it. This will prevent overwriting of addresses
55 # which would later be jumped to.
56 HARDENING+=-Wl,-z,relro -Wl,-z,now
58 # Build position independent code to take advantage of Address Space Layout Randomization
59 # offered by some kernels.
60 # see doc/build-unix.txt for more information.
65 # -D_FORTIFY_SOURCE=2 does some checking for potentially exploitable code patterns in
66 # the source such overflowing a statically defined buffer.
67 HARDENING+=-D_FORTIFY_SOURCE=2
71 DEBUGFLAGS=-g -D__WXDEBUG__
72 CXXFLAGS=-O2 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(HARDENING)
119 obj/%.o: %.cpp $(HEADERS)
120 $(CXX) -c $(CXXFLAGS) $(WXINCLUDEPATHS) -DGUI -o $@ $<
122 cryptopp/obj/%.o: cryptopp/%.cpp
123 $(CXX) -c $(CXXFLAGS) -O3 -o $@ $<
125 bitcoin: $(OBJS) obj/ui.o obj/uibase.o
126 $(CXX) $(CXXFLAGS) -o $@ $^ $(WXLIBS) $(LIBS)
129 obj/nogui/%.o: %.cpp $(HEADERS)
130 $(CXX) -c $(CXXFLAGS) -o $@ $<
132 bitcoind: $(OBJS:obj/%=obj/nogui/%)
133 $(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS)
135 obj/test/test_bitcoin.o: $(wildcard test/*.cpp) $(HEADERS)
136 $(CXX) -c $(CXXFLAGS) -o $@ test/test_bitcoin.cpp
138 test_bitcoin: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%))
139 $(CXX) $(CXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-Bstatic -lboost_unit_test_framework $(LIBS)
142 -rm -f bitcoin bitcoind test_bitcoin
146 -rm -f cryptopp/obj/*.o