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