Align query tests
[idzebra-moved-to-github.git] / win / makefile
1 # Zebra makefile for MS NMAKE
2 # $Id: makefile,v 1.57 2006-09-22 10:18:06 adam Exp $
3  
4 ###########################################################
5 ############### Parameters 
6 ###########################################################
7
8 DEBUG=0   # 0 for release, 1 for debug
9
10 # EXPAT is optional. It's required for grs.xml-filters.
11 HAVE_EXPAT=1
12 EXPAT_DIR=c:\Expat-1.95.8
13
14 # iconv is optional
15 HAVE_ICONV=1
16 ICONV_DIR=c:\iconv-1.9.2.win32
17
18 # libxslt. For alvis
19 HAVE_LIBXSLT=1
20 LIBXSLT_DIR=c:\libxslt-1.1.17.win32
21
22 # libxml2. Used by libxslt
23 HAVE_LIBXML2=1
24 LIBXML2_DIR=c:\libxml2-2.6.26.win32
25
26 # zlib compression.  Used by libxml2
27 ZLIB_DIR = c:\zlib-1.2.3.win32
28
29 # get WIN32 binaries libxml2 & iconv & zlib from here:
30 #  http://www.zlatkovic.com/libxml.en.html
31
32 default: all
33
34 all: dirs expat iconv libxml2 libxslt yaz dll zserver zebraidx tstflock
35
36 # Directories
37 # The current directory is supposed to be something like
38 # ..../Zebra/Win, everything is relative to that
39 ROOTDIR=..   # The home of zebra
40
41 # YAZ include files, libraries, etc.
42 YAZDIR=$(ROOTDIR)\..\YAZ
43 YAZINCL=$(YAZDIR)\include
44 YAZLIBS=$(YAZLIB)
45 YAZBINDIR=$(YAZDIR)\bin
46 !if $(DEBUG)
47 YAZLIB=$(YAZDIR)\lib\yazd.lib
48 YAZ_DLL_SOURCE=$(YAZBINDIR)\yazd.dll
49 YAZ_DLL_TARGET=$(BINDIR)\yazd.dll
50 !else
51 YAZLIB=$(YAZDIR)\lib\yaz.lib
52 YAZ_DLL_SOURCE=$(YAZBINDIR)\yaz.dll
53 YAZ_DLL_TARGET=$(BINDIR)\yaz.dll
54 !endif
55
56 # BZIP2 settings. Uncomment and specify if you wish to use LIBBZIP2.
57 # (C) 1996-1999 Julian Seward <jseward@acm.org> http://www.bzip2.org
58
59 #BZIP2INCLUDE=/I"$(ROOTDIR)\..\bzip2-0.9.5d"
60 #BZIP2LIB=$(ROOTDIR)\..\bzip2-0.9.5d\libbz2.lib
61 #BZIP2DEF=/D"HAVE_BZLIB_H=1"
62
63 # ZEBRA Include files, libraries, programs, etc.
64 INCLDIR=$(ROOTDIR)\include  # our includes
65 LIBDIR=$(ROOTDIR)\lib       # We produce .lib, .exp etc there
66 BINDIR=$(ROOTDIR)\bin       # We produce exes and dlls there
67 WINDIR=$(ROOTDIR)\win       # all these Win make things
68 !if $(DEBUG)
69 OBJDIR=$(WINDIR)\dobj       # where we store intermediate files
70 !else
71 OBJDIR=$(WINDIR)\obj        # where we store intermediate files
72 !endif
73 UNIXDIR=$(ROOTDIR)\unix     # corresponding unix things
74 SRCDIR=$(ROOTDIR)           # for the case we move them under src
75
76 INDEXDIR=$(SRCDIR)\INDEX
77 BFILEDIR=$(SRCDIR)\BFILE
78 DFADIR=$(SRCDIR)\DFA
79 DICTDIR=$(SRCDIR)\DICT
80 ISAMSDIR=$(SRCDIR)\ISAMS
81 ISAMCDIR=$(SRCDIR)\ISAMC
82 ISAMBDIR=$(SRCDIR)\ISAMB
83 RSETDIR=$(SRCDIR)\RSET
84 UTILDIR=$(SRCDIR)\UTIL
85 DATA1DIR=$(SRCDIR)\DATA1
86
87 # Force temp files in a local temp, easier to clean
88 # when nmake crashes and leaves a lot of rubbish behind
89 TMPDIR=$(ROOTDIR)\win\tmp
90 TMP=$(TMPDIR)
91 TEMP=$(TMPDIR)
92
93 # NSIS
94 NSIS="c:\program files\nsis\makensis.exe"
95
96 dist:
97         nmake DEBUG=1 clean
98         nmake DEBUG=0 clean
99         nmake DEBUG=0
100         $(NSIS) zebra.nsi
101
102 nsis:
103         $(NSIS) zebra.nsi
104
105 # Targets - what to make
106
107 !if $(DEBUG)
108 DLL=$(BINDIR)\idzebrad.dll
109 IMPLIB=$(LIBDIR)\idzebrad.lib
110 !else
111 DLL=$(BINDIR)\idzebra.dll
112 IMPLIB=$(LIBDIR)\idzebra.lib
113 !endif
114
115 ZEBRA_RES=$(OBJDIR)\idzebra.res
116
117 ZSERVER=$(BINDIR)\zebrasrv.exe
118 ZEBRAIDX=$(BINDIR)\zebraidx.exe
119 TSTFLOCK=$(BINDIR)\tstflock.exe
120
121 # shortcut names defined here
122 zebraidx: $(ZEBRAIDX)
123 zserver: $(ZSERVER)
124 tstflock: $(TSTFLOCK)
125 dll: $(DLL) 
126
127 # External libs and modules (enabled or disabled)
128
129 !if $(HAVE_EXPAT)
130 EXPAT_DEF= /D HAVE_EXPAT_H=1 /I"$(EXPAT_DIR)\source\lib"
131 EXPAT_LIB= "$(EXPAT_DIR)\libs\libexpat.lib"
132 EXPAT_DLL_SOURCE= "$(EXPAT_DIR)\libs\libexpat.dll"
133 EXPAT_DLL_TARGET="$(BINDIR)\libexpat.dll"
134 expat: $(EXPAT_DLL_TARGET)
135
136 $(EXPAT_DLL_TARGET) : $(EXPAT_DLL_SOURCE)
137         copy $(EXPAT_DLL_SOURCE) $(EXPAT_DLL_TARGET)
138 !else
139 EXPAT_DEF= /D HAVE_EXPAT_H=0
140 EXPAT_LIB=
141 EXPAT_DLL_SOURCE=
142 EXPAT_DLL_TARGET=
143 expat:
144 !endif
145
146 !if $(HAVE_ICONV)
147 ICONV_DEF= /D HAVE_ICONV_H=1 /I"$(ICONV_DIR)\include"
148 ICONV_LIB= $(ICONV_DIR)\lib\iconv.lib
149 iconv: $(BINDIR)\iconv.dll
150
151 $(BINDIR)\iconv.dll:
152         copy "$(ICONV_DIR)\bin\iconv.dll" $(BINDIR)
153 !else
154 ICONV_DEF= /D HAVE_ICONV_H=0
155 ICONV_LIB=
156 iconv:
157 !endif
158
159 !if $(HAVE_LIBXML2)
160 LIBXML2_LIB="$(LIBXML2_DIR)\lib\libxml2.lib"
161 LIBXML2_DEF=/D HAVE_XML2=1 /I"$(LIBXML2_DIR)\include"
162 libxml2: $(BINDIR)\libxml2.dll $(BINDIR)\zlib1.dll
163
164 $(BINDIR)\libxml2.dll:
165   copy "$(LIBXML2_DIR)\bin\libxml2.dll" $(BINDIR)
166
167 $(BINDIR)\zlib1.dll:
168   copy "$(ZLIB_DIR)\bin\zlib1.dll" $(BINDIR)
169
170 !else
171 LIBXML2_LIB=
172 LIBXML2_DEF=/D HAVE_XML2=0
173 libxml2: 
174
175 !endif
176
177 !if $(HAVE_LIBXSLT)
178 LIBXSLT_LIB="$(LIBXSLT_DIR)\lib\libxslt.lib"
179 LIBXSLT_DEF=/D HAVE_XSLT=1 /I"$(LIBXSLT_DIR)\include"
180 libxslt: $(BINDIR)\libxslt.dll 
181
182 $(BINDIR)\libxslt.dll:
183   copy "$(LIBXSLT_DIR)\bin\libxslt.dll" $(BINDIR)
184
185 !else
186 LIBXSLT_LIB=
187 LIBXSLT_DEF=/D HAVE_XSLT=0
188 libxslt: 
189
190 !endif
191
192 !if $(HAVE_LIBXSLT)
193 MOD_ALVIS_OBJS= $(OBJDIR)\alvis.obj
194 MOD_ALVIS_CFLAGS=/DIDZEBRA_STATIC_ALVIS=1
195 !else
196 MOD_ALVIS_OBJS=
197 MOD_ALVIS_CFLAGS=
198 !endif
199
200 ### C and CPP compiler  (the same thing)
201 # Note: $(CPP) has already been defined in the environment
202 # (if you set things up right!)
203
204 COMMON_C_OPTIONS=          \
205   /nologo /W3 /EHsc /FD /c \
206   /D "WIN32"               \
207   /D"_CONSOLE" /D"_MBCS"   \
208   /DYAZ_USE_NEW_LOG=1      \
209   /D"_CRT_SECURE_NO_DEPRECATE" \
210   /D"_CRT_NONSTDC_NO_DEPRECATE" \
211   $(ICONV_DEF)             \
212   $(EXPAT_DEF)             \
213   $(LIBXML2_DEF)           \
214   $(LIBXSLT_DEF)           \
215   /FR"$(OBJDIR)\\"         \
216   /Fo"$(OBJDIR)\\"         \
217   /Fd"$(OBJDIR)\\"         \
218   /DDEFAULT_PROFILE_PATH=0 \
219   /DDEFAULT_MODULE_PATH=0  \
220   /DIDZEBRA_STATIC_GRS_SGML=1 \
221   /DIDZEBRA_STATIC_TEXT=1  \
222   /DIDZEBRA_STATIC_GRS_XML=1 \
223   /DIDZEBRA_STATIC_GRS_REGX=1 \
224   /DIDZEBRA_STATIC_GRS_MARC=1 \
225   /DIDZEBRA_STATIC_GRS_DANBIB=1 \
226   $(MOD_ALVIS_CFLAGS) \
227   /DIDZEBRA_STATIC_SAFARI=1 \
228   $(BZIP2DEF)
229
230 COMMON_C_INCLUDES= \
231   /I"$(SRCDIR)\include" \
232   /I"$(YAZDIR)\include" \
233   $(BZIP2INCLUDE)
234
235 DEBUG_C_OPTIONS=  \
236   /D "_DEBUG"      \
237   /MDd  /Od /YX /Zi /Gm
238
239 RELEASE_C_OPTIONS=  \
240   /D "NDEBUG"        \
241   /MD /O2
242
243 # /W3  = warning level
244 # /GX  = Enable exception handling
245 # /FD  = Generate file dependencies (what ever they are)
246 # /c   = compile without linking
247 # /FR  = Generate browse info (.sbr file that gets combined into .bsc)
248 # /Fo  = object file name (or at least path)
249 # /Fd  = debug database name (or path)
250 # /MD  = Runtime library: Multithread DLL
251 # /MDd = Runtime library: Multithread DLL (debug)
252 # /Od  = Disable optimising (debug)
253 # /O2  = Optimize for speed
254 # /YX  = Automatic use of precomipled headers
255 # /Gm  = Minimal rebuild (some cpp class stuff)
256 # /Zi  = Program database for debuggers
257 # /ZI  = Pgm database with special "edit&continue" stuff - not available in C5
258
259 ### Linker options
260 LINK=link.exe
261
262 LINK_LIBS= kernel32.lib user32.lib   gdi32.lib   winspool.lib \
263            comdlg32.lib advapi32.lib shell32.lib ole32.lib    \
264            oleaut32.lib uuid.lib     odbc32.lib  odbccp32.lib \
265            wsock32.lib  advapi32.lib \
266            $(ICONV_LIB) $(EXPAT_LIB) $(LIBXML2_LIB) $(LIBXSLT_LIB)
267
268 COMMON_LNK_OPTIONS= /nologo /machine:i386 /incremental:no
269
270 DEBUG_LNK_OPTIONS= /debug 
271
272 RELEASE_LNK_OPTIONS= 
273
274 ZEBRALIB_LINK_OPTIONS= -lib 
275
276 DLL_LINK_OPTIONS= /dll  
277
278 CLIENT_LINK_OPTIONS= /subsystem:console  
279
280 # Final opt variables
281 !if $(DEBUG)
282 COPT=   $(COMMON_C_OPTIONS)   $(DEBUG_C_OPTIONS)     $(COMMON_C_INCLUDES)
283 MTLOPT= $(COMMON_MTL_OPTIONS) $(DEBUG_MTL_OPTIONS)
284 RCOPT=  $(COMMON_RC_OPTIONS)  $(DEBUG_RC_OPTIONS)
285 LNKOPT= $(COMMON_LNK_OPTIONS) $(DEBUG_LNK_OPTIONS)   $(LNK_LIBS)
286
287 !else
288 COPT=   $(COMMON_C_OPTIONS)   $(RELEASE_C_OPTIONS)   $(COMMON_C_INCLUDES) 
289 MTLOPT= $(COMMON_MTL_OPTIONS) $(RELEASE_MTL_OPTIONS)
290 RCOPT=  $(COMMON_RC_OPTIONS)  $(RELEASE_RC_OPTIONS)
291 LNKOPT= $(COMMON_LNK_OPTIONS) $(RELEASE_LNK_OPTIONS) $(LNK_LIBS)
292 !endif
293
294 LINK_PROGRAM= $(LINK) \
295                 $(LNKOPT) \
296                 $(CLIENT_LINK_OPTIONS) \
297                 $(IMPLIB) \
298                 $(YAZLIBS) \
299                 $(BZIP2LIB) \
300                 $(LINK_LIBS)
301
302 # Source and object modules
303 # Note: Ordinary source files are not specified here at 
304 # all, make finds them in suitable dirs. The object modules
305 # need to be specified, though
306
307 ZSERVER_OBJS= \
308         $(OBJDIR)\zebrasrv.obj 
309
310 ZEBRAIDX_OBJS= \
311         $(OBJDIR)\zebraidx.obj 
312 TSTFLOCK_OBJS= \
313         $(OBJDIR)\tstflock.obj
314
315 ZEBRALIB_OBJS= \
316         $(MOD_ALVIS_OBJS) \
317         $(OBJDIR)\atoi_zn.obj \
318         $(OBJDIR)\attribute.obj \
319         $(OBJDIR)\attrfind.obj \
320         $(OBJDIR)\bfile.obj \
321         $(OBJDIR)\bset.obj \
322         $(OBJDIR)\cfile.obj \
323         $(OBJDIR)\charmap.obj \
324         $(OBJDIR)\close.obj \
325         $(OBJDIR)\commit.obj \
326         $(OBJDIR)\compact.obj \
327         $(OBJDIR)\d1_absyn.obj \
328         $(OBJDIR)\d1_attset.obj \
329         $(OBJDIR)\d1_doespec.obj \
330         $(OBJDIR)\d1_espec.obj \
331         $(OBJDIR)\d1_expout.obj \
332         $(OBJDIR)\d1_grs.obj \
333         $(OBJDIR)\d1_handle.obj \
334         $(OBJDIR)\d1_if.obj \
335         $(OBJDIR)\d1_map.obj \
336         $(OBJDIR)\d1_marc.obj \
337         $(OBJDIR)\d1_prtree.obj \
338         $(OBJDIR)\d1_read.obj \
339         $(OBJDIR)\d1_soif.obj \
340         $(OBJDIR)\d1_sumout.obj \
341         $(OBJDIR)\d1_sutrs.obj \
342         $(OBJDIR)\d1_tagset.obj \
343         $(OBJDIR)\d1_utils.obj \
344         $(OBJDIR)\d1_varset.obj \
345         $(OBJDIR)\d1_write.obj \
346         $(OBJDIR)\dclose.obj \
347         $(OBJDIR)\dcompact.obj \
348         $(OBJDIR)\delete.obj \
349         $(OBJDIR)\dfa.obj \
350         $(OBJDIR)\dir.obj \
351         $(OBJDIR)\dirent.obj \
352         $(OBJDIR)\dirs.obj \
353         $(OBJDIR)\dopen.obj \
354         $(OBJDIR)\drdwr.obj \
355         $(OBJDIR)\extract.obj \
356         $(OBJDIR)\flock.obj \
357         $(OBJDIR)\imalloc.obj \
358         $(OBJDIR)\inline.obj \
359         $(OBJDIR)\insert.obj \
360         $(OBJDIR)\invstat.obj \
361         $(OBJDIR)\isamb.obj \
362         $(OBJDIR)\isamc.obj \
363         $(OBJDIR)\isams.obj \
364         $(OBJDIR)\kcompare.obj \
365         $(OBJDIR)\kcontrol.obj \
366         $(OBJDIR)\kinput.obj \
367         $(OBJDIR)\limit.obj \
368         $(OBJDIR)\lookgrep.obj \
369         $(OBJDIR)\lookup.obj \
370         $(OBJDIR)\lookupec.obj \
371         $(OBJDIR)\marcomp.obj \
372         $(OBJDIR)\marcread.obj \
373         $(OBJDIR)\merge.obj \
374         $(OBJDIR)\mfile.obj \
375         $(OBJDIR)\open.obj \
376         $(OBJDIR)\orddict.obj \
377         $(OBJDIR)\passwddb.obj \
378         $(OBJDIR)\rank1.obj \
379         $(OBJDIR)\ranksimilarity.obj \
380         $(OBJDIR)\rankstatic.obj \
381         $(OBJDIR)\recctrl.obj \
382         $(OBJDIR)\recgrs.obj \
383         $(OBJDIR)\recindex.obj \
384         $(OBJDIR)\reckeys.obj \
385         $(OBJDIR)\recstat.obj \
386         $(OBJDIR)\rectext.obj \
387         $(OBJDIR)\regxread.obj \
388         $(OBJDIR)\res.obj \
389         $(OBJDIR)\retrieve.obj \
390         $(OBJDIR)\rpnscan.obj \
391         $(OBJDIR)\rpnsearch.obj \
392         $(OBJDIR)\rsbetween.obj \
393         $(OBJDIR)\rsbool.obj \
394         $(OBJDIR)\rset.obj \
395         $(OBJDIR)\rsisamb.obj \
396         $(OBJDIR)\rsisamc.obj \
397         $(OBJDIR)\rsisams.obj \
398         $(OBJDIR)\rsmultiandor.obj \
399         $(OBJDIR)\rsnull.obj \
400         $(OBJDIR)\rsprox.obj \
401         $(OBJDIR)\rstemp.obj \
402         $(OBJDIR)\safari.obj \
403         $(OBJDIR)\scan.obj \
404         $(OBJDIR)\set.obj \
405         $(OBJDIR)\sgmlread.obj \
406         $(OBJDIR)\snippet.obj \
407         $(OBJDIR)\sortidx.obj \
408         $(OBJDIR)\states.obj \
409         $(OBJDIR)\stream.obj \
410         $(OBJDIR)\symtab.obj \
411         $(OBJDIR)\trunc.obj \
412         $(OBJDIR)\untrans.obj \
413         $(OBJDIR)\update_path.obj \
414         $(OBJDIR)\update_file.obj \
415         $(OBJDIR)\xmlread.obj \
416         $(OBJDIR)\xpath.obj \
417         $(OBJDIR)\zaptterm.obj \
418         $(OBJDIR)\zebra-lock.obj \
419         $(OBJDIR)\zebraapi.obj \
420         $(OBJDIR)\zebramap.obj \
421         $(OBJDIR)\zinfo.obj \
422         $(OBJDIR)\zint.obj \
423         $(OBJDIR)\zsets.obj
424
425 # Compiling 
426 # Note: This defines where to look for the necessary
427 # source files. Funny way of doing it, but it works.
428
429 {$(INDEXDIR)}.c{$(OBJDIR)}.obj:
430         $(CPP) $(COPT) $< 
431
432 {$(BFILEDIR)}.c{$(OBJDIR)}.obj:
433         $(CPP) $(COPT) $< 
434
435 {$(DFADIR)}.c{$(OBJDIR)}.obj:
436         $(CPP) $(COPT) $< 
437
438 {$(DICTDIR)}.c{$(OBJDIR)}.obj:
439         $(CPP) $(COPT) $< 
440
441 {$(ISAMSDIR)}.c{$(OBJDIR)}.obj:
442         $(CPP) $(COPT) $< 
443
444 {$(ISAMCDIR)}.c{$(OBJDIR)}.obj:
445         $(CPP) $(COPT) $< 
446
447 {$(ISAMBDIR)}.c{$(OBJDIR)}.obj:
448         $(CPP) $(COPT) $< 
449
450 {$(RSETDIR)}.c{$(OBJDIR)}.obj:
451         $(CPP) $(COPT) $< 
452
453 {$(UTILDIR)}.c{$(OBJDIR)}.obj:
454         $(CPP) $(COPT) $< 
455
456 {$(DATA1DIR)}.c{$(OBJDIR)}.obj:
457         $(CPP) $(COPT) $< 
458
459 # Linking
460
461 $(ZSERVER) : "$(BINDIR)" $(ZSERVER_OBJS) $(IMPLIB)
462         $(LINK_PROGRAM) \
463                 $(ZSERVER_OBJS) \
464                 /out:$(ZSERVER)
465
466 $(ZEBRAIDX) : "$(BINDIR)" $(ZEBRAIDX_OBJS) $(IMPLIB)
467         $(LINK_PROGRAM) \
468                 $(ZEBRAIDX_OBJS) \
469                 /out:$(ZEBRAIDX)
470
471 $(TSTFLOCK) : "$(BINDIR)" $(TSTFLOCK_OBJS) $(IMPLIB)
472         $(LINK_PROGRAM) \
473                 $(TSTFLOCK_OBJS) \
474                 /out:$(TSTFLOCK) 
475
476 $(DLL) $(IMPLIB): "$(BINDIR)" $(ZEBRALIB_OBJS)
477         $(LINK) \
478                 $(LNKOPT) \
479                 $(LINK_LIBS) \
480                 $(DLL_LINK_OPTIONS) \
481                 $(ZEBRALIB_OBJS) \
482                 /out:$(DLL) \
483                 $(YAZLIBS) \
484                 /implib:"$(IMPLIB)" \
485                 /map:"$(LIBDIR)\idzebra.map" \
486
487 # Other rules
488
489 clean:
490         -del $(OBJDIR)\*.obj
491         -del $(OBJDIR)\*.sbr
492         -del $(BINDIR)\*.exe
493         -del $(BINDIR)\*.dll
494         -del $(TMPDIR)\*.
495         -del $(LIBDIR)\*.lib
496
497 dirs: $(OBJDIR) $(WINDIR) $(LIBDIR) $(BINDIR) $(TMPDIR)
498
499 $(OBJDIR) $(WINDIR) $(LIBDIR) $(BINDIR) $(TMPDIR):
500         if not exist "$@/$(NUL)" mkdir "$@"
501
502 yaz: $(YAZ_DLL_TARGET)
503
504 $(YAZ_DLL_TARGET) : $(YAZ_DLL_SOURCE)
505 #       copy $(YAZBINDIR)\*.dll.manifest $(BINDIR)
506         copy $(YAZBINDIR)\*.dll $(BINDIR)
507
508