Bump version to 0.3.4
[novacoin.git] / src / makefile.bsd
1 # Copyright (c) 2009-2010 Satoshi Nakamoto
2 # Copyright (c) 2011-2012 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:=-
7
8 DEFS=-DBOOST_SPIRIT_THREADSAFE
9 BOOST_INCLUDE_PATH=/usr/local/include
10 BDB_INCLUDE_PATH=/usr/local/include/db48
11 BOOST_LIB_PATH=/usr/local/lib
12 BDB_LIB_PATH=/usr/local/lib/db48
13
14 DEFS += $(addprefix -I,$(CURDIR) $(CURDIR)/obj $(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH))
15 LIBS = $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH))
16
17 TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)
18
19 LMODE = dynamic
20 LMODE2 = dynamic
21 ifdef STATIC
22         LMODE = static
23         ifeq (${STATIC}, all)
24                 LMODE2 = static
25         endif
26 else
27         TESTDEFS += -DBOOST_TEST_DYN_LINK
28 endif
29
30 # for boost 1.37, add -mt to the boost libraries
31 LIBS += \
32  -Wl,-B$(LMODE) \
33    -l boost_system$(BOOST_LIB_SUFFIX) \
34    -l boost_filesystem$(BOOST_LIB_SUFFIX) \
35    -l boost_program_options$(BOOST_LIB_SUFFIX) \
36    -l boost_thread$(BOOST_LIB_SUFFIX) \
37    -l db_cxx$(BDB_LIB_SUFFIX) \
38    -l ssl \
39    -l crypto \
40    -l execinfo
41
42 ifndef USE_UPNP
43         override USE_UPNP = -
44 endif
45 ifneq (${USE_UPNP}, -)
46         LIBS += -l miniupnpc
47         DEFS += -DUSE_UPNP=$(USE_UPNP)
48 endif
49
50 LIBS+= \
51  -Wl,-B$(LMODE2) \
52    -l z \
53    -l pthread
54
55
56 # Hardening
57 # Make some classes of vulnerabilities unexploitable in case one is discovered.
58 #
59     # This is a workaround for Ubuntu bug #691722, the default -fstack-protector causes
60     # -fstack-protector-all to be ignored unless -fno-stack-protector is used first.
61     # see: https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/691722
62     HARDENING=-fno-stack-protector
63
64     # Stack Canaries
65     # Put numbers at the beginning of each stack frame and check that they are the same.
66     # If a stack buffer if overflowed, it writes over the canary number and then on return
67     # when that number is checked, it won't be the same and the program will exit with
68     # a "Stack smashing detected" error instead of being exploited.
69     HARDENING+=-fstack-protector-all -Wstack-protector
70
71     # Make some important things such as the global offset table read only as soon as
72     # the dynamic linker is finished building it. This will prevent overwriting of addresses
73     # which would later be jumped to.
74     HARDENING+=-Wl,-z,relro -Wl,-z,now
75
76     # Build position independent code to take advantage of Address Space Layout Randomization
77     # offered by some kernels.
78     # see doc/build-unix.txt for more information.
79     ifdef PIE
80         HARDENING+=-fPIE -pie
81     endif
82
83     # -D_FORTIFY_SOURCE=2 does some checking for potentially exploitable code patterns in
84     # the source such overflowing a statically defined buffer.
85     HARDENING+=-D_FORTIFY_SOURCE=2
86 #
87
88
89 DEBUGFLAGS=-g
90 CXXFLAGS=-O2 -msse2
91 xCXXFLAGS=-pthread -Wall -Wextra -Wno-sign-compare -Wno-invalid-offsetof -Wno-unused-parameter -Wformat -Wformat-security \
92     $(DEBUGFLAGS) $(DEFS) $(HARDENING) $(CXXFLAGS)
93
94 OBJS= \
95     obj/version.o \
96     obj/checkpoints.o \
97     obj/netbase.o \
98     obj/addrman.o \
99     obj/crypter.o \
100     obj/key.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/bitcoinrpc.o \
109     obj/rpcdump.o \
110     obj/script.o \
111     obj/util.o \
112     obj/wallet.o \
113     obj/walletdb.o \
114     obj/noui.o \
115     obj/kernel.o \
116     obj/pbkdf2.o \
117     obj/scrypt_mine.o \
118     obj/scrypt-x86.o \
119     obj/scrypt-x86_64.o
120
121 all: novacoind
122
123 # auto-generated dependencies:
124 -include obj/*.P
125 -include obj-test/*.P
126
127 obj/build.h: FORCE
128         /bin/sh ../share/genbuild.sh obj/build.h
129 version.cpp: obj/build.h
130 DEFS += -DHAVE_BUILD_INFO
131
132 obj/%.o: %.cpp
133         $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
134         @cp $(@:%.o=%.d) $(@:%.o=%.P); \
135           sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
136               -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
137           rm -f $(@:%.o=%.d)
138
139 obj/scrypt-x86.o: scrypt-x86.S
140         $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
141
142 obj/scrypt-x86_64.o: scrypt-x86_64.S
143         $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
144
145 novacoind: $(OBJS:obj/%=obj/%)
146         $(CXX) $(xCXXFLAGS) -rdynamic -o $@ $^ $(LDFLAGS) $(LIBS)
147
148 TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp))
149
150 obj-test/%.o: test/%.cpp
151         $(CXX) -c $(TESTDEFS) $(xCXXFLAGS) -MMD -o $@ $<
152         @cp $(@:%.o=%.d) $(@:%.o=%.P); \
153           sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
154               -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
155           rm -f $(@:%.o=%.d)
156
157 test_novacoin: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%))
158         $(CXX) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-B$(LMODE) -lboost_unit_test_framework $(LDFLAGS) $(LIBS)
159
160 clean:
161         -rm -f novacoind test_novacoin
162         -rm -f obj/*.o
163         -rm -f obj-test/*.o
164         -rm -f obj/*.P
165         -rm -f obj-test/*.P
166         -rm -f src/build.h
167
168 FORCE: