PPCoin: RPC 'makekeypair' limits loop to avoid hang
[novacoin.git] / src / makefile.unix
1 # Copyright (c) 2009-2010 Satoshi Nakamoto
2 # Copyright (c) 2011 The PPCoin developers
3 # Distributed under the MIT/X11 software license, see the accompanying
4 # file license.txt or http://www.opensource.org/licenses/mit-license.php.
5
6 USE_UPNP:=0
7
8 DEFS=-DNOPCH
9
10 DEFS += $(addprefix -I,$(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH))
11 LIBS += $(addprefix -l,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH))
12
13 LMODE = dynamic
14 LMODE2 = dynamic
15 ifdef STATIC
16         LMODE = static
17         ifeq (${STATIC}, all)
18                 LMODE2 = static
19         endif
20 endif
21
22 # for boost 1.37, add -mt to the boost libraries
23 LIBS= \
24  -Wl,-B$(LMODE) \
25    -l boost_system$(BOOST_LIB_SUFFIX) \
26    -l boost_filesystem$(BOOST_LIB_SUFFIX) \
27    -l boost_program_options$(BOOST_LIB_SUFFIX) \
28    -l boost_thread$(BOOST_LIB_SUFFIX) \
29    -l db_cxx$(BDB_LIB_SUFFIX) \
30    -l ssl \
31    -l crypto
32
33 ifndef USE_UPNP
34         override USE_UPNP = -
35 endif
36 ifneq (${USE_UPNP}, -)
37         LIBS += -l miniupnpc
38         DEFS += -DUSE_UPNP=$(USE_UPNP)
39 endif
40
41 ifneq (${USE_SSL}, 0)
42         DEFS += -DUSE_SSL
43 endif
44
45 LIBS+= \
46  -Wl,-B$(LMODE2) \
47    -l z \
48    -l dl \
49    -l pthread
50
51
52 # Hardening
53 # Make some classes of vulnerabilities unexploitable in case one is discovered.
54 #
55     # This is a workaround for Ubuntu bug #691722, the default -fstack-protector causes
56     # -fstack-protector-all to be ignored unless -fno-stack-protector is used first.
57     # see: https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/691722
58     HARDENING=-fno-stack-protector
59
60     # Stack Canaries
61     # Put numbers at the beginning of each stack frame and check that they are the same.
62     # If a stack buffer if overflowed, it writes over the canary number and then on return
63     # when that number is checked, it won't be the same and the program will exit with
64     # a "Stack smashing detected" error instead of being exploited.
65     HARDENING+=-fstack-protector-all -Wstack-protector
66
67     # Make some important things such as the global offset table read only as soon as
68     # the dynamic linker is finished building it. This will prevent overwriting of addresses
69     # which would later be jumped to.
70     HARDENING+=-Wl,-z,relro -Wl,-z,now
71
72     # Build position independent code to take advantage of Address Space Layout Randomization
73     # offered by some kernels.
74     # see doc/build-unix.txt for more information.
75     ifdef PIE
76         HARDENING+=-fPIE -pie
77     endif
78
79     # -D_FORTIFY_SOURCE=2 does some checking for potentially exploitable code patterns in
80     # the source such overflowing a statically defined buffer.
81     HARDENING+=-D_FORTIFY_SOURCE=2
82 #
83
84
85 DEBUGFLAGS=-g
86 CXXFLAGS=-O2
87 xCXXFLAGS=-pthread -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(HARDENING) $(CXXFLAGS)
88 HEADERS = \
89     base58.h \
90     bignum.h \
91     checkpoints.h \
92     crypter.h \
93     db.h \
94     headers.h \
95     init.h \
96     irc.h \
97     key.h \
98     keystore.h \
99     main.h \
100     net.h \
101     noui.h \
102     protocol.h \
103     bitcoinrpc.h \
104     script.h \
105     serialize.h \
106     strlcpy.h \
107     uint256.h \
108     util.h \
109     wallet.h
110
111 OBJS= \
112     obj/checkpoints.o \
113     obj/crypter.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: ppcoind
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 ppcoind: $(OBJS:obj/%=obj/nogui/%)
141         $(CXX) $(xCXXFLAGS) -rdynamic -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_ppcoin: obj/test/test_ppcoin.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 ppcoind test_ppcoin genesis
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
161         -rm -f ppcoin/obj/*
162
163 ppcoin/obj/genesis.o: ppcoin/genesis.cpp
164         $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
165         $(CXX) -c $(xCXXFLAGS) -MMD -DPPCOIN_GENESIS -o obj/nogui/init.o init.cpp
166
167 genesis: ppcoin/obj/genesis.o $(OBJS:obj/%=obj/nogui/%)
168         $(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS)
169         -rm -f obj/nogui/init.*
170         -rm -f ppcoin/obj/genesis.*