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