3b8a9d25edda2b9751c32a9608745d5e7a7dfade
[metaproxy-moved-to-github.git] / win / makefile
1 # Copyright (C) 2005-2013 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.4.2
11
12 # YAZ and YAZ++ directories
13 YAZ_DIR=..\..\yaz
14 YAZPP_DIR=..\..\yazpp
15
16 # Boost
17 BOOST=\program files\boost\boost_1_51
18 BOOST_VERSION=1_51
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 # 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 METAPROXY_PROG=$(BINDIR)\metaproxy.exe
66 TEST_PIPE=$(BINDIR)\test_pipe.exe
67
68 # shortcut names defined here
69 metaproxy: $(METAPROXY_PROG)
70 test_pipe: $(TEST_PIPE)
71
72 ###########################################################
73 ############### Compiler and linker options 
74 ###########################################################
75
76 !if $(DEBUG)
77 YAZD=yaz5d
78 YAZPPD=yazpp6d
79 !else
80 YAZD=yaz5
81 YAZPPD=yazpp6
82 !endif
83
84 # YAZ includes & libs
85 YAZ_LIB="$(YAZ_DIR)\lib\$(YAZD).lib"
86 YAZ_DEF=/DYAZ_HAVE_XML2=1 /DYAZ_HAVE_XSLT=1 /DYAZ_USE_NEW_LOG=1 /I"$(YAZ_DIR)\include"
87
88 # Copy yaz.dll to our bin
89 yaz: $(BINDIR)\$(YAZD).dll
90 $(BINDIR)\$(YAZD).dll: "$(YAZ_DIR)\bin\$(YAZD).dll"
91   copy "$(YAZ_DIR)\bin\$(YAZD).dll" $(BINDIR)
92
93 # YAZ++ includes & libs
94 YAZPP_LIB="$(YAZPP_DIR)\lib\$(YAZPPD).lib"
95 YAZPP_DEF=/I"$(YAZPP_DIR)\include"
96
97 # Copy yazpp.dll to our bin
98 yazpp: $(BINDIR)\$(YAZPPD).dll
99 $(BINDIR)\$(YAZPPD).dll: "$(YAZPP_DIR)\bin\$(YAZPPD).dll"
100   copy "$(YAZPP_DIR)\bin\$(YAZPPD).dll" $(BINDIR)
101
102 # Copy libxslt and associates to our bin directory
103 libxslt: $(BINDIR)\libxslt.dll
104
105 $(BINDIR)\libxslt.dll: "$(LIBXSLT_DIR)\bin\libxslt.dll"
106         copy "$(ICONV_DIR)\bin\iconv.dll" $(BINDIR)
107         copy "$(ZLIB_DIR)\bin\zlib1.dll" $(BINDIR)
108         copy "$(LIBXML2_DIR)\bin\libxml2.dll" $(BINDIR)
109         copy "$(LIBXSLT_DIR)\bin\libxslt.dll" $(BINDIR)
110
111 config: $(SRCDIR)\config.hpp
112
113 $(SRCDIR)\config.hpp:
114         echo /*windows*/ >$(SRCDIR)\config.hpp
115
116 # Boost 
117 #
118 !if $(DEBUG)
119 BOOST_LIB_SUFFIX=$(BOOST_TOOLSET)-$(BOOST_MODEL)-gd-$(BOOST_VERSION).lib
120 !else
121 BOOST_LIB_SUFFIX=$(BOOST_TOOLSET)-$(BOOST_MODEL)-$(BOOST_VERSION).lib
122 !endif
123
124 BOOST_DEF = /I"$(BOOST)"
125 BOOST_LIB = \
126              /LIBPATH:"$(BOOST)\lib" \
127     "libboost_thread-$(BOOST_LIB_SUFFIX)"  \
128     "libboost_regex-$(BOOST_LIB_SUFFIX)" \
129     "libboost_date_time-$(BOOST_LIB_SUFFIX)" 
130
131 LIBXSLT_DEF = \
132               /I"$(ICONV_DIR)\include" \
133               /I"$(LIBXML2_DIR)\include" \
134               /I"$(LIBXSLT_DIR)\include"
135
136 LIBXSLT_LIB = \
137     "$(ICONV_DIR)\lib\iconv.lib" \
138     "$(LIBXML2_DIR)\lib\libxml2.lib" \
139     "$(LIBXSLT_DIR)\lib\libxslt.lib"
140
141 COMMON_C_OPTIONS=          \
142   /nologo /W3 /EHsc /FD /c \
143   /D "_CRT_SECURE_NO_DEPRECATE" \
144   $(YAZ_DEF)               \
145   $(YAZPP_DEF)             \
146   $(BOOST_DEF)             \
147   $(LIBXSLT_DEF)           \
148   /D VERSION=\"$(VERSION)\" \
149   /D "_WINDOWS"            \
150   /D "WIN32"               \
151   /FR"$(OBJDIR)\\"         \
152   /Fo"$(OBJDIR)\\"         \
153   /Fd"$(OBJDIR)\\"         \
154   /I"$(ROOTDIR)\include" 
155
156 DEBUG_C_OPTIONS=  \
157   /D "_DEBUG"      \
158   /MDd  /Od /Zi /Gm
159
160 RELEASE_C_OPTIONS=  \
161   /D "NDEBUG"        \
162   /MD /O2
163
164 # /W3  = warning level
165 # /GX  = Enable exception handling
166 # /FD  = Generate file dependencies (what ever they are)
167 # /c   = compile without linking
168 # /FR  = Generate browse info (.sbr file that gets combined into .bsc)
169 # /Fo  = object file name (or at least path)
170 # /Fd  = debug database name (or path)
171 # /MD  = Runtime library: Multithread DLL
172 # /MDd = Runtime library: Multithread DLL (debug)
173 # /Od  = Disable optimising (debug)
174 # /O2  = Optimize for speed
175 # /Gm  = Minimal rebuild (some cpp class stuff)
176 # /Zi  = Program database for debuggers
177 # /ZI  = Pgm database with special "edit&continue" stuff - not available in C5
178
179
180 ### Linker options
181 LINK=link.exe
182
183 LINK_LIBS=kernel32.lib user32.lib gdi32.lib advapi32.lib uuid.lib \
184           wsock32.lib  advapi32.lib \
185           $(YAZ_LIB) $(YAZPP_LIB) $(ICONV_LIB) $(LIBXSLT_LIB) \
186           $(BOOST_LIB) 
187
188 COMMON_LNK_OPTIONS= /nologo /subsystem:windows /incremental:no
189
190 DEBUG_LNK_OPTIONS= /debug 
191
192 RELEASE_LNK_OPTIONS=
193
194 DLL_LINK_OPTIONS= /dll  
195 PROG_LINK_OPTIONS = /subsystem:console  
196
197 # Final opt variables
198 !if $(DEBUG)
199 COPT=   $(COMMON_C_OPTIONS)   $(DEBUG_C_OPTIONS)
200 RCOPT=  $(COMMON_RC_OPTIONS)  $(DEBUG_RC_OPTIONS)
201 LNKOPT= $(COMMON_LNK_OPTIONS) $(DEBUG_LNK_OPTIONS) 
202
203 !else
204 COPT=   $(COMMON_C_OPTIONS)   $(RELEASE_C_OPTIONS) 
205 RCOPT=  $(COMMON_RC_OPTIONS)  $(RELEASE_RC_OPTIONS)
206 LNKOPT= $(COMMON_LNK_OPTIONS) $(RELEASE_LNK_OPTIONS)
207 !endif
208
209 ###########################################################
210 ###############  Source and object modules
211 ###########################################################
212
213 PROJECT_DLL_OBJS = \
214         $(OBJDIR)\factory_filter.obj \
215         $(OBJDIR)\factory_static.obj \
216         $(OBJDIR)\filter.obj \
217         $(OBJDIR)\filter_auth_simple.obj \
218         $(OBJDIR)\filter_backend_test.obj \
219         $(OBJDIR)\filter_bounce.obj \
220         $(OBJDIR)\filter_cql_rpn.obj \
221         $(OBJDIR)\filter_frontend_net.obj \
222         $(OBJDIR)\filter_http_client.obj \
223         $(OBJDIR)\filter_http_file.obj \
224         $(OBJDIR)\filter_http_rewrite.obj \
225         $(OBJDIR)\filter_http_rewrite1.obj \
226         $(OBJDIR)\filter_limit.obj \
227         $(OBJDIR)\filter_load_balance.obj \
228         $(OBJDIR)\filter_log.obj \
229         $(OBJDIR)\filter_multi.obj \
230         $(OBJDIR)\filter_present_chunk.obj \
231         $(OBJDIR)\filter_query_rewrite.obj \
232         $(OBJDIR)\filter_record_transform.obj \
233         $(OBJDIR)\filter_sd_remove.obj \
234         $(OBJDIR)\filter_session_shared.obj \
235         $(OBJDIR)\filter_sort.obj \
236         $(OBJDIR)\filter_sru_to_z3950.obj \
237         $(OBJDIR)\filter_template.obj \
238         $(OBJDIR)\filter_virt_db.obj \
239         $(OBJDIR)\filter_z3950_client.obj \
240         $(OBJDIR)\filter_zeerex_explain.obj \
241         $(OBJDIR)\filter_zoom.obj \
242         $(OBJDIR)\gduutil.obj \
243         $(OBJDIR)\html_parser.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)\router_xml.obj \
251         $(OBJDIR)\session.obj \
252         $(OBJDIR)\sru_util.obj \
253         $(OBJDIR)\thread_pool_observer.obj \
254         $(OBJDIR)\torus.obj \
255         $(OBJDIR)\url_recipe.obj \
256         $(OBJDIR)\util.obj \
257         $(OBJDIR)\xmlutil.obj 
258
259 METAPROXY_OBJS = $(OBJDIR)\metaproxy_prog.obj
260 TEST_PIPE_OBJS = $(OBJDIR)\test_pipe.obj
261
262 ###########################################################
263 ############### Compiling 
264 ###########################################################
265
266 # Note: This defines where to look for the necessary
267 # source files. Funny way of doing it, but it works.
268
269 {$(SRCDIR)}.cpp{$(OBJDIR)}.obj:
270         $(CPP) $(COPT) $< 
271
272 ###########################################################
273 ############### Resources
274 ###########################################################
275
276 ### The RC compiler (resource files)
277 RSC=rc.exe
278 COMMON_RC_OPTIONS= /l 0x406 /i"$(ROOTDIR)" 
279 DEBUG_RC_OPTIONS=/d "_DEBUG"
280 RELEASE_RC_OPTIONS=/d "NDEBUG"
281
282 PROJECT_RES=$(OBJDIR)\metaproxy.res
283 PROJECT_RC=$(WINDIR)\metaproxy.rc
284
285 !if $(DEBUG)
286 RSOPT=/d_DEBUG
287 !else
288 RSOPT=/d_NDEBUG
289 !endif
290
291 $(PROJECT_RES): $(PROJECT_RC)
292         $(RSC) $(RSOPT) /fo"$(PROJECT_RES)" $(PROJECT_RC) 
293
294 ###########################################################
295 ############### Linking
296 ###########################################################
297
298 $(METAPROXY_PROG) : "$(BINDIR)" $(METAPROXY_OBJS) $(PROJECT_DLL_OBJS)
299         $(LINK) \
300                 $(LNKOPT) \
301                 $(PROG_LINK_OPTIONS) \
302                 $(LINK_LIBS) \
303                 $(METAPROXY_OBJS) \
304                 $(PROJECT_DLL_OBJS) \
305                 /out:$(METAPROXY_PROG) 
306
307 $(TEST_PIPE) : "$(BINDIR)" $(TEST_PIPE_OBJS) $(PROJECT_DLL_OBJS)
308         $(LINK) \
309                 $(LNKOPT) \
310                 $(PROG_LINK_OPTIONS) \
311                 $(LINK_LIBS) \
312                 $(PROJECT_DLL_OBJS) \
313                 $(TEST_PIPE_OBJS) \
314                 /out:$(TEST_PIPE)
315
316 ############## clean
317 clean:
318         -del $(BINDIR)\*.exe
319         -del $(BINDIR)\*.dll
320         -del $(TMPDIR)\*.
321         -del $(LIBDIR)\*.LIB
322         -del $(OBJDIR)\*.OBJ
323
324 dirs: $(OBJDIR) $(WINDIR) $(LIBDIR) $(BINDIR) $(TMPDIR)
325
326 $(OBJDIR) $(WINDIR) $(LIBDIR) $(BINDIR) $(TMPDIR):
327         if not exist "$@/$(NUL)" mkdir "$@"
328