Index: tcc/build.sh ================================================================== --- tcc/build.sh +++ tcc/build.sh @@ -15,12 +15,13 @@ SRC="src/tcltcc-${TCLTCCVERS}.zip" SRCURL="https://tcltcc.googlecode.com/files/tcltcc${TCLTCCVERS}.zip" BUILDDIR="$(pwd)/build/tcltcc-0.4" OUTDIR="$(pwd)/out" INSTDIR="$(pwd)/inst" +PATCHSCRIPTDIR="$(pwd)/patchscripts" PATCHDIR="$(pwd)/patches" -export TCLTCCVERS SRC SRCURL BUILDDIR OUTDIR INSTDIR PATCHDIR +export TCLTCCVERS SRC SRCURL BUILDDIR OUTDIR INSTDIR PATCHSCRIPTDIR PATCHDIR # Set configure options for this sub-project LDFLAGS="${KC_TCLTCC_LDFLAGS}" CFLAGS="${KC_TCLTCC_CFLAGS}" CPPFLAGS="${KC_TCLTCC_CPPFLAGS}" @@ -59,20 +60,33 @@ cp -rp ../buildsrc/* './' fi # Apply required patches cd "${BUILDDIR}" || exit 1 + + # Install current Tcl headers + cp -r ../../../{tcl,tk}/inst/include/* include/ + for patch in "${PATCHDIR}/all"/tcltcc-${TCLTCCVERS}-*.diff "${PATCHDIR}/${TCL_VERSION}"/tcltcc-${TCLTCCVERS}-*.diff; do if [ ! -f "${patch}" ]; then continue fi echo "Applying: ${patch}" ${PATCH:-patch} -p1 < "${patch}" done - cd "${BUILDDIR}" || exit 1 + # Apply patch scripts if needed + for patchscript in "${PATCHSCRIPTDIR}"/*.sh; do + if [ -f "${patchscript}" ]; then + echo "Running patch script: ${patchscript}" + + ( + . "${patchscript}" + ) + fi + done # Try to build as a shared object if requested if [ "${STATICTCLTCC}" = "0" ]; then tryopts="--enable-shared --disable-shared" elif [ "${STATICTCLTCC}" = "-1" ]; then @@ -103,10 +117,14 @@ if [ "${isshared}" = "0" -a "${KITTARGET}" = "kitdll" ]; then CFLAGS="${SAVE_CFLAGS} -fPIC" else CFLAGS="${SAVE_CFLAGS}" fi + + if [ "${isshared}" = "0" ]; then + CFLAGS="${CFLAGS} -DCONFIG_TCC_STATIC=1" + fi export CFLAGS if [ "${isshared}" = '0' ]; then sed 's@USE_TCL_STUBS@XXX_TCL_STUBS@g' configure > configure.new else @@ -143,11 +161,10 @@ incDir="${pkgDir}/include" mkdir "${incDir}" touch include/windows.h cp -r include/* "${incDir}" - cp -r ../../../{tcl,tk}/inst/include/* "${incDir}" find "${incDir}" -name '*.a' | xargs rm -f # Install libraries libDir="${pkgDir}/lib" @@ -158,11 +175,11 @@ rm -f *.a *.o for file in *.c; do ofile="$(echo "${file}" | sed 's@\.c$@.o@')" "${CC:-gcc}" -I../include -I../../../../{tcl,tk}/inst/include/ -I../../../../tcl/build/tcl${TCLVERS}/generic/ -I../../../../tcl/build/tcl${TCLVERS}/unix/ -DUSE_TCL_STUBS=1 -c "${file}" -o "${ofile}" done - "${AR:-ar}" cu ../lib/libtcc1.a *.o + "${AR:-ar}" rcu ../lib/libtcc1.a *.o "${RANLIB:-ranlib}" ../lib/libtcc1.a ) cp lib/libtcc1.a "${libDir}" # Create VFS-insert ADDED tcc/patchscripts/tcltcc-0.4-addtclfuncs.sh Index: tcc/patchscripts/tcltcc-0.4-addtclfuncs.sh ================================================================== --- /dev/null +++ tcc/patchscripts/tcltcc-0.4-addtclfuncs.sh @@ -0,0 +1,28 @@ +#! /bin/bash + +function find_syms() { + if [ -z "${NM}" ]; then + if echo "${CC}" | sed 's@ .*$@@' | grep '[-]' >/dev/null; then + NM="$(echo "${CC}" | sed 's@ .*$@@;s@\(.*\)-[^-]*$@\1-nm@')" + else + NM='nm' + fi + fi + + # "${NM}" "${LIBTCL}" | sed 's@:.*$@@' | sed 's@.* @@' | grep '^Tcl_' | sort -u | while read -r sym; do + "${CC:-gcc}" ${CPPFLAGS} -E include/tcl.h | grep '^ *extern.*Tcl_'| sed 's@^ *extern *@@;s@(.*@@;s@.* *\** *@@' | sort -u | grep '^Tcl_' | grep -v ';$' | while read -r sym; do + echo " TCCSYM($sym)" + done +} + +add="$(find_syms)" + +awk -v add="${add}" '/TCCSyms tcc_syms.*=/{ + print + print add + next +} { print }' generic/tcc.h > generic/tcc.h.new +cat generic/tcc.h.new > generic/tcc.h +rm -f generic/tcc.h.new + +exit 0