Update for VS 2005
[yazproxy-moved-to-github.git] / win / makefile
1 # Copyright (C) 1993-2006, Index Data ApS
2 # All rights reserved.
3 # $Id: makefile,v 1.7 2006-04-30 13:20:47 adam Exp $
4
5 ###########################################################
6 ############### Parameters 
7 ###########################################################
8
9 DEBUG=0   # 0 for release, 1 for debug
10
11 # YAZ and YAZ++
12 YAZ_DIR=..\..\yaz
13 YAZPP_DIR=..\..\yazpp
14
15 # iconv charcter conversion utility
16 HAVE_ICONV=1
17 ICONV_DIR = c:\iconv-1.9.1.win32
18
19 # libxslt
20 HAVE_LIBXSLT=1
21 LIBXSLT_DIR=c:\libxslt-1.1.14.win32
22
23 # libxml2 (used by libxslt)
24 HAVE_LIBXML2=1
25 LIBXML2_DIR=c:\libxml2-2.6.20.win32
26
27 # zlib compression (used by libxml2)
28 ZLIB_DIR = c:\zlib-1.2.3.win32
29
30 # get WIN32 binaries for libxslt, libxml, iconv, zlib from here:
31 # http://www.zlatkovic.com/libxml.en.html
32
33 default: all
34
35 all: dirs dll proxy iconv libxml2 libxslt yaz yazpp
36
37 NSIS="c:\program files\nsis\makensis-bz2.exe"
38
39 nsis: all
40         $(NSIS) yazpp.nsi
41
42 nsishelp:
43         $(NSIS)
44
45 ###########################################################
46 ############### Directories
47 ###########################################################
48 # The current directory is supposed to be something like
49 # ..../yaz/win, everything is relative to that
50 ROOTDIR=..   # The home of yaz++
51
52 INCLDIR=$(ROOTDIR)\include  # our includes
53 LIBDIR=$(ROOTDIR)\lib       # We produce .lib, .exp etc there
54 BINDIR=$(ROOTDIR)\bin       # We produce exes and dlls there
55 WINDIR=$(ROOTDIR)\win       # all these Win make things
56 OBJDIR=$(WINDIR)\obj        # where we store intermediate files
57 SRCDIR=$(ROOTDIR)\src       # for the case we move them under src
58 PROXYDIR=$(ROOTDIR)\proxy
59 ZOOMDIR=$(ROOTDIR)\zoom
60
61 TMPDIR=$(ROOTDIR)\win\tmp
62 TMP=$(TMPDIR)
63
64 ###########################################################
65 ############### Targets - what to make
66 ###########################################################
67
68 YAZPROXY_DLL=$(BINDIR)\yazproxy.dll
69 YAZPROXY_IMPLIB=$(LIBDIR)\yazproxy.lib
70
71 YAZPROXY=$(BINDIR)\yazproxy.exe
72
73 # shortcut names defined here
74 dll: $(YAZPROXY_DLL)
75 proxy: $(YAZPROXY)
76 ###########################################################
77 ############### Compiler and linker options 
78 ###########################################################
79
80 !if $(DEBUG)
81 YAZD=yazd
82 YAZPPD=yazpp_1_d
83 !else
84 YAZD=yaz
85 YAZPPD=yazpp_1
86 !endif
87
88 # YAZ includes & libs
89 YAZ_LIB="$(YAZ_DIR)\lib\$(YAZD).lib"
90 YAZ_DEF=/DYAZ_USE_NEW_LOG=1 /I"$(YAZ_DIR)\include"
91
92 # Copy yaz.dll to our bin
93 yaz: $(BINDIR)\$(YAZD).dll
94 $(BINDIR)\$(YAZD).dll: $(YAZ_DIR)\bin\$(YAZD).dll
95   copy "$(YAZ_DIR)\bin\$(YAZD).dll" $(BINDIR)
96
97 # YAZ++ includes & libs
98 YAZPP_LIB="$(YAZPP_DIR)\lib\$(YAZPPD).lib"
99 YAZPP_DEF=/I"$(YAZPP_DIR)\include"
100
101 # Copy yazpp.dll to our bin
102 yazpp: $(BINDIR)\$(YAZPPD).dll
103 $(BINDIR)\$(YAZPPD).dll: $(YAZPP_DIR)\bin\$(YAZPPD).dll
104   copy "$(YAZPP_DIR)\bin\$(YAZPPD).dll" $(BINDIR)
105
106 !if $(HAVE_ICONV)
107 ICONV_DEF= \
108   /D HAVE_ICONV_H=1 \
109   /I"$(ICONV_DIR)\include"
110 ICONV_LIB= \
111   "$(ICONV_DIR)\lib\iconv.lib"
112 iconv: $(BINDIR)\iconv.dll
113
114 $(BINDIR)\iconv.dll:
115   copy "$(ICONV_DIR)\bin\iconv.dll" $(BINDIR)
116 !else
117 ICONV_DEF= \
118   /D HAVE_ICONV_H=0
119 ICONV_LIB=
120 iconv:
121
122 !endif
123
124 !if $(HAVE_LIBXML2)
125 LIBXML2_LIB="$(LIBXML2_DIR)\lib\libxml2.lib"
126 LIBXML2_DEF=/D HAVE_XML2=1 /I"$(LIBXML2_DIR)\include"
127 libxml2: $(BINDIR)\libxml2.dll $(BINDIR)\zlib1.dll
128
129 $(BINDIR)\libxml2.dll:
130   copy "$(LIBXML2_DIR)\bin\libxml2.dll" $(BINDIR)
131
132 $(BINDIR)\zlib1.dll:
133   copy "$(ZLIB_DIR)\bin\zlib1.dll" $(BINDIR)
134
135 !else
136 LIBXML2_LIB=
137 LIBXML2_DEF=/D HAVE_XML2=0
138 libxml2: 
139
140 !endif
141
142 !if $(HAVE_LIBXSLT)
143 LIBXSLT_LIB="$(LIBXSLT_DIR)\lib\libxslt.lib"
144 LIBXSLT_DEF=/D HAVE_XSLT=1 /I"$(LIBXSLT_DIR)\include"
145 libxslt: $(BINDIR)\libxslt.dll $(BINDIR)\zlib1.dll
146
147 $(BINDIR)\libxslt.dll:
148   copy "$(LIBXSLT_DIR)\bin\libxslt.dll" $(BINDIR)
149
150 !else
151 LIBXSLT_LIB=
152 LIBXSLT_DEF=/D HAVE_XSLT=0
153 libxslt: 
154
155 !endif
156
157
158 ### C and CPP compiler  (the same thing)
159 # Note: $(CPP) has already been defined in the environment
160 # (if you set things up right!)
161
162 COMMON_C_OPTIONS=          \
163   /nologo /W3 /EHsc /FD /c \
164   /D "_CRT_SECURE_NO_DEPRECATE" \
165   $(ICONV_DEF)             \
166   $(YAZ_DEF)               \
167   $(YAZPP_DEF)             \
168   $(LIBXML2_DEF)           \
169   $(LIBXSLT_DEF)           \
170   /D "_WINDOWS"            \
171   /D "WIN32"               \
172   /D "HAVE_WCHAR_H=1"      \
173   /FR"$(OBJDIR)\\"         \
174   /Fo"$(OBJDIR)\\"         \
175   /Fd"$(OBJDIR)\\" 
176
177 COMMON_C_INCLUDES= \
178   /I"$(ROOTDIR)\include"
179
180 DEBUG_C_OPTIONS=  \
181   /D "_DEBUG"      \
182   /MDd  /Od /Zi /Gm
183
184 RELEASE_C_OPTIONS=  \
185   /D "NDEBUG"        \
186   /MD /O2
187
188 # /W3  = warning level
189 # /EHsc= Enable exception handling
190 # /FD  = Generate file dependencies (what ever they are)
191 # /c   = compile without linking
192 # /FR  = Generate browse info (.sbr file that gets combined into .bsc)
193 # /Fo  = object file name (or at least path)
194 # /Fd  = debug database name (or path)
195 # /MD  = Runtime library: Multithread DLL
196 # /MDd = Runtime library: Multithread DLL (debug)
197 # /Od  = Disable optimising (debug)
198 # /O2  = Optimize for speed
199 # /Gm  = Minimal rebuild (some cpp class stuff)
200 # /Zi  = Program database for debuggers
201 # /ZI  = Pgm database with special "edit&continue" stuff - not available in C5
202
203
204 ### Linker options
205 LINK=link.exe
206
207 LINK_LIBS= kernel32.lib user32.lib   gdi32.lib   \
208            advapi32.lib uuid.lib \
209            wsock32.lib  advapi32.lib \
210            $(YAZ_LIB) $(YAZPP_LIB) $(ICONV_LIB) $(LIBXML2_LIB) $(LIBXSLT_LIB)
211
212 COMMON_LNK_OPTIONS= /nologo \
213                     /subsystem:windows \
214                     /machine:i386 \
215                           /incremental:no
216
217 DEBUG_LNK_OPTIONS= /debug 
218
219 RELEASE_LNK_OPTIONS=
220
221 DLL_LINK_OPTIONS= /dll  
222 CLIENT_LINK_OPTIONS = /subsystem:console  
223
224 # Final opt variables
225 !if $(DEBUG)
226 COPT=   $(COMMON_C_OPTIONS)   $(DEBUG_C_OPTIONS)     $(COMMON_C_INCLUDES)
227 MTLOPT= $(COMMON_MTL_OPTIONS) $(DEBUG_MTL_OPTIONS)
228 RCOPT=  $(COMMON_RC_OPTIONS)  $(DEBUG_RC_OPTIONS)
229 LNKOPT= $(COMMON_LNK_OPTIONS) $(DEBUG_LNK_OPTIONS)   $(LNK_LIBS)
230 TCLOPT= $(COMMON_TCL_OPTIONS)
231
232 !else
233 COPT=   $(COMMON_C_OPTIONS)   $(RELEASE_C_OPTIONS)   $(COMMON_C_INCLUDES) 
234 MTLOPT= $(COMMON_MTL_OPTIONS) $(RELEASE_MTL_OPTIONS)
235 RCOPT=  $(COMMON_RC_OPTIONS)  $(RELEASE_RC_OPTIONS)
236 LNKOPT= $(COMMON_LNK_OPTIONS) $(RELEASE_LNK_OPTIONS) $(LNK_LIBS)
237 TCLOPT= $(COMMON_TCL_OPTIONS)
238 !endif
239
240 ###########################################################
241 ###############  Source and object modules
242 ###########################################################
243
244 YAZPROXY_OBJS= \
245    "$(OBJDIR)\yaz-proxy-main.obj"
246
247 YAZPROXY_DLL_OBJS = \
248    "$(OBJDIR)\yaz-proxy.obj" \
249    "$(OBJDIR)\yaz-proxy-config.obj" \
250    "$(OBJDIR)\yaz-usemarcon.obj" \
251    "$(OBJDIR)\msg-thread.obj" \
252    "$(OBJDIR)\charset-converter.obj" \
253    "$(OBJDIR)\limit-connect.obj" \
254    "$(OBJDIR)\modules.obj" \
255    "$(OBJDIR)\yaz-bw.obj"
256
257 ###########################################################
258 ############### Compiling 
259 ###########################################################
260
261 # Note: This defines where to look for the necessary
262 # source files. Funny way of doing it, but it works.
263
264 {$(SRCDIR)}.cpp{$(OBJDIR)}.obj:
265         $(CPP) $(COPT) $< 
266
267 ###########################################################
268 ############### Resources
269 ###########################################################
270
271 ### The RC compiler (resource files)
272 RSC=rc.exe
273 COMMON_RC_OPTIONS= /l 0x406 /i"$(ROOTDIR)" 
274 DEBUG_RC_OPTIONS=/d "_DEBUG"
275 RELEASE_RC_OPTIONS=/d "NDEBUG"
276
277 YAZ_RES=$(OBJDIR)\yaz.res
278 YAZ_RC=$(WINDIR)\yaz.rc
279
280 !if $(DEBUG)
281 RSOPT=/d_DEBUG
282 !else
283 RSOPT=/d_NDEBUG
284 !endif
285
286 $(YAZ_RES): $(YAZ_RC)
287         $(RSC) $(RSOPT) /fo"$(YAZ_RES)" $(YAZ_RC) 
288
289 ###########################################################
290 ############### Linking
291 ###########################################################
292
293 $(YAZPROXY_DLL) $(YAZPROXY_IMPLIB): "$(BINDIR)" $(YAZPROXY_DLL_OBJS)
294         $(LINK) \
295                 $(LNKOPT)  \
296                 $(LINK_LIBS)  \
297                 $(DLL_LINK_OPTIONS) \
298                 $(YAZPP_IMPLIB) \
299                 $(YAZPROXY_DLL_OBJS) \
300                 /out:$(YAZPROXY_DLL)  \
301                 /implib:"$(YAZPROXY_IMPLIB)" \
302
303 $(YAZPROXY) : "$(BINDIR)" $(YAZPROXY_OBJS) $(YAZPROXY_IMPLIB)
304         $(LINK) \
305                 $(LNKOPT)  \
306                 $(CLIENT_LINK_OPTIONS) \
307                 $(LINK_LIBS)  \
308                 $(YAZPP_IMPLIB) \
309                 $(YAZPROXY_IMPLIB) \
310                 $(YAZPROXY_OBJS) \
311                 /out:$(YAZPROXY)
312
313 ###########################################################
314 ############### Generated Source files
315 ###########################################################
316
317 ############## clean
318 clean:
319         -del $(BINDIR)\*.exe
320         -del $(BINDIR)\*.dll
321         -del $(TMPDIR)\*.
322         -del $(LIBDIR)\*.MAP
323         -del $(LIBDIR)\*.LIB
324         -del $(OBJDIR)\*.OBJ
325
326 realclean: clean
327
328 # Because DOS del will only accept one file name to delete,
329 # the _H_ files work only on sets that have just one file.
330 # Z3950_H_FILES had to be spelled out. One more point for MS!
331
332 ########### check directories and create if needed
333 dirs: $(OBJDIR) $(WINDIR) $(LIBDIR) $(BINDIR) $(TMPDIR)
334
335 $(OBJDIR) $(WINDIR) $(LIBDIR) $(BINDIR) $(TMPDIR):
336         if not exist "$@/$(NUL)" mkdir "$@"
337