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.
42 # Put numbers at the beginning of each stack frame and check that they are the same.
43 # If a stack buffer if overflowed, it writes over the canary number and then on return
44 # when that number is checked, it won't be the same and the program will exit with
45 # a "Stack smashing detected" error instead of being exploited.
46 HARDENING=-fstack-protector-all -Wstack-protector
48 # Make some important things such as the global offset table read only as soon as
49 # the dynamic linker is finished building it. This will prevent overwriting of addresses
50 # which would later be jumped to.
51 HARDENING+=-Wl,-z,relro -Wl,-z,now
53 # Build position independent code to take advantage of Address Space Layout Randomization
54 # offered by some kernels.
55 # see doc/build-unix.txt for more information.
60 # -D_FORTIFY_SOURCE=2 does some checking for potentially exploitable code patterns in
61 # the source such overflowing a statically defined buffer.
62 HARDENING+=-D_FORTIFY_SOURCE=2
66 DEBUGFLAGS=-g -D__WXDEBUG__
67 CXXFLAGS=-O2 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(HARDENING)
112 obj/%.o: %.cpp $(HEADERS)
113 $(CXX) -c $(CXXFLAGS) $(WXINCLUDEPATHS) -DGUI -o $@ $<
115 cryptopp/obj/%.o: cryptopp/%.cpp
116 $(CXX) -c $(CXXFLAGS) -O3 -o $@ $<
118 bitcoin: $(OBJS) obj/ui.o obj/uibase.o
119 $(CXX) $(CXXFLAGS) -o $@ $^ $(WXLIBS) $(LIBS)
122 obj/nogui/%.o: %.cpp $(HEADERS)
123 $(CXX) -c $(CXXFLAGS) -o $@ $<
125 bitcoind: $(OBJS:obj/%=obj/nogui/%)
126 $(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS)
128 obj/test/test_bitcoin.o: $(wildcard test/*.cpp) $(HEADERS)
129 $(CXX) -c $(CFLAGS) -o $@ test/test_bitcoin.cpp
131 test_bitcoin: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%))
132 $(CXX) $(CXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-Bstatic -lboost_unit_test_framework $(LIBS)
135 -rm -f bitcoin bitcoind test_bitcoin
139 -rm -f cryptopp/obj/*.o