Index: aclocal/shobj.m4 ================================================================== --- aclocal/shobj.m4 +++ aclocal/shobj.m4 @@ -79,36 +79,60 @@ SHLIBOBJS="$SHLIBOBJS `echo $obj | sed 's/\.o$/_shr.o/g'`" done ]) AC_DEFUN([DC_SYNC_RPATH], [ - OLD_LDFLAGS="$LDFLAGS" - - for tryrpath in "-Wl,-rpath" "-Wl,--rpath" "-Wl,-R"; do - LDFLAGS="$OLD_LDFLAGS $tryrpath -Wl,/tmp" - AC_LINK_IFELSE(AC_LANG_PROGRAM([], [ return(0); ]), [ - rpathldflags="$tryrpath" - break - ]) - done - unset tryrpath - - LDFLAGS="$OLD_LDFLAGS" - unset OLD_LDFLAGS - - ADDLDFLAGS="" - for opt in $LDFLAGS; do - if echo "$opt" | grep '^-L' >/dev/null; then - rpathdir=`echo "$opt" | sed 's@^-L *@@'` - ADDLDFLAGS="$ADDLDFLAGS $rpathldflags -Wl,$rpathdir" - fi - done - unset opt rpathldflags - - LDFLAGS="$LDFLAGS $ADDLDFLAGS" - - unset ADDLDFLAGS + AC_ARG_ENABLE([rpath], AS_HELP_STRING([--disable-rpath], [disable setting of rpath]), [ + if test "$enableval" = 'no'; then + set_rpath='no' + else + set_rpath='yes' + fi + ], [ + if test "$cross_compiling" = 'yes'; then + set_rpath='no' + else + ifelse($1, [], [ + set_rpath='yes' + ], [ + set_rpath='$1' + ]) + fi + ]) + + if test "$set_rpath" = 'yes'; then + OLD_LDFLAGS="$LDFLAGS" + + AC_CACHE_CHECK([how to set rpath], [rsk_cv_link_set_rpath], [ + AC_LANG_PUSH(C) + for tryrpath in "-Wl,-rpath" "-Wl,--rpath" "-Wl,-R"; do + LDFLAGS="$OLD_LDFLAGS $tryrpath -Wl,/tmp" + AC_LINK_IFELSE([AC_LANG_PROGRAM([], [ return(0); ])], [ + rsk_cv_link_set_rpath="$tryrpath" + break + ]) + done + AC_LANG_POP(C) + unset tryrpath + ]) + + LDFLAGS="$OLD_LDFLAGS" + unset OLD_LDFLAGS + + ADDLDFLAGS="" + for opt in $LDFLAGS $LIBS; do + if echo "$opt" | grep '^-L' >/dev/null; then + rpathdir="`echo "$opt" | sed 's@^-L *@@'`" + ADDLDFLAGS="$ADDLDFLAGS $rsk_cv_link_set_rpath -Wl,$rpathdir" + fi + done + unset opt + + LDFLAGS="$LDFLAGS $ADDLDFLAGS" + + unset ADDLDFLAGS + fi ]) AC_DEFUN([DC_CHK_OS_INFO], [ AC_CANONICAL_HOST AC_SUBST(SHOBJEXT) @@ -140,22 +164,21 @@ *) SHOBJEXT="sl" ;; esac ;; - aix[0-9].*) - SHOBJEXT="a" - ;; mingw32|mingw32msvc*) SHOBJEXT="dll" + AREXT='lib' CFLAGS="$CFLAGS -mms-bitfields" CPPFLAGS="$CPPFLAGS -mms-bitfields" SHOBJCPPFLAGS="-DPIC" SHOBJLDFLAGS='-shared -Wl,--dll -Wl,--enable-auto-image-base -Wl,--output-def,$[@].def,--out-implib,$[@].a' ;; msvc) SHOBJEXT="dll" + AREXT='lib' CFLAGS="$CFLAGS -nologo" SHOBJCPPFLAGS='-DPIC' SHOBJLDFLAGS='/LD /LINK /NODEFAULTLIB:MSVCRT' ;; cygwin*) @@ -168,11 +191,11 @@ ;; esac fi ]) -AC_DEFUN(SHOBJ_SET_SONAME, [ +AC_DEFUN([SHOBJ_SET_SONAME], [ SAVE_LDFLAGS="$LDFLAGS" AC_MSG_CHECKING([how to specify soname]) for try in "-Wl,--soname,$1" "Wl,-install_name,$1" '__fail__'; do @@ -195,5 +218,83 @@ ]) done AC_SUBST(SHOBJLDFLAGS) ]) + +dnl $1 = Description to show user +dnl $2 = Libraries to link to +dnl $3 = Variable to update (optional; default LIBS) +dnl $4 = Action to run if found +dnl $5 = Action to run if not found +AC_DEFUN([SHOBJ_DO_STATIC_LINK_LIB], [ + ifelse($3, [], [ + define([VAR_TO_UPDATE], [LIBS]) + ], [ + define([VAR_TO_UPDATE], [$3]) + ]) + + + AC_MSG_CHECKING([for how to statically link to $1]) + + trylink_ADD_LDFLAGS='' + for arg in $VAR_TO_UPDATE; do + case "${arg}" in + -L*) + trylink_ADD_LDFLAGS="${arg}" + ;; + esac + done + + SAVELIBS="$LIBS" + staticlib="" + found="0" + dnl HP/UX uses -Wl,-a,archive ... -Wl,-a,shared_archive + dnl Linux and Solaris us -Wl,-Bstatic ... -Wl,-Bdynamic + AC_LANG_PUSH([C]) + for trylink in "-Wl,-a,archive $2 -Wl,-a,shared_archive" "-Wl,-Bstatic $2 -Wl,-Bdynamic" "$2"; do + if echo " ${LDFLAGS} " | grep ' -static ' >/dev/null; then + if test "${trylink}" != "$2"; then + continue + fi + fi + + LIBS="${SAVELIBS} ${trylink_ADD_LDFLAGS} ${trylink}" + + AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [ + staticlib="${trylink}" + found="1" + + break + ]) + done + AC_LANG_POP([C]) + LIBS="${SAVELIBS}" + + if test "${found}" = "1"; then + new_RESULT='' + SAVERESULT="$VAR_TO_UPDATE" + for lib in ${SAVERESULT}; do + addlib='1' + for removelib in $2; do + if test "${lib}" = "${removelib}"; then + addlib='0' + break + fi + done + + if test "$addlib" = '1'; then + new_RESULT="${new_RESULT} ${lib}" + fi + done + VAR_TO_UPDATE="${new_RESULT} ${staticlib}" + + AC_MSG_RESULT([${staticlib}]) + + $4 + else + AC_MSG_RESULT([cant]) + + $5 + fi +]) + Index: aclocal/tcl.m4 ================================================================== --- aclocal/tcl.m4 +++ aclocal/tcl.m4 @@ -1,51 +1,93 @@ dnl Tcl M4 Routines + +dnl Find a runnable Tcl +AC_DEFUN([TCLEXT_FIND_TCLSH_PROG], [ + AC_CACHE_CHECK([runnable tclsh], [tcl_cv_tclsh_native_path], [ + dnl Try to find a runnable tclsh + if test -z "$TCLCONFIGPATH"; then + TCLCONFIGPATH=/dev/null/null + fi + + for try_tclsh in "$TCLSH_NATIVE" "$TCLCONFIGPATH/../bin/tclsh" \ + "$TCLCONFIGPATH/../bin/tclsh8.6" \ + "$TCLCONFIGPATH/../bin/tclsh8.5" \ + "$TCLCONFIGPATH/../bin/tclsh8.4" \ + `which tclsh 2>/dev/null` \ + `which tclsh8.6 2>/dev/null` \ + `which tclsh8.5 2>/dev/null` \ + `which tclsh8.4 2>/dev/null` \ + tclsh; do + if test -z "$try_tclsh"; then + continue + fi + if test -x "$try_tclsh"; then + if echo 'exit 0' | "$try_tclsh" 2>/dev/null >/dev/null; then + tcl_cv_tclsh_native_path="$try_tclsh" + + break + fi + fi + done + + if test "$TCLCONFIGPATH" = '/dev/null/null'; then + unset TCLCONFIGPATH + fi + ]) + + TCLSH_PROG="${tcl_cv_tclsh_native_path}" + AC_SUBST(TCLSH_PROG) +]) + dnl Must call AC_CANONICAL_HOST before calling us AC_DEFUN([TCLEXT_FIND_TCLCONFIG], [ - AC_MSG_CHECKING([for path to tclConfig.sh]) TCLCONFIGPATH="" AC_ARG_WITH([tcl], AS_HELP_STRING([--with-tcl], [directory containing tcl configuration (tclConfig.sh)]), [ if test "x$withval" = "xno"; then AC_MSG_ERROR([cant build without tcl]) fi TCLCONFIGPATH="$withval" ], [ - for dir in "/usr/$host_alias/lib" /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib64; do + if test "$cross_compiling" = 'no'; then + TCLEXT_FIND_TCLSH_PROG + tclConfigCheckDir="`echo 'puts [[tcl::pkgconfig get libdir,runtime]]' | "$TCLSH_PROG" 2>/dev/null`" + else + tclConfigCheckDir=/dev/null/null + fi + + if test "$cross_compiling" = 'no'; then + dirs="/usr/$host_alias/lib /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib64" + else + dirs='' + fi + + for dir in "$tclConfigCheckDir" $dirs; do if test -f "$dir/tclConfig.sh"; then TCLCONFIGPATH="$dir" break fi done ]) + AC_MSG_CHECKING([for path to tclConfig.sh]) + if test -z "$TCLCONFIGPATH"; then AC_MSG_ERROR([unable to locate tclConfig.sh. Try --with-tcl.]) fi - for try_tclsh in "$TCLCONFIGPATH/../bin/tclsh" \ - "$TCLCONFIGPATH/../bin/tclsh8.6" \ - "$TCLCONFIGPATH/../bin/tclsh8.5" \ - "$TCLCONFIGPATH/../bin/tclsh8.4" \ - `which tclsh 2>/dev/null` \ - `which tclsh8.6 2>/dev/null` \ - `which tclsh8.5 2>/dev/null` \ - `which tclsh8.4 2>/dev/null` \ - tclsh; do - if test -x "$try_tclsh"; then - break - fi - done - TCLSH_PROG="${try_tclsh}" - AC_SUBST(TCLCONFIGPATH) - AC_SUBST(TCLSH_PROG) AC_MSG_RESULT([$TCLCONFIGPATH]) + + dnl Find Tcl if we haven't already + if test -z "$TCLSH_PROG"; then + TCLEXT_FIND_TCLSH_PROG + fi ]) dnl Must define TCLCONFIGPATH before calling us (i.e., by TCLEXT_FIND_TCLCONFIG) AC_DEFUN([TCLEXT_LOAD_TCLCONFIG], [ AC_MSG_CHECKING([for working tclConfig.sh]) @@ -65,10 +107,18 @@ TCLEXT_FIND_TCLCONFIG TCLEXT_LOAD_TCLCONFIG AC_DEFINE_UNQUOTED([MODULE_SCOPE], [static], [Define how to declare a function should only be visible to the current module]) + + TCLEXT_BUILD='shared' + AC_ARG_ENABLE([static], AS_HELP_STRING([--enable-static], [enable a static build]), [ + if test "$enableval" = "yes"; then + TCLEXT_BUILD='static' + TCL_SUPPORTS_STUBS=0 + fi + ]) AC_ARG_ENABLE([stubs], AS_HELP_STRING([--disable-stubs], [disable use of Tcl stubs]), [ if test "$enableval" = "no"; then TCL_SUPPORTS_STUBS=0 else @@ -88,13 +138,24 @@ TCL_INCLUDE_SPEC="`eval echo "${TCL_INCLUDE_SPEC}"`" CFLAGS="${CFLAGS} ${TCL_INCLUDE_SPEC}" CPPFLAGS="${CPPFLAGS} ${TCL_INCLUDE_SPEC}" - DEFS="${DEFS} ${TCL_DEFS}" + TCL_DEFS_TCL_ONLY=`( + eval "set -- ${TCL_DEFS}" + for flag in "[$]@"; do + case "${flag}" in + -DTCL_*) + echo "${flag}" | sed "s/'/'\\''/g" | sed "s@^@'@;s@"'[$]'"@'@" | tr $'\n' ' ' + ;; + esac + done + )` + TCL_DEFS="${TCL_DEFS_TCL_ONLY}" + AC_SUBST(TCL_DEFS) dnl Needed for package installation TCL_PACKAGE_PATH="`echo "${TCL_PACKAGE_PATH}" | sed 's@ *$''@@' | awk '{ print [$]1 }'`" AC_SUBST(TCL_PACKAGE_PATH) AC_SUBST(LIBS) ]) Index: build/autogen.sh ================================================================== --- build/autogen.sh +++ build/autogen.sh @@ -6,11 +6,11 @@ cd aclocal || exit 1 for file in shobj.m4 tcl.m4 versionscript.m4; do rm -f "${file}" - wget -O "${file}.new" "http://rkeene.org/devel/autoconf/${file}" || continue + wget -O "${file}.new" "http://chiselapp.com/user/rkeene/repository/autoconf/doc/trunk/${file}" || continue mv "${file}.new" "${file}" done ) Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -12,21 +12,16 @@ AC_GNU_SOURCE AC_LANG(C) dnl Determine system information DC_CHK_OS_INFO + +dnl Perform Tcl Extension required stuff +TCLEXT_INIT dnl Determine if a shared or static build is requested -AC_ARG_ENABLE([shared], AS_HELP_STRING([--disable-shared], [build static library instead of shared library]), [ - if test "$enableval" = "no"; then - TCC4TCL_TARGET=static - else - TCC4TCL_TARGET=shared - fi -], [ - TCC4TCL_TARGET=shared -]) +TCC4TCL_TARGET="${TCLEXT_BUILD}" dnl Configure TCC build options AC_SUBST(TCC_CONFIGURE_OPTS) TCC_CONFIGURE_OPTS="" @@ -86,15 +81,12 @@ AC_SUBST(HOST_PATH_SEPARATOR) dnl Find a suitable awk AC_CHECK_TOOLS(AWK, gawk awk, [false]) -dnl Perform Tcl Extension required stuff -TCLEXT_INIT - dnl This must be done last since it breaks the compilation if test "${TCC4TCL_TARGET}" = "shared"; then DC_SETUP_STABLE_API([${srcdir}/tcc4tcl.vers], [tcc4tcl.syms]) fi dnl Produce output AC_OUTPUT(Makefile pkgIndex.tcl tcc4tcl.syms)