3c65af92c89e4f652cb060f36e006ac47f0d957a
[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 MINIUPNPC_LIB_PATH:=$(DEPSDIR)/miniupnpc-1.9
17 OPENSSL_LIB_PATH:=$(DEPSDIR)/openssl-1.0.1h
18
19 BOOST_INCLUDE_PATH:=$(DEPSDIR)/boost_1_57_0
20 BDB_INCLUDE_PATH:=$(DEPSDIR)/db-6.0.20.NC/build_unix
21 MINIUPNPC_INCLUDE_PATH:=$(DEPSDIR)
22 OPENSSL_INCLUDE_PATH:=$(DEPSDIR)/openssl-1.0.1h/include
23
24 USE_UPNP:=0
25 USE_LEVELDB:=0
26 USE_IPV6:=1
27
28 INCLUDEPATHS= \
29  -I"$(CURDIR)" \
30  -I"$(CURDIR)"/obj \
31  -I"$(BOOST_INCLUDE_PATH)" \
32  -I"$(BDB_INCLUDE_PATH)" \
33  -I"$(OPENSSL_INCLUDE_PATH)" \
34  -I"$(MINIUPNPC_INCLUDE_PATH)"
35
36 LIBPATHS= \
37  -L"$(BOOST_LIB_PATH)" \
38  -L"$(BDB_LIB_PATH)" \
39  -L"$(OPENSSL_LIB_PATH)" \
40  -L"$(MINIUPNPC_LIB_PATH)"
41
42 LIBS= \
43  -l boost_system-mt \
44  -l boost_filesystem-mt \
45  -l boost_program_options-mt \
46  -l boost_thread_win32-mt \
47  -l boost_chrono-mt \
48  -l db_cxx \
49  -l ssl \
50  -l crypto \
51  -Wl,-Bstatic -lpthread -Wl,-Bdynamic
52
53 xOPT_LEVEL=-O2
54 ifeq (${USE_O3}, 1)
55     xOPT_LEVEL=-O3
56 endif
57
58 DEFS=-D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
59 DEBUGFLAGS=-g
60 CFLAGS=$(xOPT_LEVEL) -msse2 -w -Wall -Wextra -Wno-ignored-qualifiers -Wformat -Wformat-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
61 LDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat -static-libgcc -static-libstdc++
62
63 ifndef USE_UPNP
64         override USE_UPNP = -
65 endif
66 ifneq (${USE_UPNP}, -)
67         LIBPATHS += -L"$(DEPSDIR)/miniupnpc"
68         LIBS += -l miniupnpc -l iphlpapi
69         DEFS += -DSTATICLIB -DUSE_UPNP=$(USE_UPNP)
70 endif
71
72 ifneq (${USE_IPV6}, -)
73         DEFS += -DUSE_IPV6=$(USE_IPV6)
74 endif
75
76 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
77
78 # TODO: make the mingw builds smarter about dependencies, like the linux/osx builds are
79 HEADERS = $(wildcard *.h)
80
81 OBJS= \
82     obj/alert.o \
83     obj/version.o \
84     obj/checkpoints.o \
85     obj/netbase.o \
86     obj/addrman.o \
87     obj/crypter.o \
88     obj/key.o \
89     obj/db.o \
90     obj/init.o \
91     obj/irc.o \
92     obj/keystore.o \
93     obj/main.o \
94     obj/miner.o \
95     obj/net.o \
96     obj/ntp.o \
97     obj/stun.o \
98     obj/protocol.o \
99     obj/bitcoinrpc.o \
100     obj/rpcdump.o \
101     obj/rpcnet.o \
102     obj/rpcmining.o \
103     obj/rpcwallet.o \
104     obj/rpcblockchain.o \
105     obj/rpcrawtransaction.o \
106     obj/script.o \
107     obj/sync.o \
108     obj/util.o \
109     obj/wallet.o \
110     obj/walletdb.o \
111     obj/noui.o \
112     obj/kernel.o
113
114 all: novacoind.exe
115
116 #
117 # LevelDB support
118 #
119 ifeq (${USE_LEVELDB}, 1)
120 LIBS += $(CURDIR)/leveldb/libleveldb.a $(CURDIR)/leveldb/libmemenv.a
121 DEFS += -I"$(CURDIR)/leveldb/include" -DUSE_LEVELDB
122 DEFS += -I"$(CURDIR)/leveldb/helpers"
123 OBJS += obj/txdb-leveldb.o
124 leveldb/libleveldb.a:
125         @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 ..
126 obj/txdb-leveldb.o: leveldb/libleveldb.a
127 else
128 OBJS += obj/txdb-bdb.o
129 endif
130
131 ifeq (${USE_ASM}, 1)
132 # Assembler implementation
133 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
134
135 crypto/scrypt/asm/obj/scrypt-x86.o: crypto/scrypt/asm/scrypt-x86.S
136         $(CXX) -c $(CFLAGS) -MMD -o $@ $<
137
138 crypto/scrypt/asm/obj/scrypt-x86_64.o: crypto/scrypt/asm/scrypt-x86_64.S
139         $(CXX) -c $(CFLAGS) -MMD -o $@ $<
140
141 crypto/scrypt/asm/obj/scrypt-arm.o: crypto/scrypt/asm/scrypt-arm.S
142         $(CXX) -c $(CFLAGS) -MMD -o $@ $<
143
144 crypto/scrypt/asm/obj/asm-wrapper.o: crypto/scrypt/asm/asm-wrapper.cpp
145         $(CXX) -c $(CFLAGS) -MMD -o $@ $<
146 else
147 ifeq  (${USE_SSE2}, 1)
148 # Intrinsic implementation
149 DEFS += -DUSE_SSE2
150 OBJS += crypto/scrypt/intrin/obj/scrypt-sse2.o
151
152 crypto/scrypt/intrin/obj/scrypt-sse2.o: crypto/scrypt/intrin/scrypt-sse2.cpp $(HEADERS)
153         $(CXX) -c $(CFLAGS) -MMD -o $@ $<
154 else
155 ifneq (${USE_ASM}, 1)
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 endif
164
165
166
167 obj/build.h: FORCE
168         /bin/sh ../share/genbuild.sh obj/build.h
169 version.cpp: obj/build.h
170 DEFS += -DHAVE_BUILD_INFO
171
172 obj/%.o: %.cpp $(HEADERS)
173         $(CXX) -c $(CFLAGS) -o $@ $<
174
175 novacoind.exe: $(OBJS:obj/%=obj/%)
176         $(CXX) $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) -lshlwapi
177         $(STRIP) novacoind.exe
178
179 clean:
180         -rm -f novacoind.exe
181         -rm -f obj/*.o
182         -rm -f obj/*.P
183         -rm -f obj/*.d
184         -rm -f crypto/scrypt/asm/obj/*.o
185         -rm -f crypto/scrypt/asm/obj/*.P
186         -rm -f crypto/scrypt/asm/obj/*.d
187         -rm -f crypto/scrypt/intrin/obj/*.o
188         -rm -f crypto/scrypt/intrin/obj/*.P
189         -rm -f crypto/scrypt/intrin/obj/*.d
190         -rm -f crypto/scrypt/generic/obj/*.o
191         -rm -f crypto/scrypt/generic/obj/*.P
192         -rm -f crypto/scrypt/generic/obj/*.d
193         -rm -f obj/build.h
194         cd leveldb && TARGET_OS=OS_WINDOWS_CROSSCOMPILE $(MAKE) clean && cd ..
195
196 FORCE: