83c048326ca585506f01d0c4838535d931e4a57e
[novacoin.git] / src / makefile.mingw
1 # Copyright (c) 2009-2010 Satoshi Nakamoto
2 # Copyright (c) 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 # Windows commandline build procedure:
7 # - Install MinGW following http://www.mingw.org/wiki/Getting_Started.
8 #   Install with the C++ and MSYS options checked
9 #
10 # - Add/edit 'MAKE' environment variable with value '/c/MinGW32/bin/mingw32-make.exe'
11 #
12 # - Build openssl library version: 1.0.1b
13 #   download from  http://www.openssl.org/source/
14 #   Extract to c:\openssl-1.0.1b-mgw
15 #   In MinGW MSYS:
16 #     ./config
17 #     make
18 #
19 # - Build Berkeley DB library version: 4.8.30.NC
20 #   download from  http://www.oracle.com/technology/software/products/berkeley-db/index.html
21 #   Extract to c:\db-4.8.30.NC-mgw
22 #   In MinGW MSYS:
23 #     cd build_unix
24 #     sh ../dist/configure --disable-replication --enable-mingw --enable-cxx --prefix=/usr/local
25 #   Edit db.h@113 in build_unix
26 #   from
27 #     typedef pthread_t db_threadid_t;
28 #   to 
29 #     typedef u_int32_t db_threadid_t;
30 #   Then
31 #     make
32 #
33 # - Build Boost C++ library version: 1.47.0
34 #   download from http://www.boost.org/users/download/
35 #   Extract to c:\boost-1.47.0-mgw
36 #   Install Boost.Build:
37 #     cd tools\build\v2
38 #     bootstrap.bat
39 #     b2 install --prefix=BOOST_BUILD_INSTALL_DIR
40 #   Add BOOST_BUILD_INSTALL_DIR to your PATH system environment variable
41 #   Build boost library in MSDOS:
42 #     cd c:\boost-1.47.0-mgw
43 #     bjam toolset=gcc --build-type=complete stage
44 #
45 # - Build Miniupnp library version: 1.6
46 #   download from http://miniupnp.free.fr/files/
47 #   file name is miniupnpc-1.6.20120509.tar.gz
48 #   Extract to c:\miniupnpc-1.6-mgw
49 #   In MinGW MSYS shell:
50 #     cd /c/miniupnpc-1.6-mgw
51 #     make -f Makefile.mingw
52 #     mkdir miniupnpc
53 #     cp *.h miniupnpc/
54 #
55 # - Build ppcoind.exe
56 #   in MinGW MSYS
57 #     cd ppcoin/src
58 #     make ppcoind.exe -f makefile.mingw USE_UPNP=1
59 #
60 #
61
62 USE_UPNP:=-
63
64 INCLUDEPATHS= \
65  -I"C:\boost-1.47.0-mgw" \
66  -I"C:\db-4.8.30.NC-mgw\build_unix" \
67  -I"C:\openssl-1.0.1b-mgw\include"
68
69 LIBPATHS= \
70  -L"C:\boost-1.47.0-mgw\stage\lib" \
71  -L"C:\db-4.8.30.NC-mgw\build_unix" \
72  -L"C:\openssl-1.0.1b-mgw"
73
74 LIBS= \
75  -l boost_system-mgw46-mt-s-1_47 \
76  -l boost_filesystem-mgw46-mt-s-1_47 \
77  -l boost_program_options-mgw46-mt-s-1_47 \
78  -l boost_thread-mgw46-mt-s-1_47 \
79  -l db_cxx \
80  -l ssl \
81  -l crypto
82
83 DEFS=-DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE
84 DEBUGFLAGS=-g
85 CFLAGS=-mthreads -O2 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
86
87 TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)
88
89 ifdef USE_UPNP
90  INCLUDEPATHS += -I"C:\miniupnpc-1.6-mgw"
91  LIBPATHS += -L"C:\miniupnpc-1.6-mgw"
92  LIBS += -l miniupnpc -l iphlpapi
93  DEFS += -DSTATICLIB -DUSE_UPNP=$(USE_UPNP)
94 endif
95
96 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 shlwapi
97
98 # TODO: make the mingw builds smarter about dependencies, like the linux/osx builds are
99 HEADERS = $(wildcard *.h)
100
101 OBJS= \
102     obj/version.o \
103     obj/checkpoints.o \
104     obj/netbase.o \
105     obj/addrman.o \
106     obj/crypter.o \
107     obj/key.o \
108     obj/db.o \
109     obj/init.o \
110     obj/irc.o \
111     obj/keystore.o \
112     obj/scrypt_mine.o \
113     obj/scrypt-x86.o \
114     obj/main.o \
115     obj/net.o \
116     obj/protocol.o \
117     obj/bitcoinrpc.o \
118     obj/rpcdump.o \
119     obj/script.o \
120     obj/util.o \
121     obj/wallet.o \
122     obj/walletdb.o \
123     obj/noui.o \
124     obj/pbkdf2.o
125
126 all: novacoind.exe
127
128 obj/%.o: %.cpp $(HEADERS)
129         g++ -c $(CFLAGS) -o $@ $<
130
131 obj/scrypt-x86.o: scrypt-x86.S
132         $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
133
134 obj/scrypt-x86_64.o: scrypt-x86_64.S
135         $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
136
137
138 novacoind.exe: $(OBJS:obj/%=obj/%)
139         g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)
140
141 TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp))
142
143 obj-test/%.o: test/%.cpp $(HEADERS)
144         g++ -c $(TESTDEFS) $(CFLAGS) -o $@ $<
145
146 test_bitcoin.exe: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%))
147         g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ -lboost_unit_test_framework $(LIBS)
148
149 clean:
150         -del /Q novacoind test_bitcoin
151         -del /Q obj\*
152         -del /Q obj-test\*
153         -del /Q build.h