Diff

Differences From Artifact [ec7be57b0b]:

To Artifact [d3695d1fba]:


    26     26   rm -rf 'build' 'out' 'inst'
    27     27   mkdir 'out' 'inst' || exit 1
    28     28   
    29     29   
    30     30   (
    31     31   	cp -r 'buildsrc' 'build'
    32     32   	cd "${BUILDDIR}" || exit 1
           33  +
           34  +	# Fix up archives that Tcl gets wrong
           35  +	for archive in ../../../tcl/inst/lib/dde*/tcldde*.a ../../../tcl/inst/lib/reg*/tclreg*.a; do
           36  +		if [ ! -f "${archive}" ]; then
           37  +			continue
           38  +		fi
           39  +
           40  +		rm -rf __TEMP__
           41  +		(
           42  +			mkdir __TEMP__ || exit 1
           43  +			cd __TEMP__
           44  +
           45  +			## Patch archive name
           46  +			archive="../${archive}"
           47  +
           48  +			"${AR:-ar}" x "${archive}" || exit 1
           49  +
           50  +			rm -f "${archive}"
           51  +
           52  +			"${AR:-ar}" cr "${archive}" *.o || exit 1
           53  +			"${RANLIB:-ranlib}" "${archive}" || true
           54  +		)
           55  +	done
           56  +
           57  +	# Determine how we invoke a Tcl interpreter
           58  +	for testsh in "${TCLSH_NATIVE:-false}" tclsh tclsh8.4 tclsh8.5 tclsh8.6 "${TCLKIT:-tclkit}"; do
           59  +		if echo 'exit 0' | "${testsh}" >/dev/null 2>/dev/null; then
           60  +			TCLSH_NATIVE="${testsh}"
           61  +
           62  +			break
           63  +		fi
           64  +	done
    33     65   
    34     66   	# Cleanup, just incase the incoming directory was not pre-cleaned
    35     67   	${MAKE:-make} distclean >/dev/null 2>/dev/null
           68  +	rm -rf 'starpack.vfs'
           69  +
           70  +	# Create VFS directory
           71  +	mkdir "starpack.vfs"
           72  +	mkdir "starpack.vfs/lib"
           73  +
           74  +	## Copy in all built directories
           75  +	cp -r "${OTHERPKGSDIR}"/*/out/* 'starpack.vfs/'
           76  +
           77  +	## Rename the "vfs" package directory to what "boot.tcl" expects
           78  +	mv 'starpack.vfs/lib'/vfs* 'starpack.vfs/lib/vfs'
           79  +
           80  +	## Install "boot.tcl"
           81  +	cp 'boot.tcl' 'starpack.vfs/'
    36     82   
    37     83   	# Figure out if zlib compiled (if not, the system zlib will be used and we
    38     84   	# will need to have that present)
    39     85   	ZLIBDIR="$(cd "${OTHERPKGSDIR}/zlib/inst" 2>/dev/null && pwd)"
    40     86   	export ZLIBDIR
    41     87   	if [ -z "${ZLIBDIR}" -o ! -f "${ZLIBDIR}/lib/libz.a" ]; then
    42     88   		unset ZLIBDIR
................................................................................
    45     91   	# Copy user specified kit.rc and kit.ico in to build directory, if found
    46     92   	cp "${KITCREATOR_ICON}" "${BUILDDIR}/kit.ico"
    47     93   	cp "${KITCREATOR_RC}" "${BUILDDIR}/kit.rc"
    48     94   
    49     95   	# Include extra objects as required
    50     96   	## Initialize list of extra objects
    51     97   	EXTRA_OBJS=""
           98  +	export EXTRA_OBJS
    52     99   
    53    100   	## Tk Resources (needed for Win32 support) -- remove kit-found resources to prevent the symbols from being in conflict
    54    101   	TKDIR="$(cd "${OTHERPKGSDIR}/tk/inst" && pwd)"
    55    102   	TKRSRC="${TKDIR}/lib/tkbase.res.o"
    56    103   	if [ -n "${TKDIR}" -a -f "${TKRSRC}" ]; then
    57    104   		EXTRA_OBJS="${EXTRA_OBJS} ${TKRSRC}"
    58    105   
    59    106   		echo ' *** Removing "kit.rc" since we have Tk with its own resource file'
    60    107   
    61    108   		rm -f "${BUILDDIR}/kit.rc"
    62    109   	fi
    63    110   
    64         -	## Export to the environment, to be picked up by the "configure" script
    65         -	export EXTRA_OBJS
          111  +	# Determine if target is KitDLL or KitSH
          112  +	if [ "${KITTARGET}" = "kitdll" ]; then
          113  +		CONFIGUREEXTRA="${CONFIGUREEXTRA} --enable-kitdll"
          114  +	fi
    66    115   
    67         -	# Compile Kitsh
          116  +	# Compile Kit
    68    117   	if [ -z "${ZLIBDIR}" ]; then
    69    118   		echo "Running: ./configure --with-tcl=\"${TCLCONFIGDIR}\" ${CONFIGUREEXTRA}"
    70    119   
    71    120   		./configure --with-tcl="${TCLCONFIGDIR}" ${CONFIGUREEXTRA}
    72    121   	else
    73    122   		echo "Running: ./configure --with-tcl=\"${TCLCONFIGDIR}\" --with-zlib=\"${ZLIBDIR}\" ${CONFIGUREEXTRA}"
    74    123   
    75    124   		./configure --with-tcl="${TCLCONFIGDIR}" --with-zlib="${ZLIBDIR}" ${CONFIGUREEXTRA}
    76    125   	fi
    77    126   
    78         -	echo "Running: ${MAKE:-make}"
    79         -	${MAKE:-make} || exit 1
          127  +	echo "Running: ${MAKE:-make} TCLSH_NATIVE=\"${TCLSH_NATIVE}\""
          128  +	${MAKE:-make} TCLSH_NATIVE="${TCLSH_NATIVE}" || exit 1
    80    129   
    81    130   	# Strip the kit of all symbols, if possible
    82    131   	"${STRIP:-strip}" kit >/dev/null 2>/dev/null
          132  +	"${STRIP:-strip}" -g libtclkit* >/dev/null 2>/dev/null
          133  +
          134  +	# Fix up Win32 DLL names
          135  +	## .DLL.A -> .LIB
          136  +	for file in libtclkit*.dll.a; do
          137  +		if [ ! -f "${file}" ]; then
          138  +			continue
          139  +		fi
          140  +
          141  +		newfile="$(basename "${file}" .dll.a).lib"
          142  +		mv "${file}" "${newfile}"
          143  +	done
          144  +
          145  +	## .DLL.DEF -> .DEF
          146  +	for file in libtclkit*.dll.def; do
          147  +		if [ ! -f "${file}" ]; then
          148  +			continue
          149  +		fi
          150  +
          151  +		newfile="$(basename "${file}" .dll.def).def"
          152  +		mv "${file}" "${newfile}"
          153  +	done
          154  +
          155  +	# Determine name of created kit
          156  +	KITTARGET_NAME='__error__'
          157  +	if [ "${KITTARGET}" = "kitdll" ]; then
          158  +		## Find the library created
          159  +		for chkkittarget in libtclkit*.*; do
          160  +			if [ ! -f "${chkkittarget}" ]; then
          161  +				continue
          162  +			fi
          163  +
          164  +			if echo "${chkkittarget}" | egrep '\.(lib|def|a)$'; then
          165  +				continue
          166  +			fi
          167  +
          168  +			KITTARGET_NAME="${chkkittarget}"
          169  +
          170  +			break
          171  +		done
    83    172   
    84         -	# Create VFS directory
    85         -	mkdir "starpack.vfs"
    86         -	mkdir "starpack.vfs/lib"
          173  +		## Also create an executable named "kit" so that we can run it later
          174  +		${MAKE:-make} tclsh
          175  +		mv tclsh kit
          176  +	else
          177  +		## The executable is always named "kit"
          178  +		KITTARGET_NAME='kit'
          179  +	fi
          180  +	export KITTARGET_NAME
    87    181   
    88         -	## Copy in all built directories
    89         -	cp -r "${OTHERPKGSDIR}"/*/out/* 'starpack.vfs/'
          182  +	if [ "x${KITTARGET_NAME}" = 'x__error__' ]; then
          183  +		echo "Failed to locate kit target!" >&2
    90    184   
    91         -	## Rename the "vfs" package directory to what "boot.tcl" expects
    92         -	mv 'starpack.vfs/lib'/vfs* 'starpack.vfs/lib/vfs'
    93         -
    94         -	## Install "boot.tcl"
    95         -	cp 'boot.tcl' 'starpack.vfs/'
          185  +		exit 1
          186  +	fi
    96    187   
    97    188   	# Intall VFS onto kit
    98    189   	## Determine if we have a Tclkit to do this work
    99    190   	TCLKIT="${TCLKIT:-tclkit}"
   100    191   	if echo 'exit 0' | "${TCLKIT}" >/dev/null 2>/dev/null; then
   101    192   		## Install using existing Tclkit
   102    193   		### Call installer
   103         -		echo "Running: \"${TCLKIT}\" installvfs.tcl kit starpack.vfs \"${ENABLECOMPRESSION}\""
   104         -		"${TCLKIT}" installvfs.tcl kit starpack.vfs "${ENABLECOMPRESSION}" || exit 1
          194  +		echo "Running: \"${TCLKIT}\" installvfs.tcl \"${KITTARGET_NAME}\" starpack.vfs \"${ENABLECOMPRESSION}\""
          195  +		"${TCLKIT}" installvfs.tcl "${KITTARGET_NAME}" starpack.vfs "${ENABLECOMPRESSION}" || exit 1
   105    196   	else
   106    197   		## Bootstrap (cannot cross-compile)
   107    198   		### Call installer
   108    199   		cp kit runkit
   109         -		echo "set argv [list kit starpack.vfs {${ENABLECOMPRESSION}}]" > setup.tcl
          200  +		echo "set argv [list {${KITTARGET_NAME}} starpack.vfs {${ENABLECOMPRESSION}}]" > setup.tcl
   110    201   		echo 'if {[catch { clock seconds }]} { proc clock args { return 0 } }' >> setup.tcl
   111    202   		echo 'source installvfs.tcl' >> setup.tcl
   112    203   
   113    204   		echo 'Running: echo | ./runkit'
   114         -		echo | ./runkit || exit 1
          205  +		echo | ./runkit setup.tcl || exit 1
          206  +	fi
          207  +
          208  +	# Cleanup
          209  +	if [ "${KITTARGET}" = "kitdll" ]; then
          210  +		## Remove built interpreters if we are building KitDLL --
          211  +		## they're just tiny stubs anyway
          212  +		rm -f kit runkit
   115    213   	fi
   116    214   
   117    215   	exit 0
   118    216   ) || exit 1
   119    217   
   120    218   exit 0