summaryrefslogtreecommitdiff
path: root/itcl/itcl/win/makefile.vc
blob: 92fb39c2eafaa4c62dd7c401da430a395e6a080f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
######################################################################
# Visual C++ 5.0+ makefile for [Incr Tcl]
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
# 
# Copyright (c) 1993-1998 Lucent Technologies, Inc.
# RCS: $Id$
######################################################################
# All needed information is derived from running vcvars32.bat
#
# NOTE: Be sure to modify the "config.vc" file in the toplevel directory
#   before running this makefile.
######################################################################
#  Do not modify this file!  modify config.vc to effect the build.
######################################################################

!include "..\..\rules.vc"
!include "..\..\config.vc"
!include "..\..\pkg.vc"

BINROOT		= .
ROOT		= ..
NAMEPREFIX	= itcl
STUBPREFIX	= $(NAMEPREFIX)stub

!if $(DEBUG)
TMPNAME		= Debug
DBGX		= d
!else
TMPNAME		= Release
DBGX		=
!endif

TMP_DIR		= $(BINROOT)\$(TMPNAME)

!ifndef OUT_DIR
OUT_DIR		= $(TMP_DIR)
!endif

PKGINDEX	= "$(TMP_DIR)\pkgIndex.tcl"

!if $(STATIC_BUILD)
ITCLOUTNAME	= $(NAMEPREFIX)$(ITCL_VERSION)s$(DBGX)
ITCLTARGET	= "$(OUT_DIR)\$(ITCLOUTNAME).lib"
!else
ITCLOUTNAME	= $(NAMEPREFIX)$(ITCL_VERSION)$(DBGX)
ITCLIMPLIB	= "$(OUT_DIR)\$(ITCLOUTNAME).lib"
ITCLTARGET	= "$(OUT_DIR)\$(ITCLOUTNAME).dll"
!endif

!if $(ISTCLINSTALL)
TCLSTUBLIB	= "$(TCLROOT)\lib\tclstub$(TCL_VERSION).lib"
TCLIMPLIB	= "$(TCLROOT)\lib\tcl$(TCL_VERSION)$(DBGX).lib"
TCLSH		= "$(TCLROOT)\bin\tclsh$(TCL_VERSION)$(DBGX).exe"
!else
TCLSTUBLIB	= "$(TCLROOT)\win\Release\tclstub$(TCL_VERSION).lib"
TCLIMPLIB	= "$(TCLROOT)\win\$(OUT_DIR)\tcl$(TCL_VERSION)$(DBGX).lib"
TCLSH		= "$(TCLROOT)\win\$(OUT_DIR)\tclsh$(TCL_VERSION)$(DBGX).exe"
!endif

ITCLSTUBLIBNAME	= $(STUBPREFIX)$(ITCL_VERSION)$(DBGX).lib
ITCLSTUBLIB	= "$(OUT_DIR)\$(ITCLSTUBLIBNAME)"

LIB_INSTALL_DIR		= $(INSTALLDIR)\lib
BIN_INSTALL_DIR		= $(INSTALLDIR)\bin
SCRIPT_INSTALL_DIR	= $(INSTALLDIR)\lib\itcl$(ITCL_DOTVERSION)
INCLUDE_INSTALL_DIR	= $(INSTALLDIR)\include

ITCLSHOBJS = \
	$(TMP_DIR)\tclAppInit.obj

ITCLOBJS = \
	$(TMP_DIR)\itcl_bicmds.obj \
	$(TMP_DIR)\itcl_class.obj \
	$(TMP_DIR)\itcl_cmds.obj \
	$(TMP_DIR)\itcl_ensemble.obj \
	$(TMP_DIR)\itcl_linkage.obj \
	$(TMP_DIR)\itcl_migrate.obj \
	$(TMP_DIR)\itcl_methods.obj \
	$(TMP_DIR)\itcl_objects.obj \
	$(TMP_DIR)\itcl_obsolete.obj \
	$(TMP_DIR)\itcl_parse.obj \
	$(TMP_DIR)\itcl_util.obj \
