bitcoind does not need to link with gthread-2.0
[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     # Stack Canaries
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
47
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
52
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.
56     ifdef PIE
57         HARDENING+=-fPIE -pie
58     endif
59
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
63 #
64
65
66 DEBUGFLAGS=-g -D__WXDEBUG__
67 CXXFLAGS=-O2 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(HARDENING)
68 HEADERS = \
69     base58.h \
70     bignum.h \
71     crypter.h \
72     db.h \
73     headers.h \
74     init.h \
75     irc.h \
76     key.h \
77     keystore.h \
78     main.h \
79     net.h \
80     noui.h \
81     protocol.h \
82     rpc.h \
83     script.h \
84     serialize.h \
85     strlcpy.h \
86     ui.h \
87     uibase.h \
88     uint256.h \
89     util.h \
90     wallet.h
91
92 OBJS= \
93     obj/crypter.o \
94     obj/db.o \
95     obj/init.o \
96     obj/irc.o \
97     obj/keystore.o \
98     obj/main.o \
99     obj/net.o \
100     obj/protocol.o \
101     obj/rpc.o \
102     obj/script.o \
103     obj/util.o \
104     obj/wallet.o \
105     cryptopp/obj/sha.o \
106     cryptopp/obj/cpu.o
107
108
109 all: bitcoin
110
111
112 obj/%.o: %.cpp $(HEADERS)
113         $(CXX) -c $(CXXFLAGS) $(WXINCLUDEPATHS) -DGUI -o $@ $<
114
115 cryptopp/obj/%.o: cryptopp/%.cpp
116         $(CXX) -c $(CXXFLAGS) -O3 -o $@ $<
117
118 bitcoin: $(OBJS) obj/ui.o obj/uibase.o
119         $(CXX) $(CXXFLAGS) -o $@ $^ $(WXLIBS) $(LIBS)
120
121
122 obj/nogui/%.o: %.cpp $(HEADERS)
123         $(CXX) -c $(CXXFLAGS) -o $@ $<
124
125 bitcoind: $(OBJS:obj/%=obj/nogui/%)
126         $(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS)
127
128 obj/test/test_bitcoin.o: $(wildcard test/*.cpp) $(HEADERS)
129         $(CXX) -c $(CFLAGS) -o $@ test/test_bitcoin.cpp
130
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)
133
134 clean:
135         -rm -f bitcoin bitcoind test_bitcoin
136         -rm -f obj/*.o
137         -rm -f obj/nogui/*.o
138         -rm -f obj/test/*.o
139         -rm -f cryptopp/obj/*.o
140         -rm -f headers.h.gch