Diff

Differences From Artifact [92a8d1c751]:

To Artifact [9c93a36278]:


    62     62   	# If we are building for Win32, we need to define "BUILD_tcl" so that
    63     63   	# TCL_STORAGE_CLASS gets defined as DLLEXPORT, to make static linking
    64     64   	# work
    65     65   	BUILDTYPE="$(basename "${TCLCONFIGDIR}")"
    66     66   	if [ "${BUILDTYPE}" = "win" ]; then
    67     67   		CPPFLAGS="${CPPFLAGS} -DBUILD_tcl=1"
    68     68   		export CPPFLAGS
           69  +
           70  +		if [ "${STATICMK4}" != "-1" ]; then
           71  +			if [ "${STATICMK4}" = "0" ]; then
           72  +				echo 'Warning: Metakit4 fails to build shared on Win32, converting to static linking'
           73  +
           74  +				STATICMK4="1"
           75  +			fi
           76  +		else
           77  +			STATICMK4="0"
           78  +		fi
           79  +		export STATICMK4
    69     80   	fi
    70     81   
    71         -
    72         -	# If we are building for KitDLL, compile as shared
    73         -	isshared="0"
    74         -	if [ "${KITTARGET}" = "kitdll" ]; then
    75         -		isshared="1"
    76         -
    77         -		echo "Running: ./configure --enable-shared --prefix=\"${INSTDIR}\" --exec-prefix=\"${INSTDIR}\" --with-tcl=\"${TCLCONFIGDIR}/../generic\" ${CONFIGUREEXTRA}"
    78         -		./configure --enable-shared --prefix="${INSTDIR}" --exec-prefix="${INSTDIR}" --with-tcl="${TCLCONFIGDIR}/../generic" ${CONFIGUREEXTRA}
           82  +	# Try to build as a shared object if requested
           83  +	if [ "${STATICMK4}" = "0" ]; then
           84  +		tryopts="--enable-shared --disable-shared"
           85  +	elif [ "${STATICMK4}" = "-1" ]; then
           86  +		tryopts="--enable-shared"
    79     87   	else
    80         -		echo "Running: ./configure --disable-shared --prefix=\"${INSTDIR}\" --exec-prefix=\"${INSTDIR}\" --with-tcl=\"${TCLCONFIGDIR}/../generic\" ${CONFIGUREEXTRA}"
    81         -		./configure --disable-shared --prefix="${INSTDIR}" --exec-prefix="${INSTDIR}" --with-tcl="${TCLCONFIGDIR}/../generic" ${CONFIGUREEXTRA}
           88  +		tryopts="--disable-shared"
    82     89   	fi
    83     90   
    84         -	echo "Running: ${MAKE:-make} tcllibdir=\"${INSTDIR}/lib\" AR=\"${AR:-ar}\" RANLIB=\"${RANLIB:-ranlib}\""
    85         -	${MAKE:-make} tcllibdir="${INSTDIR}/lib" AR="${AR:-ar}" RANLIB="${RANLIB:-ranlib}" && \
    86         -	${MAKE:-make} tcllibdir="${INSTDIR}/lib" AR="${AR:-ar}" RANLIB="${RANLIB:-ranlib}" install || (
           91  +	for tryopt in $tryopts __fail__; do
           92  +		# Clean up, if needed
           93  +		make distclean >/dev/null 2>/dev/null
    87     94   		rm -rf "${INSTDIR}"
    88     95   		mkdir "${INSTDIR}"
    89     96   
    90         -		exit 1
    91         -	) || exit 1
           97  +		if [ "${tryopt}" = "__fail__" ]; then
           98  +			exit 1
           99  +		fi
          100  +
          101  +		if [ "${tryopt}" == "--enable-shared" ]; then
          102  +			isshared="1"
          103  +		else
          104  +			isshared="0"
          105  +		fi
          106  +
          107  +		(
          108  +			echo "Running: ./configure $tryopt --prefix=\"${INSTDIR}\" --exec-prefix=\"${INSTDIR}\" --with-tcl=\"${TCLCONFIGDIR}/../generic\" ${CONFIGUREEXTRA}"
          109  +			./configure $tryopt --prefix="${INSTDIR}" --exec-prefix="${INSTDIR}" --with-tcl="${TCLCONFIGDIR}/../generic" ${CONFIGUREEXTRA}
          110  +
          111  +			echo "Running: ${MAKE:-make} tcllibdir=\"${INSTDIR}/lib\" AR=\"${AR:-ar}\" RANLIB=\"${RANLIB:-ranlib}\""
          112  +			${MAKE:-make} tcllibdir="${INSTDIR}/lib" AR="${AR:-ar}" RANLIB="${RANLIB:-ranlib}" || exit 1
          113  +
          114  +			echo "Running: ${MAKE:-make} tcllibdir=\"${INSTDIR}/lib\" AR=\"${AR:-ar}\" RANLIB=\"${RANLIB:-ranlib}\" install"
          115  +			${MAKE:-make} tcllibdir="${INSTDIR}/lib" AR="${AR:-ar}" RANLIB="${RANLIB:-ranlib}" install || exit 1
          116  +		) || continue
          117  +
          118  +		break
          119  +	done
          120  +
          121  +	# Clean up "libmk4.*", it's not needed
          122  +	rm -f "${INSTDIR}/lib"/libmk4.*
    92    123   
          124  +	# If we are building a shared version of Mk4tcl, put it in the VFS directory
    93    125   	if [ "${isshared}" = "1" ]; then
    94         -		# If we are building a shared version of Mk4tcl, put it in the VFS directory
    95    126   		cp -r "${INSTDIR}/lib" "${OUTDIR}"
    96    127   	fi
    97    128   
    98    129   	exit 0
    99    130   ) || exit 1
   100    131   
   101    132   exit 0