!if $(STATIC_BUILD) == 0
	$(TMP_DIR)\dllEntryPoint.obj \
	$(TMP_DIR)\dllResource.obj \
!endif
	$(TMP_DIR)\itclStubInit.obj

ITCLSTUBOBJS = \
	$(TMP_DIR)\itclStubLib.obj

WINDIR		= $(ROOT)\win
GENERICDIR	= $(ROOT)\generic
RCDIR		= $(ROOT)\win\rc

######################################################################
# Link flags
######################################################################

!if $(DEBUG)
ldebug = -debug:full -debugtype:cv -pdb:none
!else
ldebug = -release -opt:ref
!endif

# declarations common to all linker options
lcommon = -nologo -link50compat -machine:$(MACHINE)

ITCL_LFLAGS = $(lcommon) -subsystem:windows -dll

!if $(USE_TCL_STUBS) == 0
ITCL_LLIBS	= $(TCLIMPLIB)
!else
ITCL_LLIBS	= $(TCLSTUBLIB)
!endif

######################################################################
# Compile flags
######################################################################

!IF $(DEBUG) == 0
!IF "$(MACHINE)" == "ALPHA"
# MSVC on Alpha doesn't understand -Ot
cdebug = -O2i
!ELSE
cdebug = -Ox
!ENDIF
!ELSE
!if $(MSDEV_VER) < 6
cdebug = -Zi -Od -WX
!else
cdebug = -ZI -Od -WX
!endif
!ENDIF

!if $(STATIC_BUILD)
cdll	=
!else
cdll	= -GD
!endif

# declarations common to all compiler options
ccommon = -nologo -c -W3 -YX -Fp$(TMP_DIR)\ 

!if $(STATIC_BUILD) && $(NOMSVCRT)
crt	= -MT$(DBGX)
!else
crt	= -MD$(DBGX)
!endif

!if $(ISTCLINSTALL)
TCL_INCLUDES	= -I"$(TCLROOT)\include"
!else
TCL_INCLUDES	= -I"$(TCLROOT)\generic"
!endif

ITCL_INCLUDES	= -I$(WINDIR) -I$(GENERICDIR)
ITCL_DEFINES	= -DBUILD_itcl -DTCL_THREADS=1
ITCL_EXE_CFLAGS	= $(ccommon) $(cdebug) $(crt) $(cdll) $(ITCL_INCLUDES) \
		$(ITCL_DEFINES) $(TCL_INCLUDES)

!if $(USE_TCL_STUBS)
ITCL_CFLAGS	= $(ITCL_EXE_CFLAGS) -DUSE_TCL_STUBS
!else
ITCL_CFLAGS	= $(ITCL_EXE_CFLAGS)
!endif

######################################################################
# Project specific targets
######################################################################

all :     setup $(ITCLTARGET) $(ITCLSTUBLIB)
release : setup $(ITCLTARGET) $(ITCLSTUBLIB)

!if $(STATIC_BUILD)
test :
	@echo test target not supported for a static library.
!else
#test :    setup $(ITCLTARGET) $(ITCLSTUBLIB) $(PKGINDEX)
#	-@copy $(TCLDLL) $(TMP_DIR)
#	$(TCLSH) <<
#cd ../tests
#lappend auto_path ../win/$(TMP_DIR)
#set env(ITCL_LIBRARY) ../library
#source all
#<<
!endif

$(PKGINDEX) :
	-@copy pkgIndex.tcl $@

setup :
	@$(vcvars) > nul
	@if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR) &\
		echo Created directory '$(TMP_DIR)'
	@if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR) &\
		echo Created directory '$(OUT_DIR)'

$(ITCLTARGET): $(ITCLOBJS)
!if $(STATIC_BUILD)
	$(lib32) -nologo -machine:$(MACHINE) -out:$@ @<<
!else
	$(link32) $(ITCL_LFLAGS) -out:$@ $(ITCL_LLIBS) @<<
!endif
		$(ITCLOBJS)
<<

