Moved checkpoints out of main, to prep for using them to help prevent DoS attacks
[novacoin.git] / src / makefile.unix
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.
4
5 CXX=g++
6
7 WXINCLUDEPATHS=$(shell wx-config --cxxflags)
8
9 WXLIBS=$(shell wx-config --libs)
10
11 USE_UPNP:=0
12
13 DEFS=-DNOPCH -DUSE_SSL
14
15 # for boost 1.37, add -mt to the boost libraries
16 LIBS= \
17  -Wl,-Bstatic \
18    -l boost_system \
19    -l boost_filesystem \
20    -l boost_program_options \
21    -l boost_thread \
22    -l db_cxx \
23    -l ssl \
24    -l crypto
25
26 ifdef USE_UPNP
27         LIBS += -l miniupnpc
28         DEFS += -DUSE_UPNP=$(USE_UPNP)
29 endif
30
31 LIBS+= \
32  -Wl,-Bdynamic \
33    -l z \
34    -l dl \
35    -l pthread
36
37
38 # Hardening
39 # Make some classes of vulnerabilities unexploitable in case one is discovered.
40 #
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
45
46     # Stack Canaries
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
52
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
57
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.
61     ifdef PIE
62         HARDENING+=-fPIE -pie
63     endif
64
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
68 #
69
70
71 DEBUGFLAGS=-g -D__WXDEBUG__
72 CXXFLAGS=-O2 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(HARDENING)
73 HEADERS = \
74     base58.h \
75     bignum.h \
76     checkpoints.h \
77     crypter.h \
78     db.h \
79     headers.h \
80     init.h \
81     irc.h \
82     key.h \
83     keystore.h \
84     main.h \
85     net.h \
86     noui.h \
87     protocol.h \
88     rpc.h \
89     script.h \
90     serialize.h \
91     strlcpy.h \
92     ui.h \
93     uibase.h \
94     uint256.h \
95     util.h \
96     wallet.h
97
98 OBJS= \
99     obj/checkpoints.o \
100     obj/crypter.o \
101     obj/db.o \
102     obj/init.o \
103     obj/irc.o \
104     obj/keystore.o \
105     obj/main.o \
106     obj/net.o \
107     obj/protocol.o \
108     obj/rpc.o \
109     obj/script.o \
110     obj/util.o \
111     obj/wallet.o \
112     cryptopp/obj/sha.o \
113     cryptopp/obj/cpu.o
114
115
116 all: bitcoin
117
118
119 obj/%.o: %.cpp $(HEADERS)
120         $(CXX) -c $(CXXFLAGS) $(WXINCLUDEPATHS) -DGUI -o $@ $<
121
122 cryptopp/obj/%.o: cryptopp/%.cpp
123         $(CXX) -c $(CXXFLAGS) -O3 -o $@ $<
124
125 bitcoin: $(OBJS) obj/ui.o obj/uibase.o
126         $(CXX) $(CXXFLAGS) -o $@ $^ $(WXLIBS) $(LIBS)
127
128
129 obj/nogui/%.o: %.cpp $(HEADERS)
130         $(CXX) -c $(CXXFLAGS) -o $@ $<
131
132 bitcoind: $(OBJS:obj/%=obj/nogui/%)
133         $(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS)
134
135 obj/test/test_bitcoin.o: $(wildcard test/*.cpp) $(HEADERS)
136         $(CXX) -c $(CFLAGS) -o $@ test/test_bitcoin.cpp
137
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)
140
141 clean:
142         -rm -f bitcoin bitcoind test_bitcoin
143         -rm -f obj/*.o
144         -rm -f obj/nogui/*.o
145         -rm -f obj/test/*.o
146         -rm -f cryptopp/obj/*.o
147         -rm -f headers.h.gch