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