OSDN Git Service

Import of Itcl 3.3.
[pf3gnuchains/pf3gnuchains3x.git] / itcl / itk / win / makefile.vc
1 #------------------------------------------------------------------------------
2 # Visual C++ 5.0+ makefile for [Incr Tk]
3 #
4 # See the file "license.terms" for information on usage and redistribution
5 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
6
7 # Copyright (c) 1993-1998 Lucent Technologies, Inc.
8 # RCS: $Id$
9 #------------------------------------------------------------------------------
10 #  Do not modify this file!
11 #------------------------------------------------------------------------------
12
13 !if !exist("makefile.vc")
14 MSG = ^
15 You must run this makefile only from the directory it is in.^
16 Please `cd` to its location first.
17 !error $(MSG) 
18 !endif
19
20 PROJECT = itk
21 !include "..\..\rules.vc"
22
23
24 !if $(TCLINSTALL)
25 !message *** Warning: [Incr Tk] requires the source distribution of Tcl to build from,
26 !message ***    at this time, sorry.  Please set the TCLDIR and TKDIR macros to point
27 !message ***    to the sources.
28 !endif
29
30 ITCLDIR         = ..\..\itcl
31
32
33 !if [nmakehlp -g $(ITCLDIR)\generic\itcl.h ITCL_VERSION] == 33
34 ITCL_DOTVERSION = 3.3
35 !elseif [nmakehlp -g $(ITCLDIR)\generic\itcl.h ITCL_VERSION] == 34
36 ITCL_DOTVERSION = 3.4
37 !elseif [nmakehlp -g $(ITCLDIR)\generic\itcl.h ITCL_VERSION] == 35
38 ITCL_DOTVERSION = 3.5
39 !elseif [nmakehlp -g $(ITCLDIR)\generic\itcl.h ITCL_VERSION] == 0
40 MSG =^
41 Can't get version string from ..\generic\itcl.h
42 !error $(MSG)
43 !endif
44 ITCL_VERSION    = $(ITCL_DOTVERSION:.=)
45
46 !if [nmakehlp -g ..\generic\itk.h ITK_VERSION] == 33
47 ITK_DOTVERSION  = 3.3
48 !elseif [nmakehlp -g ..\generic\itk.h ITK_VERSION] == 34
49 ITK_DOTVERSION  = 3.4
50 !elseif [nmakehlp -g ..\generic\itk.h ITK_VERSION] == 35
51 ITK_DOTVERSION  = 3.5
52 !elseif [nmakehlp -g ..\generic\itk.h ITK_VERSION] == 0
53 MSG =^
54 Can't get version string from ..\generic\itk.h
55 !error $(MSG)
56 !endif
57 ITK_VERSION     = $(ITK_DOTVERSION:.=)
58
59
60 BINROOT         = .
61 ROOT            = ..
62 STUBPREFIX      = $(PROJECT)stub
63
64 PKGINDEX        = "$(TMP_DIR)\pkgIndex.tcl"
65
66 ITCLLIBNAME     = itcl$(ITCL_VERSION)$(SUFX).$(EXT)
67 ITCLLIB         = "$(ITCLDIR)\win\$(OUT_DIR)\$(ITCLLIBNAME)"
68 ITKIMPLIB       = "$(OUT_DIR)\$(PROJECT)$(ITK_VERSION)$(SUFX).lib"
69 ITKSTUBLIBNAME  = $(STUBPREFIX)$(ITK_VERSION).lib
70 ITKSTUBLIB      = "$(OUT_DIR)\$(ITKSTUBLIBNAME)"
71
72 !if $(TCL_DOES_STUBS)
73 ITKLIBNAME      = $(PROJECT)$(ITK_VERSION)$(SUFX).$(EXT)
74 ITCLIMPLIBNAME  = itcl$(ITCL_VERSION)$(SUFX).$(EXT)
75 !else
76 ITKLIBNAME      = $(PROJECT)$(ITK_VERSION)80$(SUFX).$(EXT)
77 ITCLIMPLIBNAME  = itcl$(ITCL_VERSION)80$(SUFX).lib
78 !endif
79 ITKLIB          = "$(OUT_DIR)\$(ITKLIBNAME)"
80 ITCLIMPLIB      = "$(ITCLDIR)\win\Release\$(ITCLIMPLIBNAME)"
81
82
83 !if $(TCLINSTALL)
84 TKSTUBLIB       = "$(TCLDIR)\lib\tkstub$(TCL_VERSION).lib"
85 TKIMPLIB        = "$(TCLDIR)\lib\tk$(TCL_VERSION)$(DBGX).lib"
86 WISH            = "$(TCLDIR)\bin\wish$(TCL_VERSION)$(DBGX).exe"
87 TCL_LIBRARY     = 
88 TK_LIBRARY      = 
89 !else
90 TKSTUBLIB       = "$(TKDIR)\win\Release\tkstub$(TCL_VERSION).lib"
91 TKIMPLIB        = "$(TKDIR)\win\$(OUT_DIR)\tk$(TCL_VERSION)$(DBGX).lib"
92 WISH            = "$(TKDIR)\win\$(OUT_DIR)\wish$(TCL_VERSION)$(DBGX).exe"
93 TCL_LIBRARY     = "$(TCLDIR)\library"
94 TK_LIBRARY      = "$(TKDIR)\library"
95 !endif
96 ITCL_LIBRARY    = "$(ITCLDIR:\=/)/library"
97 ITK_LIBRARY     = "$(ROOT)/library
98
99 ITCLSTUBLIBNAME = itclstub$(ITCL_VERSION).lib
100 ITCLSTUBLIB     = "$(ITCLDIR)\win\Release\$(ITCLSTUBLIBNAME)"
101
102 ### For Tcl 8.0
103 !if !$(TCL_DOES_STUBS)
104 TCLSTUBLIB      = $(TCLIMPLIB)
105 TKSTUBLIB       = $(TKIMPLIB)
106 ITCLSTUBLIB     = $(ITCLIMPLIB)
107 !endif
108
109
110 BIN_INSTALL_DIR         = $(_INSTALLDIR)\bin
111 DOC_INSTALL_DIR         = $(_INSTALLDIR)\doc
112 LIB_INSTALL_DIR         = $(_INSTALLDIR)\lib
113 SCRIPT_INSTALL_DIR      = $(_INSTALLDIR)\lib\itk$(ITK_DOTVERSION)
114 INCLUDE_INSTALL_DIR     = $(_INSTALLDIR)\include
115
116 ITKOBJS = \
117         $(TMP_DIR)\itk_archetype.obj \
118         $(TMP_DIR)\itk_cmds.obj \
119         $(TMP_DIR)\itk_option.obj \
120         $(TMP_DIR)\itk_util.obj \
121 !if !$(STATIC_BUILD)
122         $(TMP_DIR)\dllEntryPoint.obj \
123         $(TMP_DIR)\itk.res \
124 !endif
125 !if $(TCL_DOES_STUBS)
126         $(TMP_DIR)\itkStubInit.obj
127 !endif
128
129 ITKSTUBOBJS = \
130 !if $(TCL_DOES_STUBS)
131     $(TMP_DIR)\itkStubLib.obj
132 !endif
133
134 GENERICDIR      = $(ROOT)\generic
135 DOCDIR          = $(ROOT)\doc
136 WINDIR          = $(ROOT)\win
137 RCDIR           = $(ROOT)\win\rc
138 TOOLSDIR        = ..\..\tools
139
140 #---------------------------------------------------------------------
141 # Link flags
142 #---------------------------------------------------------------------
143
144 !if $(DEBUG)
145 ldebug  = -debug:full -debugtype:cv
146 !else
147 ldebug  = -release -opt:ref -opt:icf,3
148 !endif
149
150 # declarations common to all linker options
151 lflags  = -nologo -machine:$(MACHINE) $(ldebug)
152
153 !if $(PROFILE)
154 lflags  = $(lflags) -profile
155 !endif
156
157 !if $(ALIGN98_HACK) && !$(STATIC_BUILD)
158 # align sections for PE size savings.
159 lflags  = $(lflags) -opt:nowin98
160 !else if !$(ALIGN98_HACK) && $(STATIC_BUILD)
161 # align sections for speed in loading by choosing the virtual page size.
162 lflags  = $(lflags) -align:4096
163 !endif
164
165 !if $(LOIMPACT)
166 lflags  = $(lflags) -ws:aggressive
167 !endif
168
169 ITK_LFLAGS = $(lflags) -subsystem:windows -dll
170 ITK_LLIBS       = $(TCLSTUBLIB) $(TKSTUBLIB) $(ITCLSTUBLIB)
171
172 !if exist("$(TCLDIR)\win\coffbase.txt")
173 ITK_DLLBASE     = -base:@$(TCLDIR)\win\coffbase.txt,itk
174 !else
175 ITK_DLLBASE     =
176 !endif
177
178 #---------------------------------------------------------------------
179 # Compile flags
180 #---------------------------------------------------------------------
181
182 !if $(DEBUG)
183 !if "$(MACHINE)" == "IA64"
184 cdebug = -Od -Zi
185 !else
186 cdebug = -Z7 -Od -WX
187 !endif
188 !else
189 # This cranks the optimization level up to max.
190 cdebug = -O2
191 !endif
192
193 # declarations common to all compiler options
194 cflags = -nologo -c -W3 -YX -Fp$(TMP_DIR)^\
195
196 !if $(PENT_0F_ERRATA)
197 cflags = $(cflags) -QI0f
198 !endif
199
200 !if $(ITAN_B_ERRATA)
201 cflags = $(cflags) -QIA64_Bx
202 !endif
203
204 !if $(MSVCRT)
205 crt = -MD$(DBGX)
206 !else
207 crt = -MT$(DBGX)
208 !endif
209
210 !if $(TCLINSTALL)
211 TCL_INCLUDES    = -I"$(TCLDIR)\include"
212 TK_INCLUDES     = 
213 !else
214 TCL_INCLUDES    = -I"$(TCLDIR)\generic" -I"$(TCLDIR)\win"
215 TK_INCLUDES     = -I"$(TKDIR)\generic" -I"$(TKDIR)\xlib"
216 !endif
217
218 ITK_INCLUDES    = -I$(WINDIR) -I$(GENERICDIR)
219 ITCL_INCLUDES   = -I"$(ITCLDIR)\generic"
220 ITK_DEFINES     = -DBUILD_itk -DTCL_THREADS=1
221 ITK_EXE_CFLAGS  = $(cdebug) $(cflags) $(crt) $(ITCL_INCLUDES) $(ITK_INCLUDES) \
222                 $(TCL_INCLUDES) $(TK_INCLUDES) $(ITK_DEFINES)
223
224 ### By convention, static builds do not use Stubs.  This is just a practice,
225 ### not a technical limitation.
226 !if $(STATIC_BUILD)
227 ITK_CFLAGS      = $(ITK_EXE_CFLAGS) -DSTATIC_BUILD
228 !elseif $(TCL_DOES_STUBS)
229 ITK_CFLAGS      = $(ITK_EXE_CFLAGS) -DUSE_TCL_STUBS -DUSE_TK_STUBS -DUSE_ITCL_STUBS
230 !else
231 ITK_CFLAGS      = $(ITK_EXE_CFLAGS)
232 !endif
233
234 #---------------------------------------------------------------------
235 # Project specific targets
236 #---------------------------------------------------------------------
237
238 all :     setup $(ITKLIB) $(ITKSTUBLIB)
239 release : setup $(ITKLIB) $(ITKSTUBLIB)
240 install : install-binaries install-docs
241
242 !if $(STATIC_BUILD)
243 test :
244         @echo test target not supported for a static library.
245 !else
246 test : setup $(ITKLIB) $(ITKSTUBLIB)
247         set TCL_LIBRARY=$(TCL_LIBRARY)
248         set TK_LIBRARY=$(TK_LIBRARY)
249         set ITCL_LIBRARY=$(ITCL_LIBRARY)
250         set ITK_LIBRARY=$(ITK_LIBRARY)
251         $(TCLSH) ..\tests\all.tcl $(TESTFLAGS) -loadfile <<
252         load [file normalize $(ITCLLIB:\=/)] Itcl
253         load [file normalize $(ITKLIB:\=/)] Itk
254 <<
255 !endif
256
257 setup :
258         @if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR)
259         @if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR)
260
261 $(ITKLIB): $(ITKOBJS)
262 !if $(STATIC_BUILD)
263         $(lib32) -nologo -machine:$(MACHINE) -out:$@ @<<
264 !else
265         $(link32) $(ITK_LFLAGS) $(ITK_DLLBASE) -out:$@ $(ITK_LLIBS) @<<
266 !endif
267                 $(ITKOBJS)
268 <<
269
270
271 !if $(TCL_DOES_STUBS)
272 $(ITKSTUBLIB) : $(ITKSTUBOBJS)
273         $(lib32) -nologo -out:$@ $(ITKSTUBOBJS)
274 !endif
275
276 install-binaries:
277         if not exist "$(_INSTALLDIR)" mkdir "$(_INSTALLDIR)"
278         if not exist "$(BIN_INSTALL_DIR)" mkdir "$(BIN_INSTALL_DIR)"
279         if not exist "$(LIB_INSTALL_DIR)" mkdir "$(LIB_INSTALL_DIR)"
280         if not exist "$(SCRIPT_INSTALL_DIR)" mkdir "$(SCRIPT_INSTALL_DIR)"
281         if not exist "$(INCLUDE_INSTALL_DIR)" mkdir "$(INCLUDE_INSTALL_DIR)"
282         copy $(ITKLIB) "$(SCRIPT_INSTALL_DIR)"
283 !if $(ITKSTUBLIB) != ""
284         copy $(ITKSTUBLIB) "$(LIB_INSTALL_DIR)"
285 !endif
286         copy $(ROOT)\generic\itk.h "$(INCLUDE_INSTALL_DIR)"
287         copy $(ROOT)\generic\itkDecls.h "$(INCLUDE_INSTALL_DIR)"
288         copy $(ROOT)\library\*.* "$(SCRIPT_INSTALL_DIR)"
289         echo if {[package vsatisfies 8.0 [package provide Tcl]]} {\
290                 > "$(SCRIPT_INSTALL_DIR)\pkgIndex.tcl"
291         echo ^ ^ ^ ^ set add 80>> "$(SCRIPT_INSTALL_DIR)\pkgIndex.tcl"
292         echo } else {>> "$(SCRIPT_INSTALL_DIR)\pkgIndex.tcl"
293         echo ^ ^ ^ ^ set add {}>> "$(SCRIPT_INSTALL_DIR)\pkgIndex.tcl"
294         echo }>> "$(SCRIPT_INSTALL_DIR)\pkgIndex.tcl"
295         echo if {[info exists ::tcl_platform(debug)] ^&^&\
296                 $$::tcl_platform(debug) ^&^& \>> "$(SCRIPT_INSTALL_DIR)\pkgIndex.tcl"
297         echo ^ ^ ^ ^ ^ ^ ^ ^ [file exists [file join $$dir\
298                 $(PROJECT)$(ITK_VERSION)$${add}g.dll]]}\
299                 {>> "$(SCRIPT_INSTALL_DIR)\pkgIndex.tcl"
300         echo ^ ^ ^ ^ package ifneeded Itk $(ITK_DOTVERSION) [list load\
301                 [file join $$dir $(PROJECT)$(ITK_VERSION)$${add}g.dll]\
302                 Itk]>> "$(SCRIPT_INSTALL_DIR)\pkgIndex.tcl"
303         echo } else {>> "$(SCRIPT_INSTALL_DIR)\pkgIndex.tcl"
304         echo ^ ^ ^ ^ package ifneeded Itk $(ITK_DOTVERSION) [list load\
305                 [file join $$dir $(PROJECT)$(ITK_VERSION)$${add}.dll]\
306                 Itk]>> "$(SCRIPT_INSTALL_DIR)\pkgIndex.tcl"
307         echo }>> "$(SCRIPT_INSTALL_DIR)\pkgIndex.tcl"
308         echo unset add>> "$(SCRIPT_INSTALL_DIR)\pkgIndex.tcl"
309
310
311 #---------------------------------------------------------------------
312 # Regenerate the stubs files.
313 #---------------------------------------------------------------------
314
315 !if !$(TCLINSTALL)
316 # Only from the sources of Tcl does genStubs.tcl exist.
317 genstubs:
318     $(TCLSH) $(TOOLSDIR)\genStubs.tcl $(GENERICDIR) \
319         $(GENERICDIR)\itk.decls
320 !else
321 genstubs:
322     @echo ERROR: Can't rebuild stubs tables without the Tcl source distribution
323 !endif
324
325 #---------------------------------------------------------------------
326 # Special case object file targets
327 #---------------------------------------------------------------------
328
329 # The following object is part of the stub library and should not
330 # be built as DLL objects but none of the symbols should be exported
331
332 $(TMP_DIR)\itkStubLib.obj : $(GENERICDIR)\itkStubLib.c
333     $(cc32) -DSTATIC_BUILD $(ITK_EXE_CFLAGS) -Zl -Fo$@ $?
334
335 #---------------------------------------------------------------------
336 # Inference rules.
337 #---------------------------------------------------------------------
338
339 {$(WINDIR)}.c{$(TMP_DIR)}.obj ::
340         $(cc32) $(ITK_CFLAGS) -Fo$(TMP_DIR)\ @<<
341 $<
342 <<
343
344 {$(GENERICDIR)}.c{$(TMP_DIR)}.obj ::
345         $(cc32) $(ITK_CFLAGS) -Fo$(TMP_DIR)\ @<<
346 $<
347 <<
348
349 {$(RCDIR)}.rc{$(TMP_DIR)}.res :
350         $(rc32) -fo $@ -DDEBUG=$(DEBUG) $(ITK_INCLUDES) $(TCL_INCLUDES) $(ITCL_INCLUDES) $(ITK_DEFINES) $<
351
352 #---------------------------------------------------------------------
353 # Generate the windows help files.
354 #---------------------------------------------------------------------
355
356 HLPBASE         = $(PROJECT)$(ITK_VERSION)
357 HELPFILE        = $(OUT_DIR)\$(HLPBASE).hlp
358 HELPCNT         = $(OUT_DIR)\$(HLPBASE).cnt
359 DOCTMP_DIR      = $(OUT_DIR)\$(PROJECT)_docs
360 HELPRTF         = $(DOCTMP_DIR)\$(PROJECT).rtf
361 MAN2HELP        = $(DOCTMP_DIR)\man2help.tcl
362 MAN2HELP2       = $(DOCTMP_DIR)\man2help2.tcl
363 INDEX           = $(DOCTMP_DIR)\index.tcl
364 BMP             = $(DOCTMP_DIR)\toaster.bmp
365 BMP_NOPATH      = toaster.bmp
366 MAN2TCL         = $(DOCTMP_DIR)\man2tcl.exe
367
368 winhelp: docsetup $(HELPFILE)
369
370 docsetup:
371         @if not exist $(DOCTMP_DIR)\nul mkdir $(DOCTMP_DIR)
372
373 $(MAN2HELP) $(MAN2HELP2) $(INDEX): $(TCLTOOLSDIR)\$$(@F)
374         copy $(TCLTOOLSDIR)\$(@F) $(@D)
375
376 $(BMP):
377         copy $(WINDIR)\$(@F) $(@D)
378
379 $(HELPFILE): $(HELPRTF) $(BMP)
380         cd $(DOCTMP_DIR)
381         start /wait hcrtf.exe -x <<$(PROJECT).hpj
382 [OPTIONS]
383 COMPRESS=12 Hall Zeck
384 LCID=0x409 0x0 0x0 ; English (United States)
385 TITLE=[Incr Tk] Reference Manual
386 BMROOT=.
387 CNT=$(@B).cnt
388 HLP=$(@B).hlp
389
390 [FILES]
391 $(PROJECT).rtf
392
393 [WINDOWS]
394 main="[Incr Tk] Reference Manual",,27648,(r15263976),(r65280)
395
396 [CONFIG]
397 BrowseButtons()
398 CreateButton(1, "Web", ExecFile("http://www.tcl.tk"))
399 CreateButton(2, "SF", ExecFile("http://sf.net/projects/incrtcl"))
400 CreateButton(3, "Wiki", ExecFile("http://wiki.tcl.tk"))
401 CreateButton(4, "FAQ", ExecFile("http://www.purl.org/NET/Tcl-FAQ/"))
402 <<
403         cd $(MAKEDIR)
404         copy "$(DOCTMP_DIR)\$(@B).hlp" "$(OUT_DIR)"
405         copy "$(DOCTMP_DIR)\$(@B).cnt" "$(OUT_DIR)"
406
407 $(MAN2TCL): $(TCLTOOLSDIR)\$$(@B).c
408         $(cc32) -nologo -G4 -ML -O2 -Fo$(@D)\ $(TCLTOOLSDIR)\$(@B).c -link -out:$@
409
410 $(HELPRTF): $(MAN2TCL) $(MAN2HELP) $(MAN2HELP2) $(INDEX)
411         $(TCLSH) $(MAN2HELP) -bitmap $(BMP_NOPATH) $(PROJECT) $(ITK_VERSION) $(DOCDIR:\=/)
412
413 install-docs:
414 !if exist($(HELPFILE))
415         @xcopy /i /y "$(HELPFILE)" "$(DOC_INSTALL_DIR)\"
416         @xcopy /i /y "$(HELPCNT)" "$(DOC_INSTALL_DIR)\"
417         $(TCLSH) <<
418 puts "Installing $(PROJECT)'s helpfile contents into Tcl's ..."
419 set f [open {$(DOC_INSTALL_DIR:\=/)/tcl$(TCL_VERSION).cnt} r]
420 while {![eof $$f]} {
421     if {[regexp {:Include $(PROJECT)([0-9]{2}).cnt} [gets $$f] dummy ver]} {
422         if {$$ver == $(ITK_VERSION)} {
423             puts "Already installed."
424             exit
425         } else {
426             # do something here logical to remove (or replace) it.
427             puts "$$ver != $(ITK_VERSION), unfinished code path, die, die!"
428             exit 1
429         }
430     }
431 }
432 close $$f
433 set f [open {$(DOC_INSTALL_DIR:\=/)/tcl$(TCL_VERSION).cnt} a]
434 puts $$f {:Include $(HLPBASE).cnt}
435 close $$f
436 <<
437         start /wait winhlp32 -g $(DOC_INSTALL_DIR)\tcl$(TCL_VERSION).hlp
438 !endif
439
440 #---------------------------------------------------------------------
441 # Clean up
442 #---------------------------------------------------------------------
443
444 tidy :
445         -del $(TMP_DIR)\*.pch
446         -del $(TMP_DIR)\*.obj
447         -del $(TMP_DIR)\*.res
448
449 clean : tidy
450         -del $(OUT_DIR)\*.exp
451         -del $(OUT_DIR)\*.lib
452         -del $(OUT_DIR)\*.dll
453
454 hose : clean
455         -rmdir $(OUT_DIR)
456         -rmdir $(TMP_DIR)