Updated makefile for VS 2008 + Boost 1.35.
[metaproxy-moved-to-github.git] / win / makefile
1 # Copyright (C) 2005-2008, Index Data ApS
2 # All rights reserved.
3 # $Id: makefile,v 1.37 2008-02-29 15:25:20 adam Exp $
4
5 # MS NMAKE makefile for metaproxy
6
7 # Parameters that we customize often.
8 DEBUG=0   # 0 for release, 1 for debug
9
10 # Metaproxy version
11 VERSION=1.0.15
12
13 # YAZ and YAZ++ directories
14 YAZ_DIR=..\..\yaz
15 YAZPP_DIR=..\..\yazpp
16
17 # Boost
18 BOOST=\program files\boost\boost_1_35_0
19 BOOST_VERSION=1_35
20 BOOST_TOOLSET=vc90 # vc90 for VS2008, vc80 for VS 2005, vc71 for 2003
21 BOOST_MODEL=mt
22
23 # libxml2 + libxslt + associates
24 ZLIB_DIR=\zlib-1.2.3.win32
25 ICONV_DIR=\iconv-1.9.2.win32
26 LIBXML2_DIR=\libxml2-2.7.1.win32
27 LIBXSLT_DIR=\libxslt-1.1.24.win32
28
29 # The targets
30
31 default: all
32
33 all: dirs config yaz yazpp libxslt progs
34
35 progs: metaproxy ex_filter_frontend_net # test_pipe does not work
36 NSIS="c:\program files\nsis\makensis.exe"
37
38 nsis: all
39         $(NSIS) metaproxy.nsi
40
41 # Directories
42 # The current directory is supposed to be something like
43 # ..../yaz/win, everything is relative to that
44 ROOTDIR=..   # The home of our project
45
46 INCLDIR=$(ROOTDIR)\include  # our includes
47 LIBDIR=$(ROOTDIR)\lib       # We produce .lib, .exp etc there
48 BINDIR=$(ROOTDIR)\bin       # We produce exes and dlls there
49 WINDIR=$(ROOTDIR)\win       # all these Win make things
50 SRCDIR=$(ROOTDIR)\src       # for the case we move them under src
51
52 !if $(DEBUG)
53 OBJDIR=$(WINDIR)\dobj       # where we store intermediate files
54 !else
55 OBJDIR=$(WINDIR)\obj        # where we store intermediate files
56 !endif
57
58 TMPDIR=$(ROOTDIR)\win\tmp
59 TMP=$(TMPDIR)
60
61
62 ##########################################################
63 ############### Targets - what to make
64 ###########################################################
65
66 EX_FILTER_FRONTEND_NET=$(BINDIR)\ex_filter_frontend_net.exe
67 METAPROXY_PROG=$(BINDIR)\metaproxy.exe
68 TEST_PIPE=$(BINDIR)\test_pipe.exe
69
70 # shortcut names defined here
71 ex_filter_frontend_net: $(EX_FILTER_FRONTEND_NET)
72 metaproxy: $(METAPROXY_PROG)
73 test_pipe: $(TEST_PIPE)
74
75 ###########################################################
76 ############### Compiler and linker options 
77 ###########################################################
78
79 !if $(DEBUG)
80 YAZD=yaz3d
81 YAZPPD=yazpp3d
82 !else
83 YAZD=yaz3
84 YAZPPD=yazpp3
85 !endif
86
87 # YAZ includes & libs
88 YAZ_LIB="$(YAZ_DIR)\lib\$(YAZD).lib"
89 YAZ_DEF=/DYAZ_HAVE_XML2=1 /DYAZ_HAVE_XSLT=1 /DYAZ_USE_NEW_LOG=1 /I"$(YAZ_DIR)\include"
90
91 # Copy yaz.dll to our bin
92 yaz: $(BINDIR)\$(YAZD).dll
93 $(BINDIR)\$(YAZD).dll: "$(YAZ_DIR)\bin\$(YAZD).dll"
94   copy "$(YAZ_DIR)\bin\$(YAZD).dll" $(BINDIR)
95
96 # YAZ++ includes & libs
97 YAZPP_LIB="$(YAZPP_DIR)\lib\$(YAZPPD).lib"
98 YAZPP_DEF=/I"$(YAZPP_DIR)\include"
99
100 # Copy yazpp.dll to our bin
101 yazpp: $(BINDIR)\$(YAZPPD).dll
102 $(BINDIR)\$(YAZPPD).dll: "$(YAZPP_DIR)\bin\$(YAZPPD).dll"
103   copy "$(YAZPP_DIR)\bin\$(YAZPPD).dll" $(BINDIR)
104
105 # Copy libxslt and associates to our bin directory
106 libxslt: $(BINDIR)\libxslt.dll
107
108 $(BINDIR)\libxslt.dll: "$(LIBXSLT_DIR)\bin\libxslt.dll"
109         copy "$(ICONV_DIR)\bin\iconv.dll" $(BINDIR)
110         copy "$(ZLIB_DIR)\bin\zlib1.dll" $(BINDIR)
111         copy "$(LIBXML2_DIR)\bin\libxml2.dll" $(BINDIR)
112         copy "$(LIBXSLT_DIR)\bin\libxslt.dll" $(BINDIR)
113
114 config: $(SRCDIR)\config.hpp
115
116 $(SRCDIR)\config.hpp:
117         echo /*windows*/ >$(SRCDIR)\config.hpp
118
119 # Boost 
120 #
121 !if $(DEBUG)
122 BOOST_LIB_SUFFIX=$(BOOST_TOOLSET)-$(BOOST_MODEL)-gd-$(BOOST_VERSION).lib
123 !else
124 BOOST_LIB_SUFFIX=$(BOOST_TOOLSET)-$(BOOST_MODEL)-$(BOOST_VERSION).lib
125 !endif
126
127 BOOST_DEF = /I"$(BOOST)"
128 BOOST_LIB = \
129     "$(BOOST)\lib\libboost_date_time-$(BOOST_LIB_SUFFIX)" \
130     "$(BOOST)\lib\libboost_thread-$(BOOST_LIB_SUFFIX)"  
131
132 #"$(BOOST)\lib\libboost_program_options-$(BOOST_LIB_SUFFIX)" \
133 # "$(BOOST)\lib\libboost_unit_test_framework-$(BOOST_LIB_SUFFIX)"
134
135
136 LIBXSLT_DEF = \
137               /I"$(ICONV_DIR)\include" \
138               /I"$(LIBXML2_DIR)\include" \
139               /I"$(LIBXSLT_DIR)\include"
140
141 LIBXSLT_LIB = \
142     "$(ICONV_DIR)\lib\iconv.lib" \
143     "$(LIBXML2_DIR)\lib\libxml2.lib" \
144     "$(LIBXSLT_DIR)\lib\libxslt.lib"
145
146 COMMON_C_OPTIONS=          \
147   /nologo /W3 /EHsc /FD /c \
148   /D "_CRT_SECURE_NO_DEPRECATE" \
149   $(YAZ_DEF)               \
150   $(YAZPP_DEF)             \
151   $(BOOST_DEF)             \
152   $(LIBXSLT_DEF)           \
153   /D VERSION=\"$(VERSION)\" \
154   /D "_WINDOWS"            \
155   /D "WIN32"               \
156   /FR"$(OBJDIR)\\"         \
157   /Fo"$(OBJDIR)\\"         \
158   /Fd"$(OBJDIR)\\"         \
159   /I"$(ROOTDIR)\include" 
160
161 DEBUG_C_OPTIONS=  \
162   /D "_DEBUG"      \
163   /MDd  /Od /Zi /Gm
164
165 RELEASE_C_OPTIONS=  \
166   /D "NDEBUG"        \
167   /MD /O2
168
169 # /W3  = warning level
170 # /GX  = Enable exception handling
171 # /FD  = Generate file dependencies (what ever they are)
172 # /c   = compile without linking
173 # /FR  = Generate browse info (.sbr file that gets combined into .bsc)
174 # /Fo  = object file name (or at least path)
175 # /Fd  = debug database name (or path)
176 # /MD  = Runtime library: Multithread DLL
177 # /MDd = Runtime library: Multithread DLL (debug)
178 # /Od  = Disable optimising (debug)
179 # /O2  = Optimize for speed
180 # /Gm  = Minimal rebuild (some cpp class stuff)
181 # /Zi  = Program database for debuggers
182 # /ZI  = Pgm database with special "edit&continue" stuff - not available in C5
183
184
185 ### Linker options
186 LINK=link.exe
187
188 LINK_LIBS=kernel32.lib user32.lib gdi32.lib advapi32.lib uuid.lib \
189           wsock32.lib  advapi32.lib \
190           $(BOOST_LIB) \
191           $(YAZ_LIB) $(YAZPP_LIB) $(ICONV_LIB) $(LIBXSLT_LIB) \
192           $(BOOST_LIB) 
193
194 COMMON_LNK_OPTIONS= /nologo \
195                   /subsystem:windows \
196                   /machine:i386 \
197                   /incremental:no
198
199 DEBUG_LNK_OPTIONS= /debug 
200
201 RELEASE_LNK_OPTIONS=
202
203 DLL_LINK_OPTIONS= /dll  
204 PROG_LINK_OPTIONS = /subsystem:console  
205
206 # Final opt variables
207 !if $(DEBUG)
208 COPT=   $(COMMON_C_OPTIONS)   $(DEBUG_C_OPTIONS)
209 RCOPT=  $(COMMON_RC_OPTIONS)  $(DEBUG_RC_OPTIONS)
210 LNKOPT= $(COMMON_LNK_OPTIONS) $(DEBUG_LNK_OPTIONS) 
211
212 !else
213 COPT=   $(COMMON_C_OPTIONS)   $(RELEASE_C_OPTIONS) 
214 RCOPT=  $(COMMON_RC_OPTIONS)  $(RELEASE_RC_OPTIONS)
215 LNKOPT= $(COMMON_LNK_OPTIONS) $(RELEASE_LNK_OPTIONS)
216 !endif
217
218 ###########################################################
219 ###############  Source and object modules
220 ###########################################################
221
222 PROJECT_DLL_OBJS = \
223         $(OBJDIR)\factory_filter.obj \
224         $(OBJDIR)\factory_static.obj \
225         $(OBJDIR)\filter.obj \
226         $(OBJDIR)\filter_auth_simple.obj \
227         $(OBJDIR)\filter_backend_test.obj \
228         $(OBJDIR)\filter_bounce.obj \
229         $(OBJDIR)\filter_cql_to_rpn.obj \
230         $(OBJDIR)\filter_frontend_net.obj \
231         $(OBJDIR)\filter_http_file.obj \
232         $(OBJDIR)\filter_load_balance.obj \
233         $(OBJDIR)\filter_log.obj \
234         $(OBJDIR)\filter_multi.obj \
235         $(OBJDIR)\filter_query_rewrite.obj \
236         $(OBJDIR)\filter_record_transform.obj \
237         $(OBJDIR)\filter_session_shared.obj \
238         $(OBJDIR)\filter_sru_to_z3950.obj \
239         $(OBJDIR)\filter_template.obj \
240         $(OBJDIR)\filter_virt_db.obj \
241         $(OBJDIR)\filter_z3950_client.obj \
242         $(OBJDIR)\filter_zeerex_explain.obj \
243         $(OBJDIR)\gduutil.obj \
244         $(OBJDIR)\origin.obj \
245         $(OBJDIR)\package.obj \
246         $(OBJDIR)\pipe.obj \
247         $(OBJDIR)\plainfile.obj \
248         $(OBJDIR)\router_chain.obj \
249         $(OBJDIR)\router_flexml.obj \
250         $(OBJDIR)\session.obj \
251         $(OBJDIR)\sru_util.obj \
252         $(OBJDIR)\thread_pool_observer.obj \
253         $(OBJDIR)\util.obj \
254         $(OBJDIR)\xmlutil.obj 
255
256 EX_FILTER_FRONTEND_NET_OBJS = $(OBJDIR)\ex_filter_frontend_net.obj
257 METAPROXY_OBJS = $(OBJDIR)\metaproxy_prog.obj
258 TEST_PIPE_OBJS = $(OBJDIR)\test_pipe.obj
259
260 ###########################################################
261 ############### Compiling 
262 ###########################################################
263
264 # Note: This defines where to look for the necessary
265 # source files. Funny way of doing it, but it works.
266
267 {$(SRCDIR)}.cpp{$(OBJDIR)}.obj:
268         $(CPP) $(COPT) $< 
269
270 ###########################################################
271 ############### Resources
272 ###########################################################
273
274 ### The RC compiler (resource files)
275 RSC=rc.exe
276 COMMON_RC_OPTIONS= /l 0x406 /i"$(ROOTDIR)" 
277 DEBUG_RC_OPTIONS=/d "_DEBUG"
278 RELEASE_RC_OPTIONS=/d "NDEBUG"
279
280 PROJECT_RES=$(OBJDIR)\metaproxy.res
281 PROJECT_RC=$(WINDIR)\metaproxy.rc
282
283 !if $(DEBUG)
284 RSOPT=/d_DEBUG
285 !else
286 RSOPT=/d_NDEBUG
287 !endif
288
289 $(PROJECT_RES): $(PROJECT_RC)
290         $(RSC) $(RSOPT) /fo"$(PROJECT_RES)" $(PROJECT_RC) 
291
292 ###########################################################
293 ############### Linking
294 ###########################################################
295
296 $(EX_FILTER_FRONTEND_NET) : "$(BINDIR)" $(EX_FILTER_FRONTEND_NET_OBJS) $(PROJECT_DLL_OBJS)
297         $(LINK) \
298                 $(LNKOPT) \
299                 $(PROG_LINK_OPTIONS) \
300                 $(LINK_LIBS) \
301                 $(PROJECT_DLL_OBJS) \
302                 $(EX_FILTER_FRONTEND_NET_OBJS) \
303                 /out:$(EX_FILTER_FRONTEND_NET) 
304
305 $(METAPROXY_PROG) : "$(BINDIR)" $(METAPROXY_OBJS) $(PROJECT_DLL_OBJS)
306         $(LINK) \
307                 $(LNKOPT) \
308                 $(PROG_LINK_OPTIONS) \
309                 $(LINK_LIBS) \
310                 $(METAPROXY_OBJS) \
311                 $(PROJECT_DLL_OBJS) \
312                 /out:$(METAPROXY_PROG) 
313
314 $(TEST_PIPE) : "$(BINDIR)" $(TEST_PIPE_OBJS) $(PROJECT_DLL_OBJS)
315         $(LINK) \
316                 $(LNKOPT) \
317                 $(PROG_LINK_OPTIONS) \
318                 $(LINK_LIBS) \
319                 $(PROJECT_DLL_OBJS) \
320                 $(TEST_PIPE_OBJS) \
321                 /out:$(TEST_PIPE)
322
323 ############## clean
324 clean:
325         -del $(BINDIR)\*.exe
326         -del $(BINDIR)\*.dll
327         -del $(TMPDIR)\*.
328         -del $(LIBDIR)\*.LIB
329         -del $(OBJDIR)\*.OBJ
330
331 dirs: $(OBJDIR) $(WINDIR) $(LIBDIR) $(BINDIR) $(TMPDIR)
332
333 $(OBJDIR) $(WINDIR) $(LIBDIR) $(BINDIR) $(TMPDIR):
334         if not exist "$@/$(NUL)" mkdir "$@"
335