Add GetSecret() and GetKeys() to CKeyStore
[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 USE_UPNP:=0
6
7 DEFS=-DNOPCH
8
9 DEFS += $(addprefix -I,$(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH))
10 LIBS += $(addprefix -l,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH))
11
12 LMODE = dynamic
13 LMODE2 = dynamic
14 ifdef STATIC
15         LMODE = static
16         ifeq (${STATIC}, all)
17                 LMODE2 = static
18         endif
19 endif
20
21 # for boost 1.37, add -mt to the boost libraries
22 LIBS= \
23  -Wl,-B$(LMODE) \
24    -l boost_system$(BOOST_LIB_SUFFIX) \
25    -l boost_filesystem$(BOOST_LIB_SUFFIX) \
26    -l boost_program_options$(BOOST_LIB_SUFFIX) \
27    -l boost_thread$(BOOST_LIB_SUFFIX) \
28    -l db_cxx$(BDB_LIB_SUFFIX) \
29    -l ssl \
30    -l crypto
31
32 ifndef USE_UPNP
33         override USE_UPNP = -
34 endif
35 ifneq (${USE_UPNP}, -)
36         LIBS += -l miniupnpc
37         DEFS += -DUSE_UPNP=$(USE_UPNP)
38 endif
39
40 ifneq (${USE_SSL}, 0)
41         DEFS += -DUSE_SSL
42 endif
43
44 LIBS+= \
45  -Wl,-B$(LMODE2) \
46    -l z \
47    -l dl \
48    -l pthread
49
50
51 # Hardening
52 # Make some classes of vulnerabilities unexploitable in case one is discovered.
53 #
54     # This is a workaround for Ubuntu bug #691722, the default -fstack-protector causes
55     # -fstack-protector-all to be ignored unless -fno-stack-protector is used first.
56     # see: https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/691722
57     HARDENING=-fno-stack-protector
58
59     # Stack Canaries
60     # Put numbers at the beginning of each stack frame and check that they are the same.
61     # If a stack buffer if overflowed, it writes over the canary number and then on return
62     # when that number is checked, it won't be the same and the program will exit with
63     # a "Stack smashing detected" error instead of being exploited.
64     HARDENING+=-fstack-protector-all -Wstack-protector
65
66     # Make some important things such as the global offset table read only as soon as
67     # the dynamic linker is finished building it. This will prevent overwriting of addresses
68     # which would later be jumped to.
69     HARDENING+=-Wl,-z,relro -Wl,-z,now
70
71     # Build position independent code to take advantage of Address Space Layout Randomization
72     # offered by some kernels.
73     # see doc/build-unix.txt for more information.
74     ifdef PIE
75         HARDENING+=-fPIE -pie
76     endif
77
78     # -D_FORTIFY_SOURCE=2 does some checking for potentially exploitable code patterns in
79     # the source such overflowing a statically defined buffer.
80     HARDENING+=-D_FORTIFY_SOURCE=2
81 #
82
83
84 DEBUGFLAGS=-g
85 CXXFLAGS=-O2
86 xCXXFLAGS=-pthread -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(HARDENING) $(CXXFLAGS)
87 HEADERS = \
88     base58.h \
89     bignum.h \
90     checkpoints.h \
91     crypter.h \
92     db.h \
93     headers.h \
94     init.h \
95     irc.h \
96     key.h \
97     keystore.h \
98     main.h \
99     net.h \
100     noui.h \
101     protocol.h \
102     bitcoinrpc.h \
103     script.h \
104     serialize.h \
105     strlcpy.h \
106     uint256.h \
107     util.h \
108     wallet.h
109
110 OBJS= \
111     obj/checkpoints.o \
112     obj/crypter.o \
113     obj/key.o \
114     obj/db.o \
115     obj/init.o \
116     obj/irc.o \
117     obj/keystore.o \
118     obj/main.o \
119     obj/net.o \
120     obj/protocol.o \
121     obj/bitcoinrpc.o \
122     obj/script.o \
123     obj/util.o \
124     obj/wallet.o
125
126
127 all: bitcoind
128
129 # auto-generated dependencies:
130 -include obj/nogui/*.P
131 -include obj/test/*.P
132
133 obj/nogui/%.o: %.cpp
134         $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
135         @cp $(@:%.o=%.d) $(@:%.o=%.P); \
136           sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
137               -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
138           rm -f $(@:%.o=%.d)
139
140 bitcoind: $(OBJS:obj/%=obj/nogui/%)
141         $(CXX) $(xCXXFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
142
143 obj/test/%.o: test/%.cpp
144         $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
145         @cp $(@:%.o=%.d) $(@:%.o=%.P); \
146           sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
147               -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
148           rm -f $(@:%.o=%.d)
149
150 test_bitcoin: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%))
151         $(CXX) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-Bstatic -lboost_unit_test_framework $(LDFLAGS) $(LIBS)
152
153 clean:
154         -rm -f bitcoind test_bitcoin
155         -rm -f obj/*.o
156         -rm -f obj/nogui/*.o
157         -rm -f obj/test/*.o
158         -rm -f obj/*.P
159         -rm -f obj/nogui/*.P
160         -rm -f obj/test/*.P