!if $(DEBUG) == 0
$(ITCLSTUBLIB) : $(ITCLSTUBOBJS)
	$(lib32) -nologo -out:$@ $(ITCLSTUBOBJS)
!else
$(ITCLSTUBLIB) :
!endif

install : all
	if not exist "$(INSTALLDIR)" mkdir "$(INSTALLDIR)"
	if not exist "$(BIN_INSTALL_DIR)" mkdir "$(BIN_INSTALL_DIR)"
	if not exist "$(LIB_INSTALL_DIR)" mkdir "$(LIB_INSTALL_DIR)"
	if not exist "$(SCRIPT_INSTALL_DIR)" mkdir "$(SCRIPT_INSTALL_DIR)"
	if not exist "$(INCLUDE_INSTALL_DIR)" mkdir "$(INCLUDE_INSTALL_DIR)"
	copy $(ITCLTARGET) "$(SCRIPT_INSTALL_DIR)"
	-copy $(ITCLSTUBLIB) "$(LIB_INSTALL_DIR)"
	copy $(ROOT)\generic\itcl.h "$(INCLUDE_INSTALL_DIR)"
	copy $(ROOT)\generic\itclDecls.h "$(INCLUDE_INSTALL_DIR)"
	copy $(ROOT)\library\*.* "$(SCRIPT_INSTALL_DIR)"
	echo package ifneeded Itcl $(ITCL_DOTVERSION) [list load [file join $$dir $(ITCLOUTNAME).dll] Itcl] > \
		"$(SCRIPT_INSTALL_DIR)\pkgIndex.tcl"

######################################################################
# Regenerate the stubs files.
######################################################################

!if $(ISTCLINSTALL) == 0
# Only from the sources of Tcl does genStubs.tcl exist.
genstubs:
	$(TCLSH) $(TCLROOT)\tools\genStubs.tcl $(GENERICDIR) \
        	$(GENERICDIR)\itcl.decls $(GENERICDIR)\itclInt.decls
!endif

######################################################################
# Special case object file targets
######################################################################

# The following object is part of the stub library and should not
# be built as DLL objects but none of the symbols should be exported

$(TMP_DIR)\itclStubLib.obj : $(GENERICDIR)\itclStubLib.c
	$(cc32) -DSTATIC_BUILD $(ITCL_EXE_CFLAGS) -Zl -Fo$@ $?

$(TMP_DIR)\dllResource.obj : $(TMP_DIR)\itcl.res
	$(cvtres32) -nologo -machine:$(MACHINE) -out:$@ $?

######################################################################
# Inference rules.  Use batch-mode when supported.
######################################################################

!if $(_NMAKE_VER) < 162
{$(WINDIR)}.c{$(TMP_DIR)}.obj :
!else
{$(WINDIR)}.c{$(TMP_DIR)}.obj ::
!endif
	$(cc32) -DDLL_BUILD $(ITCL_CFLAGS) -Fo$(TMP_DIR)\ @<<
$<
<<

!if $(_NMAKE_VER) < 162
{$(GENERICDIR)}.c{$(TMP_DIR)}.obj :
!else
{$(GENERICDIR)}.c{$(TMP_DIR)}.obj ::
!endif
	$(cc32) -DDLL_BUILD $(ITCL_CFLAGS) -Fo$(TMP_DIR)\ @<<
$<
<<

{$(RCDIR)}.rc{$(TMP_DIR)}.res :
	$(rc32) -fo $@ -DDEBUG=$(DEBUG) $(ITCL_INCLUDES) $(TCL_INCLUDES) $(ITCL_DEFINES) $<

######################################################################
# Clean up
######################################################################

tidy :
	-del $(TMP_DIR)\*.pch
	-del $(TMP_DIR)\*.obj
	-del $(TMP_DIR)\*.res

clean : tidy
	-del $(OUT_DIR)\*.exp
	-del $(OUT_DIR)\*.lib
	-del $(OUT_DIR)\*.dll

hose : clean
	-rmdir $(OUT_DIR)
	-rmdir $(TMP_DIR)