Add Google's LevelDB support
[novacoin.git] / src / makefile.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 USE_UPNP:=0
6 USE_IPV6:=1
7 USE_LEVELDB:=1
8
9 INCLUDEPATHS= \
10  -I"C:\boost-1.50.0-mgw" \
11  -I"C:\db-4.8.30.NC-mgw\build_unix" \
12  -I"C:\openssl-1.0.1c-mgw\include"
13
14 LIBPATHS= \
15  -L"C:\boost-1.50.0-mgw\stage\lib" \
16  -L"C:\db-4.8.30.NC-mgw\build_unix" \
17  -L"C:\openssl-1.0.1c-mgw"
18
19 LIBS= \
20  -l boost_system-mgw44-mt-1_53 \
21  -l boost_filesystem-mgw44-mt-1_53 \
22  -l boost_program_options-mgw44-mt-1_53 \
23  -l boost_thread-mgw44-mt-1_53 \
24  -l boost_chrono-mgw44-mt-1_53 \
25  -l db_cxx \
26  -l ssl \
27  -l crypto
28
29 DEFS=-DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE
30 DEBUGFLAGS=-g
31 CFLAGS=-mthreads -O2 -msse2 -w -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
32 LDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat
33
34 TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)
35
36 ifndef USE_UPNP
37         override USE_UPNP = -
38 endif
39 ifneq (${USE_UPNP}, -)
40  INCLUDEPATHS += -I"C:\miniupnpc-1.6-mgw"
41  LIBPATHS += -L"C:\miniupnpc-1.6-mgw"
42  LIBS += -l miniupnpc -l iphlpapi
43  DEFS += -DSTATICLIB -DUSE_UPNP=$(USE_UPNP)
44 endif
45
46 ifneq (${USE_IPV6}, -)
47         DEFS += -DUSE_IPV6=$(USE_IPV6)
48 endif
49
50 LIBS += -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
51
52 # TODO: make the mingw builds smarter about dependencies, like the linux/osx builds are
53 HEADERS = $(wildcard *.h)
54
55 OBJS= \
56     obj/alert.o \
57     obj/version.o \
58     obj/checkpoints.o \
59     obj/netbase.o \
60     obj/addrman.o \
61     obj/crypter.o \
62     obj/key.o \
63     obj/db.o \
64     obj/init.o \
65     obj/irc.o \
66     obj/keystore.o \
67     obj/main.o \
68     obj/miner.o \
69     obj/net.o \
70     obj/protocol.o \
71     obj/bitcoinrpc.o \
72     obj/rpcdump.o \
73     obj/rpcnet.o \
74     obj/rpcmining.o \
75     obj/rpcwallet.o \
76     obj/rpcblockchain.o \
77     obj/rpcrawtransaction.o \
78     obj/script.o \
79     obj/sync.o \
80     obj/util.o \
81     obj/wallet.o \
82     obj/walletdb.o \
83     obj/noui.o \
84     obj/kernel.o \
85     obj/pbkdf2.o \
86     obj/scrypt.o \
87     obj/scrypt-x86.o \
88     obj/scrypt-x86_64.o
89
90 all: novacoind.exe
91
92 #
93 # LevelDB support
94 #
95 ifdef USE_LEVELDB
96 LIBS += $(CURDIR)/leveldb/libleveldb.a $(CURDIR)/leveldb/libmemenv.a
97 DEFS += $(addprefix -I,$(CURDIR)/leveldb/include) -DUSE_LEVELDB
98 DEFS += $(addprefix -I,$(CURDIR)/leveldb/helpers)
99 OBJS += obj/txdb-leveldb.o
100 leveldb/libleveldb.a:
101         cd leveldb; make; cd ..
102 obj/txdb-leveldb.o: leveldb/libleveldb.lib
103 else
104 OBJS += obj/txdb-bdb.o
105 endif
106
107
108 test check: test_novacoin.exe FORCE
109         test_novacoin.exe
110
111 obj/%.o: %.cpp $(HEADERS)
112         g++ -c $(CFLAGS) -o $@ $<
113
114 obj/scrypt-x86.o: scrypt-x86.S
115         $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
116
117 obj/scrypt-x86_64.o: scrypt-x86_64.S
118         $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
119
120 novacoind.exe: $(OBJS:obj/%=obj/%)
121         g++ $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)
122
123 TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp))
124
125 obj-test/%.o: test/%.cpp $(HEADERS)
126         g++ -c $(TESTDEFS) $(CFLAGS) -o $@ $<
127
128 test_bitcoin.exe: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%))
129         g++ $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPATHS) $^ -lboost_unit_test_framework $(LIBS)
130
131 clean:
132         -del /Q novacoind test_novacoin
133         -del /Q obj\*
134         -del /Q obj-test\*
135
136 FORCE: