Various Makefile fixes:
[novacoin.git] / src / makefile.osx
1 # -*- mode: Makefile; -*-
2 # Copyright (c) 2011 Bitcoin Developers
3 # Distributed under the MIT/X11 software license, see the accompanying
4 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6 # Mac OS X makefile for bitcoin
7 # Originally by Laszlo Hanyecz (solar@heliacal.net)
8
9 CXX=llvm-g++
10 DEPSDIR=/opt/local
11
12 INCLUDEPATHS= \
13  -I"$(CURDIR)" \
14  -I"$(CURDIR)"/obj \
15  -I"$(DEPSDIR)/include" \
16  -I"$(DEPSDIR)/include/db48"
17
18 LIBPATHS= \
19  -L"$(DEPSDIR)/lib" \
20  -L"$(DEPSDIR)/lib/db48"
21
22 USE_UPNP:=0
23 USE_LEVELDB:=0
24 USE_IPV6:=1
25
26 LIBS= -dead_strip
27
28 ifdef STATIC
29 # Build STATIC if you are redistributing the bitcoind binary
30 LIBS += \
31  $(DEPSDIR)/lib/db48/libdb_cxx-4.8.a \
32  $(DEPSDIR)/lib/libboost_system-mt.a \
33  $(DEPSDIR)/lib/libboost_filesystem-mt.a \
34  $(DEPSDIR)/lib/libboost_program_options-mt.a \
35  $(DEPSDIR)/lib/libboost_thread-mt.a \
36  $(DEPSDIR)/lib/libssl.a \
37  $(DEPSDIR)/lib/libcrypto.a \
38  -lz
39 else
40 LIBS += \
41  -ldb_cxx-4.8 \
42  -lboost_system-mt \
43  -lboost_filesystem-mt \
44  -lboost_program_options-mt \
45  -lboost_thread-mt \
46  -lssl \
47  -lcrypto \
48  -lz
49 endif
50
51 DEFS=-DMAC_OSX -DMSG_NOSIGNAL=0 -DBOOST_SPIRIT_THREADSAFE -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
52
53 ifdef RELEASE
54 # Compile for maximum compatibility and smallest size.
55 # This requires that dependencies are compiled
56 # the same way.
57 CFLAGS = -O2 -msse2
58 else
59 CFLAGS = -g -msse2
60 endif
61
62 # ppc doesn't work because we don't support big-endian
63 CFLAGS += -Wall -Wextra -Wformat -Wno-ignored-qualifiers -Wformat-security -Wno-unused-parameter \
64     $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
65
66 OBJS= \
67     obj/alert.o \
68     obj/version.o \
69     obj/checkpoints.o \
70     obj/netbase.o \
71     obj/addrman.o \
72     obj/crypter.o \
73     obj/key.o \
74     obj/db.o \
75     obj/init.o \
76     obj/irc.o \
77     obj/keystore.o \
78     obj/main.o \
79     obj/miner.o \
80     obj/net.o \
81     obj/ntp.o \
82     obj/stun.o \
83     obj/protocol.o \
84     obj/bitcoinrpc.o \
85     obj/rpcdump.o \
86     obj/rpcnet.o \
87     obj/rpcmining.o \
88     obj/rpcwallet.o \
89     obj/rpcblockchain.o \
90     obj/rpcrawtransaction.o \
91     obj/script.o \
92     obj/sync.o \
93     obj/util.o \
94     obj/wallet.o \
95     obj/walletdb.o \
96     obj/noui.o \
97     obj/kernel.o
98
99 ifndef USE_UPNP
100         override USE_UPNP = -
101 endif
102 ifneq (${USE_UPNP}, -)
103         DEFS += -DUSE_UPNP=$(USE_UPNP)
104 ifdef STATIC
105         LIBS += $(DEPSDIR)/lib/libminiupnpc.a
106 else
107         LIBS += -lminiupnpc
108 endif
109 endif
110
111 ifneq (${USE_IPV6}, -)
112         DEFS += -DUSE_IPV6=$(USE_IPV6)
113 endif
114
115 all: novacoind
116
117 #
118 # LevelDB support
119 #
120 ifdef USE_LEVELDB
121 LIBS += $(CURDIR)/leveldb/libleveldb.a $(CURDIR)/leveldb/libmemenv.a
122 DEFS += $(addprefix -I,$(CURDIR)/leveldb/include) -DUSE_LEVELDB
123 DEFS += $(addprefix -I,$(CURDIR)/leveldb/helpers)
124 OBJS += obj/txdb-leveldb.o
125 leveldb/libleveldb.a:
126         @echo "Building LevelDB ..."; cd leveldb; make; cd ..
127 obj/txdb-leveldb.o: leveldb/libleveldb.a
128 else
129 OBJS += obj/txdb-bdb.o
130 endif
131
132 ifeq (${USE_ASM}, 1)
133 # Assembler implementation
134 OBJS += crypto/scrypt/asm/obj/scrypt-arm.o crypto/scrypt/asm/obj/scrypt-x86.o crypto/scrypt/asm/obj/scrypt-x86_64.o crypto/scrypt/asm/obj/asm-wrapper.o
135
136 crypto/scrypt/asm/obj/scrypt-x86.o: crypto/scrypt/asm/scrypt-x86.S
137         $(CXX) -c $(CFLAGS) -MMD -o $@ $<
138
139 crypto/scrypt/asm/obj/scrypt-x86_64.o: crypto/scrypt/asm/scrypt-x86_64.S
140         $(CXX) -c $(CFLAGS) -MMD -o $@ $<
141
142 crypto/scrypt/asm/obj/scrypt-arm.o: crypto/scrypt/asm/scrypt-arm.S
143         $(CXX) -c $(CFLAGS) -MMD -o $@ $<
144
145 crypto/scrypt/asm/obj/asm-wrapper.o: crypto/scrypt/asm/asm-wrapper.cpp
146         $(CXX) -c $(CFLAGS) -MMD -o $@ $<
147 else
148 ifeq  (${USE_SSE2}, 1)
149 # Intrinsic implementation
150 DEFS += -DUSE_SSE2
151 OBJS += crypto/scrypt/intrin/obj/scrypt-sse2.o
152
153 crypto/scrypt/intrin/obj/scrypt-sse2.o: crypto/scrypt/intrin/scrypt-sse2.cpp
154         $(CXX) -c $(CFLAGS) -MMD -o $@ $<
155 else
156 # Generic implementation
157 OBJS += crypto/scrypt/generic/obj/scrypt-generic.o
158
159 crypto/scrypt/generic/obj/scrypt-generic.o: crypto/scrypt/generic/scrypt-generic.cpp
160         $(CXX) -c $(CFLAGS) -MMD -o $@ $<
161 endif
162 endif
163
164
165 # auto-generated dependencies:
166 -include obj/*.P
167
168 obj/build.h: FORCE
169         /bin/sh ../share/genbuild.sh obj/build.h
170 version.cpp: obj/build.h
171 DEFS += -DHAVE_BUILD_INFO
172
173 obj/%.o: %.cpp
174         $(CXX) -c $(CFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $<
175         @cp $(@:%.o=%.d) $(@:%.o=%.P); \
176           sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
177               -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
178           rm -f $(@:%.o=%.d)
179
180 novacoind: $(OBJS:obj/%=obj/%)
181         $(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)
182
183 clean:
184         -rm -f novacoind
185         -rm -f obj/*.o
186         -rm -f obj/*.P
187         -rm -f obj/*.d
188         -rm -f crypto/scrypt/asm/obj/*.o
189         -rm -f crypto/scrypt/asm/obj/*.P
190         -rm -f crypto/scrypt/asm/obj/*.d
191         -rm -f crypto/scrypt/intrin/obj/*.o
192         -rm -f crypto/scrypt/intrin/obj/*.P
193         -rm -f crypto/scrypt/intrin/obj/*.d
194         -rm -f crypto/scrypt/generic/obj/*.o
195         -rm -f crypto/scrypt/generic/obj/*.P
196         -rm -f crypto/scrypt/generic/obj/*.d
197         -rm -f obj/build.h
198
199 FORCE: