Renamed a pile of files
[yaz-moved-to-github.git] / win / makefile
1 # Makefile.mak - makefile for MS NMAKE 
2 # $Id: makefile,v 1.2 1999-06-08 14:07:24 heikki Exp $
3 #
4 # Programmed by
5 #  HL: Heikki Levanto, Index Data
6 #
7 # Log at the end of the file
8 #
9 # Missing
10 # - Move MS-C's whatnots into win direcotry
11 #  
12 # Envoronment problems
13 # - You need to have the proper path and environment for VC set
14 #   up. There is a bat file VCVARS32.BAT that sets most of it up
15 #   for you. You can find this somewhere near DevStudio\VC\BIN
16 # - RegSvr32 must also be along the path, often in WINDOWS\SYSTEM
17 # - TCL has to be available too, if compiling for NEW_Z3950
18
19 ###########################################################
20 ############### Parameters 
21 ###########################################################
22
23 DEBUG=0   # 0 for release, 1 for debug
24
25 NEW_Z3950=0  # 0= use old asn files
26              # 1= generate files from *.asn (needs tcl)
27
28
29 default: all
30
31 all: dirs proto_h dll client server ztest 
32
33
34 ###########################################################
35 ############### Directories
36 ###########################################################
37 # The current directory is supposed to be something like
38 # ..../Yaz/Win, everything is relative to that
39 ROOTDIR=..   # The home of Yaz
40
41 INCLDIR=$(ROOTDIR)\include  # our includes
42 LIBDIR=$(ROOTDIR)\lib       # We produce .lib, .exp etc there
43 BINDIR=$(ROOTDIR)\bin       # We produce exes and dlls there
44 WINDIR=$(ROOTDIR)\win       # all these Win make things
45 OBJDIR=$(WINDIR)\obj        # where we store intermediate files
46 UNIXDIR=$(ROOTDIR)\unix     # corresponding unix things
47 SRCDIR=$(ROOTDIR)           # for the case we move them under src
48
49 ASNDIR=$(SRCDIR)\ASN
50 COMSTACKDIR=$(SRCDIR)\COMSTACK
51 ODRDIR=$(SRCDIR)\ODR
52 UTILDIR=$(SRCDIR)\UTIL
53 ZUTILDIR=$(SRCDIR)\ZUTIL
54 RETDIR=$(SRCDIR)\RETRIEVAL
55
56 CLIENTDIR=$(SRCDIR)\CLIENT
57 SERVERDIR=$(SRCDIR)\SERVER
58 ZTESTDIR=$(SRCDIR)\ZTEST
59
60 TMPDIR=$(ROOTDIR)\win\tmp
61 TMP=$(TMP)
62
63 ###########################################################
64 ############### Targets - what to make
65 ###########################################################
66
67
68 DLL=$(BINDIR)\Yaz.dll
69 IMPLIB=$(BINDIR)\Yaz.lib
70
71 CLIENT=$(BINDIR)\client.exe
72 SERVER=$(BINDIR)\server.lib
73 ZTEST=$(BINDIR)\ztest.exe
74 PROTOH=$(INCLDIR)\proto.h
75
76 # shortcut names defined here
77 dll : $(DLL) 
78 client: $(CLIENT)
79 server: $(SERVER)
80 ztest: $(ZTEST)
81 proto_h: $(PROTOH)
82
83 ###########################################################
84 ############### Compiler and linker options 
85 ###########################################################
86
87
88 ### C and CPP compiler  (the same thing)
89 # Note: $(CPP) has already been defined in the environment
90 # (if you set things up right!)
91
92 COMMON_C_OPTIONS=          \
93   /nologo /W3 /GX /FD /c   \
94   /D "WIN32" /D "_WINDOWS" \
95   /FR"$(OBJDIR)\\"         \
96   /Fo"$(OBJDIR)\\"         \
97   /Fd"$(OBJDIR)\\" 
98
99 COMMON_C_INCLUDES= \
100   /I"$(SRCDIR)\include"
101
102 DEBUG_C_OPTIONS=  \
103   /D "_DEBUG"      \
104   /MDd  /Od /YX /Zi /Gm
105
106 RELEASE_C_OPTIONS=  \
107   /D "NDEBUG"        \
108   /MD /O2
109
110 # /W3  = warning level
111 # /GX  = Enable exception handling
112 # /FD  = Generate file dependencies (what ever they are)
113 # /c   = compile without linking
114 # /FR  = Generate browse info (.sbr file that gets combined into .bsc)
115 # /Fo  = object file name (or at least path)
116 # /Fd  = debug database name (or path)
117 # /MD  = Runtime library: Multithread DLL
118 # /MDd = Runtime library: Multithread DLL (debug)
119 # /Od  = Disable optimising (debug)
120 # /O2  = Optimize for speed
121 # /YX  = Automatic use of precomipled headers
122 # /Gm  = Minimal rebuild (some cpp class stuff)
123 # /Zi  = Program database for debuggers
124 # /ZI  = Pgm database with special "edit&continue" stuff - not available in C5
125
126 ### The RC compiler (resource files)
127 RSC=rc.exe
128 COMMON_RC_OPTIONS= /l 0x406 /i"$(ROOTDIR)" 
129 DEBUG_RC_OPTIONS=/d "_DEBUG"
130 RELEASE_RC_OPTIONS=/d "NDEBUG"
131
132
133 ### Linker options
134 LINK=link.exe
135
136 LINK_LIBS= kernel32.lib user32.lib   gdi32.lib   winspool.lib \
137            comdlg32.lib advapi32.lib shell32.lib ole32.lib    \
138            oleaut32.lib uuid.lib     odbc32.lib  odbccp32.lib \
139            wsock32.lib  advapi32.lib
140
141 COMMON_LNK_OPTIONS= /nologo \
142                     /subsystem:windows \
143                     /machine:i386 \
144                           /incremental:no
145
146 DEBUG_LNK_OPTIONS= /debug 
147
148 RELEASE_LNK_OPTIONS=  /pdb:none
149
150 DLL_LINK_OPTIONS= /dll  
151 CLIENT_LINK_OPTIONS = /subsystem:console  
152 SERVER_LINK_OPTIONS = -lib 
153 ZTEST_LINK_OPTIONS = /subsystem:console  
154
155
156 # Final opt variables
157 !if $(DEBUG)
158 COPT=   $(COMMON_C_OPTIONS)   $(DEBUG_C_OPTIONS)     $(COMMON_C_INCLUDES)
159 MTLOPT= $(COMMON_MTL_OPTIONS) $(DEBUG_MTL_OPTIONS)
160 RCOPT=  $(COMMON_RC_OPTIONS)  $(DEBUG_RC_OPTIONS)
161 LNKOPT= $(COMMON_LNK_OPTIONS) $(DEBUG_LNK_OPTIONS)   $(LNK_LIBS)
162
163 !else
164 COPT=   $(COMMON_C_OPTIONS)   $(RELEASE_C_OPTIONS)   $(COMMON_C_INCLUDES) 
165 MTLOPT= $(COMMON_MTL_OPTIONS) $(RELEASE_MTL_OPTIONS)
166 RCOPT=  $(COMMON_RC_OPTIONS)  $(RELEASE_RC_OPTIONS)
167 LNKOPT= $(COMMON_LNK_OPTIONS) $(RELEASE_LNK_OPTIONS) $(LNK_LIBS)
168 !endif
169
170
171
172 ###########################################################
173 ###############  Source and object modules
174 ###########################################################
175
176 # The resource files
177
178 RCFILE=$(SRCDIR)\compmak.rc
179 # Horrible Hack: The resfile contains just one line, pointing
180 # to the component.tlb file (which is created by the idl compiler)
181 # Devstudio wants that file to live in YazX3950, this makefile in
182 # win/obj. So we need to RC files!
183
184 RESFILE=$(OBJDIR)\component.res
185
186
187 # The def file
188 #DEF_FILE= $(ROOTDIR)\component.def 
189
190
191
192 # Note: Ordinary source files are not specified here at 
193 # all, make finds them in suitable dirs. The object modules
194 # need to be specified, though
195
196 YAZ_CLIENT_OBJS= \
197    $(OBJDIR)\client.obj
198
199 YAZ_SERVER_OBJS= \
200         "$(OBJDIR)\eventl.obj" \
201         "$(OBJDIR)\requestq.obj" \
202         "$(OBJDIR)\service.obj" \
203         "$(OBJDIR)\seshigh.obj" \
204         "$(OBJDIR)\statserv.obj" \
205         "$(OBJDIR)\tcpdchk.obj" 
206
207 ZTEST_OBJS= \
208         "$(OBJDIR)\read-grs.obj" \
209         "$(OBJDIR)\ztest.obj" 
210         
211
212 YAZ_ASN_OBJS= \
213    $(OBJDIR)\proto.obj \
214    $(OBJDIR)\prt-acc.obj \
215    $(OBJDIR)\prt-add.obj \
216    $(OBJDIR)\prt-arc.obj \
217    $(OBJDIR)\prt-dat.obj \
218    $(OBJDIR)\prt-dia.obj \
219    $(OBJDIR)\prt-esp.obj \
220    $(OBJDIR)\prt-exd.obj \
221    $(OBJDIR)\prt-exp.obj \
222    $(OBJDIR)\prt-grs.obj \
223    $(OBJDIR)\prt-rsc.obj \
224    $(OBJDIR)\prt-univ.obj 
225
226 YAZ_COMSTACK_OBJS= \
227    $(OBJDIR)\comstack.obj \
228    $(OBJDIR)\tcpip.obj \
229    $(OBJDIR)\waislen.obj 
230
231 YAZ_ODR_OBJS= \
232    $(OBJDIR)\ber_any.obj \
233    $(OBJDIR)\ber_bit.obj \
234    $(OBJDIR)\ber_bool.obj \
235    $(OBJDIR)\ber_int.obj \
236    $(OBJDIR)\ber_len.obj \
237    $(OBJDIR)\ber_null.obj \
238    $(OBJDIR)\ber_oct.obj \
239    $(OBJDIR)\ber_oid.obj \
240    $(OBJDIR)\ber_tag.obj \
241    $(OBJDIR)\dumpber.obj \
242    $(OBJDIR)\odr.obj \
243    $(OBJDIR)\odr_any.obj \
244    $(OBJDIR)\odr_bit.obj \
245    $(OBJDIR)\odr_bool.obj \
246    $(OBJDIR)\odr_choice.obj \
247    $(OBJDIR)\odr_cons.obj \
248    $(OBJDIR)\odr_enum.obj \
249    $(OBJDIR)\odr_int.obj \
250    $(OBJDIR)\odr_mem.obj \
251    $(OBJDIR)\odr_null.obj \
252    $(OBJDIR)\odr_oct.obj \
253    $(OBJDIR)\odr_oid.obj \
254    $(OBJDIR)\odr_priv.obj \
255    $(OBJDIR)\odr_seq.obj \
256    $(OBJDIR)\odr_tag.obj \
257    $(OBJDIR)\odr_use.obj \
258    $(OBJDIR)\odr_util.obj 
259
260 YAZ_UTIL_OBJS= \
261    $(OBJDIR)\atoin.obj \
262    $(OBJDIR)\dmalloc.obj \
263    $(OBJDIR)\log.obj \
264    $(OBJDIR)\marcdisp.obj \
265    $(OBJDIR)\nmem.obj \
266    $(OBJDIR)\nmemsdup.obj \
267    $(OBJDIR)\oid.obj \
268    $(OBJDIR)\options.obj \
269    $(OBJDIR)\readconf.obj \
270    $(OBJDIR)\tpath.obj \
271    $(OBJDIR)\wrbuf.obj \
272    $(OBJDIR)\xmalloc.obj \
273    $(OBJDIR)\matchstr.obj 
274
275 YAZ_ZUTIL_OBJS= \
276    $(OBJDIR)\diagbib1.obj \
277    $(OBJDIR)\zget.obj \
278    $(OBJDIR)\prt-ext.obj \
279    $(OBJDIR)\logrpn.obj \
280    $(OBJDIR)\pquery.obj \
281    $(OBJDIR)\query.obj \
282    $(OBJDIR)\yaz-ccl.obj \
283    $(OBJDIR)\otherinfo.obj
284
285 YAZ_RET_OBJS= \
286    $(OBJDIR)\d1_absyn.obj\
287    $(OBJDIR)\d1_attset.obj\
288    $(OBJDIR)\d1_doespec.obj\
289    $(OBJDIR)\d1_espec.obj\
290    $(OBJDIR)\d1_expout.obj\
291    $(OBJDIR)\d1_grs.obj\
292    $(OBJDIR)\d1_handle.obj\
293    $(OBJDIR)\d1_map.obj\
294    $(OBJDIR)\d1_marc.obj\
295    $(OBJDIR)\d1_prtree.obj\
296    $(OBJDIR)\d1_read.obj\
297    $(OBJDIR)\d1_soif.obj\
298    $(OBJDIR)\d1_sumout.obj\
299    $(OBJDIR)\d1_sutrs.obj\
300    $(OBJDIR)\d1_tagset.obj\
301    $(OBJDIR)\d1_varset.obj\
302    $(OBJDIR)\d1_write.obj
303
304 YAZ_OBJS= \
305    $(YAZ_ASN_OBJS) \
306    $(YAZ_COMSTACK_OBJS) \
307    $(YAZ_ODR_OBJS) \
308    $(YAZ_UTIL_OBJS) \
309    $(YAZ_ZUTIL_OBJS) \
310    $(YAZ_RET_OBJS)
311
312 DLL_OBJS= $(YAZ_OBJS)
313
314
315 ###########################################################
316 ############### Compiling 
317 ###########################################################
318
319 # Note: This defines where to look for the necessary
320 # source files. Funny way of doing it, but it works.
321
322 # DLL sources
323 {$(SRCDIR)}.cpp{$(OBJDIR)}.obj:
324         @$(CPP) @<<
325         $(COPT) $<
326 <<
327
328 # Yaz client
329 {$(CLIENTDIR)}.c{$(OBJDIR)}.obj:
330         echo MAKING IN CLIENT !!!!!
331         @$(CPP) @<<  
332         $(COPT) $< 
333         /D"_CONSOLE"
334 <<
335
336 # Ztest
337 {$(ZTESTDIR)}.c{$(OBJDIR)}.obj:
338         @$(CPP) @<<  
339         $(COPT) $< 
340       /D"_CONSOLE"
341         /D"_MBCS"
342 <<
343
344
345 # Server
346 {$(SERVERDIR)}.c{$(OBJDIR)}.obj:
347         @$(CPP) @<<  
348         $(COPT) $< 
349 <<
350
351 # Various YAZ source directories
352 {$(ASNDIR)}.c{$(OBJDIR)}.obj:
353         @$(CPP) @<<  
354         $(COPT) $< 
355 <<
356
357 {$(COMSTACKDIR)}.c{$(OBJDIR)}.obj:
358         @$(CPP) @<<  
359         $(COPT) $< 
360 <<
361
362 {$(ODRDIR)}.c{$(OBJDIR)}.obj:
363         @$(CPP) @<<  
364         $(COPT) $< 
365 <<
366
367 {$(UTILDIR)}.c{$(OBJDIR)}.obj:
368         @$(CPP) @<<  
369         $(COPT) $< 
370 <<
371
372 {$(ZUTILDIR)}.c{$(OBJDIR)}.obj:
373         @$(CPP) @<<  
374         $(COPT) $< 
375 <<
376
377 {$(RETDIR)}.c{$(OBJDIR)}.obj:
378         @$(CPP) @<<  
379         $(COPT) $< 
380 <<
381
382
383 ### Resource file
384 $(RESFILE): $(RCFILE) $(IDLGENERATED)
385         $(RSC) $(RCOPT) /fo"$(RESFILE)" $(RCFILE) 
386
387
388 ###########################################################
389 ############### Linking
390 ###########################################################
391
392
393 $(DLL) $(IMPLIB): "$(BINDIR)" $(DLL_OBJS) 
394         @echo Linking the dll  $(DLL)
395         $(LINK) @<<
396                 $(LNKOPT) 
397                 $(LINK_LIBS) 
398                 $(DLL_LINK_OPTIONS)
399                 $(DLL_OBJS) 
400                 /out:$(DLL) 
401                 /implib:$(IMPLIB)
402                 /pdb:"$(LIBDIR)/yaz.pdb" 
403                 /map:"$(LIBDIR)/yaz.map"  
404 <<
405
406 $(CLIENT) : "$(BINDIR)" $(YAZ_CLIENT_OBJS) #####$(IMPLIB)
407         @echo Linking the client  $(CLIENT)
408         $(LINK) @<<
409             $(LNKOPT) 
410                 $(CLIENT_LINK_OPTIONS)
411                 $(LINK_LIBS) 
412                 $(IMPLIB)
413                 $(YAZ_CLIENT_OBJS) 
414                 /out:$(CLIENT) 
415 <<
416
417 $(ZTEST) : "$(BINDIR)" $(ZTEST_OBJS) $(SERVER) $(DLL)
418         @echo Linking the ztest  $(ZTEST)
419         $(LINK) @<<
420             $(LNKOPT) 
421                 $(ZTEST_LINK_OPTIONS)
422                 $(LINK_LIBS) 
423                 shell32.lib 
424                 $(IMPLIB)
425                 $(SERVER)
426                 $(ZTEST_OBJS) 
427                 /out:$(ZTEST) 
428 <<
429
430
431 $(SERVER) : "$(BINDIR)" $(YAZ_SERVER_OBJS) 
432         @echo Linking the server  $(SERVER)
433         $(LINK) $(SERVER_LINK_OPTIONS) @<<
434                 /nologo
435                 $(LINK_LIBS) 
436                 $(IMPLIB)
437                 $(YAZ_SERVER_OBJS) 
438                 /out:$(SERVER) 
439 <<
440
441 # note that this links a lib, so it uses completely different options.
442
443
444
445 ###########################################################
446 ############### Special operations
447 ###########################################################
448
449
450 ############## clean
451 clean:
452         del $(OBJDIR)\*.obj
453         del $(OBJDIR)\*.sbr
454         del $(DLL) 
455         del $(CLIENT)
456         del $(SERVER)
457         del $(ZTEST)
458         del $(TMPDIR)\*.
459
460 ########### check directories and create if needed
461 dirs: $(OBJDIR) $(WINDIR) $(LIBDIR) $(BINDIR) $(TMPDIR)
462
463 $(OBJDIR) $(WINDIR) $(LIBDIR) $(BINDIR) $(TMPDIR):
464         if not exist "$@/$(NUL)" mkdir "$@"
465
466
467 ###########################################################
468 ############### Explicit dependencies
469 ###########################################################
470
471 $(OBJDIR)/client.obj: $(IDLGENERATED)
472
473 $(DLL_OBJS): makefile $(PROTOH)
474
475
476 # Debug test
477 foo: $(OBJDIR)\ztest.obj
478
479 ###########################################################
480 ############### Log
481 ###########################################################
482 #
483 # $Log: makefile,v $
484 # Revision 1.2  1999-06-08 14:07:24  heikki
485 # Renamed a pile of files
486 # Tmpdir (to get around Ms leaving temp files around, and crashing
487 # when too many with same number...)
488 #
489 # Revision 1.1  1999/06/08 12:15:41  heikki
490 # Renamed to makefile (.nothing) (from .mak)
491 # Working on the proto.h problems and alternative confiigurations
492 #
493 # Revision 1.5  1999/06/04 10:04:28  heikki
494 # Cleaning up
495 #
496 # Revision 1.4  1999/06/02 13:23:29  heikki
497 # Debug options for C compiler
498 #
499 # Revision 1.3  1999/05/19 08:26:22  heikki
500 # Added comments
501 #
502 #
503
504
505