fc1b93e909b8c7553a9bfc7bff9f5bf03d22aa3b
[novacoin.git] / src / makefile.linux-mingw
1 # Copyright (c) 2009-2010 Satoshi Nakamoto
2 # Distributed under the MIT/X11 software license, see the accompanying
3 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5 TARGET_PLATFORM:=i686
6 #TARGET_PLATFORM:=x86_64
7 CC:=$(TARGET_PLATFORM)-w64-mingw32-gcc
8 CXX:=$(TARGET_PLATFORM)-w64-mingw32-g++
9 RANLIB:=$(TARGET_PLATFORM)-w64-mingw32-ranlib
10 STRIP:=$(TARGET_PLATFORM)-w64-mingw32-strip
11
12 DEPSDIR:=/usr/$(TARGET_PLATFORM)-w64-mingw32
13
14 BOOST_LIB_PATH:=$(DEPSDIR)/boost_1_57_0/stage/lib
15 BDB_LIB_PATH:=$(DEPSDIR)/db-6.0.20.NC/build_unix
16 OPENSSL_LIB_PATH:=$(DEPSDIR)/openssl-1.0.1h
17
18 BOOST_INCLUDE_PATH:=$(DEPSDIR)/boost_1_57_0
19 BDB_INCLUDE_PATH:=$(DEPSDIR)/db-6.0.20.NC/build_unix
20 OPENSSL_INCLUDE_PATH:=$(DEPSDIR)/openssl-1.0.1h/include
21
22 USE_LEVELDB:=0
23 USE_IPV6:=1
24
25 INCLUDEPATHS= \
26  -I"$(CURDIR)" \
27  -I"$(CURDIR)"/obj \
28  -I"$(BOOST_INCLUDE_PATH)" \
29  -I"$(BDB_INCLUDE_PATH)" \
30  -I"$(OPENSSL_INCLUDE_PATH)"
31
32 LIBPATHS= \
33  -L"$(BOOST_LIB_PATH)" \
34  -L"$(BDB_LIB_PATH)" \
35  -L"$(OPENSSL_LIB_PATH)"
36
37 LIBS= \
38  -l boost_system-mt \
39  -l boost_filesystem-mt \
40  -l boost_program_options-mt \
41  -l boost_thread_win32-mt \
42  -l boost_chrono-mt \
43  -l db_cxx \
44  -l ssl \
45  -l crypto \
46  -Wl,-Bstatic -lpthread -Wl,-Bdynamic
47
48 xOPT_LEVEL=-O2
49 ifeq (${USE_O3}, 1)
50     xOPT_LEVEL=-O3
51 endif
52
53 DEFS=-D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
54
55 DEBUGFLAGS=-g
56 CFLAGS=$(xOPT_LEVEL) -msse2 -mssse3 -w -Wall -Wextra -Wno-ignored-qualifiers -Wformat -Wformat-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
57 LDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat -static-libgcc -static-libstdc++
58
59 ifneq (${USE_IPV6}, -)
60         DEFS += -DUSE_IPV6=$(USE_IPV6)
61 endif
62
63 LIBS += -l mingwthrd -l kernel32 -l user32 -l gdi32 -l comdlg32 -l winspool -l winmm -l shell32 -l comctl32 -l ole32 -l oleaut32 -l uuid -l rpcrt4 -l advapi32 -l ws2_32 -l mswsock -l shlwapi
64
65 # TODO: make the mingw builds smarter about dependencies, like the linux/osx builds are
66 HEADERS = $(wildcard *.h)
67
68 OBJS= \
69     obj/alert.o \
70     obj/version.o \
71     obj/checkpoints.o \
72     obj/netbase.o \
73     obj/addrman.o \
74     obj/crypter.o \
75     obj/key.o \
76     obj/db.o \
77     obj/init.o \
78     obj/irc.o \
79     obj/keystore.o \
80     obj/main.o \
81     obj/miner.o \
82     obj/net.o \
83     obj/ntp.o \
84     obj/stun.o \
85     obj/protocol.o \
86     obj/bitcoinrpc.o \
87     obj/rpcdump.o \
88     obj/rpcnet.o \
89     obj/rpcmining.o \
90     obj/rpcwallet.o \
91     obj/rpcblockchain.o \
92     obj/rpcrawtransaction.o \
93     obj/script.o \
94     obj/sync.o \
95     obj/util.o \
96     obj/wallet.o \
97     obj/walletdb.o \
98     obj/noui.o \
99     obj/kernel.o
100
101 all: novacoind.exe
102
103 #
104 # LevelDB support
105 #
106 ifeq (${USE_LEVELDB}, 1)
107 LIBS += $(CURDIR)/leveldb/libleveldb.a $(CURDIR)/leveldb/libmemenv.a
108 DEFS += -I"$(CURDIR)/leveldb/include" -DUSE_LEVELDB
109 DEFS += -I"$(CURDIR)/leveldb/helpers"
110 OBJS += obj/txdb-leveldb.o
111 leveldb/libleveldb.a:
112         @echo "Building LevelDB ..." && cd leveldb && CC=$(CC) CXX=$(CXX) TARGET_OS=OS_WINDOWS_CROSSCOMPILE CXXFLAGS="-I$(INCLUDEPATHS)" LDFLAGS="-L$(LIBPATHS)" $(MAKE) libleveldb.a libmemenv.a && $(RANLIB) libleveldb.a && $(RANLIB) libmemenv.a && cd ..
113 obj/txdb-leveldb.o: leveldb/libleveldb.a
114 else
115 OBJS += obj/txdb-bdb.o
116 endif
117
118 ifeq (${USE_ASM}, 1)
119 # Assembler implementation
120 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
121 OBJS += crypto/sha2/asm/obj/sha2-arm.o crypto/sha2/asm/obj/sha2-x86.o crypto/sha2/asm/obj/sha2-x86_64.o
122
123 crypto/scrypt/asm/obj/scrypt-x86.o: crypto/scrypt/asm/scrypt-x86.S
124         $(CXX) -c $(CFLAGS) -MMD -o $@ $<
125
126 crypto/scrypt/asm/obj/scrypt-x86_64.o: crypto/scrypt/asm/scrypt-x86_64.S
127         $(CXX) -c $(CFLAGS) -MMD -o $@ $<
128
129 crypto/scrypt/asm/obj/scrypt-arm.o: crypto/scrypt/asm/scrypt-arm.S
130         $(CXX) -c $(CFLAGS) -MMD -o $@ $<
131
132 crypto/scrypt/asm/obj/asm-wrapper.o: crypto/scrypt/asm/asm-wrapper.cpp
133         $(CXX) -c $(CFLAGS) -MMD -o $@ $<
134
135 crypto/sha2/asm/obj/sha2-x86.o: crypto/sha2/asm/sha2-x86.S
136         $(CXX) -c $(CFLAGS) -MMD -o $@ $<
137
138 crypto/sha2/asm/obj/sha2-x86_64.o: crypto/sha2/asm/sha2-x86_64.S
139         $(CXX) -c $(CFLAGS) -MMD -o $@ $<
140
141 crypto/sha2/asm/obj/sha2-arm.o: crypto/sha2/asm/sha2-arm.S
142         $(CXX) -c $(CFLAGS) -MMD -o $@ $<
143
144 DEFS += -DUSE_ASM
145 else
146 ifeq  (${USE_SSE2}, 1)
147 # Intrinsic implementation
148 DEFS += -DUSE_SSE2
149 OBJS += crypto/scrypt/intrin/obj/scrypt-sse2.o
150
151 crypto/scrypt/intrin/obj/scrypt-sse2.o: crypto/scrypt/intrin/scrypt-sse2.cpp $(HEADERS)
152         $(CXX) -c $(CFLAGS) -MMD -o $@ $<
153 else
154 ifneq (${USE_ASM}, 1)
155 # Generic implementation
156 OBJS += crypto/scrypt/generic/obj/scrypt-generic.o
157
158 crypto/scrypt/generic/obj/scrypt-generic.o: crypto/scrypt/generic/scrypt-generic.cpp
159         $(CXX) -c $(CFLAGS) -MMD -o $@ $<
160 endif
161 endif
162 endif
163
164
165
166 obj/build.h: FORCE
167         /bin/sh ../share/genbuild.sh obj/build.h
168 version.cpp: obj/build.h
169 DEFS += -DHAVE_BUILD_INFO
170
171 obj/%.o: %.cpp $(HEADERS)
172         $(CXX) -c $(CFLAGS) -o $@ $<
173
174 novacoind.exe: $(OBJS:obj/%=obj/%)
175         $(CXX) $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) -lshlwapi
176         $(STRIP) novacoind.exe
177
178 clean:
179         -rm -f novacoind.exe
180         -rm -f obj/*.o
181         -rm -f obj/*.P
182         -rm -f obj/*.d
183         -rm -f crypto/scrypt/asm/obj/*.o
184         -rm -f crypto/scrypt/asm/obj/*.P
185         -rm -f crypto/scrypt/asm/obj/*.d
186         -rm -f crypto/scrypt/intrin/obj/*.o
187         -rm -f crypto/scrypt/intrin/obj/*.P
188         -rm -f crypto/scrypt/intrin/obj/*.d
189         -rm -f crypto/scrypt/generic/obj/*.o
190         -rm -f crypto/scrypt/generic/obj/*.P
191         -rm -f crypto/scrypt/generic/obj/*.d
192         -rm -f crypto/sha2/asm/obj/*.o
193         -rm -f crypto/sha2/asm/obj/*.P
194         -rm -f crypto/sha2/asm/obj/*.d
195         -rm -f obj/build.h
196         cd leveldb && TARGET_OS=OS_WINDOWS_CROSSCOMPILE $(MAKE) clean && cd ..
197
198 FORCE: