Skip to content

Commit 66dd672

Browse files
committed
Apply diff from photoresize repo to support C++
1 parent 24d397b commit 66dd672

File tree

1 file changed

+106
-18
lines changed

1 file changed

+106
-18
lines changed

tclconfig/tcl.m4

Lines changed: 106 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,16 @@ AC_DEFUN([TEA_CONFIG_CFLAGS], [
11581158
STLIB_LD='${AR} cr'
11591159
LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH"
11601160
AS_IF([test "x$SHLIB_VERSION" = x],[SHLIB_VERSION=""],[SHLIB_VERSION=".$SHLIB_VERSION"])
1161+
1162+
# if the compiler is used for linking,
1163+
# choose the C++ compiler if CXX is enabled
1164+
if test x"$TEA_CXX" != "x"; then
1165+
CCLD=$CXX
1166+
else
1167+
CCLD=$CC
1168+
fi
1169+
1170+
11611171
case $system in
11621172
# TEA specific:
11631173
windows)
@@ -1212,7 +1222,7 @@ AC_DEFUN([TEA_CONFIG_CFLAGS], [
12121222
AC_CHECK_TOOL(RC, windres)
12131223
CFLAGS_DEBUG="-g"
12141224
CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer"
1215-
SHLIB_LD='${CC} -shared'
1225+
SHLIB_LD='${CCLD} -shared'
12161226
UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
12171227
LDFLAGS_CONSOLE="-wl,--subsystem,console ${lflags}"
12181228
LDFLAGS_WINDOW="-wl,--subsystem,windows ${lflags}"
@@ -1313,7 +1323,7 @@ AC_DEFUN([TEA_CONFIG_CFLAGS], [
13131323
LD_SEARCH_FLAGS='-R "${LIB_RUNTIME_DIR}"'
13141324
], [
13151325
AS_IF([test "$GCC" = yes], [
1316-
SHLIB_LD='${CC} -shared -Wl,-bexpall'
1326+
SHLIB_LD='${CCLD} -shared -Wl,-bexpall'
13171327
], [
13181328
SHLIB_LD="/bin/ld -bhalt:4 -bM:SRE -bexpall -H512 -T512 -bnoentry"
13191329
LDFLAGS="$LDFLAGS -brtl"
@@ -1325,7 +1335,7 @@ AC_DEFUN([TEA_CONFIG_CFLAGS], [
13251335
;;
13261336
BeOS*)
13271337
SHLIB_CFLAGS="-fPIC"
1328-
SHLIB_LD='${CC} -nostart'
1338+
SHLIB_LD='${CCLD} -nostart'
13291339
SHLIB_SUFFIX=".so"
13301340
13311341
#-----------------------------------------------------------
@@ -1344,15 +1354,15 @@ AC_DEFUN([TEA_CONFIG_CFLAGS], [
13441354
;;
13451355
BSD/OS-4.*)
13461356
SHLIB_CFLAGS="-export-dynamic -fPIC"
1347-
SHLIB_LD='${CC} -shared'
1357+
SHLIB_LD='${CCLD} -shared'
13481358
SHLIB_SUFFIX=".so"
13491359
LDFLAGS="$LDFLAGS -export-dynamic"
13501360
CC_SEARCH_FLAGS=""
13511361
LD_SEARCH_FLAGS=""
13521362
;;
13531363
CYGWIN_*)
13541364
SHLIB_CFLAGS=""
1355-
SHLIB_LD='${CC} -shared'
1365+
SHLIB_LD='${CCLD} -shared'
13561366
SHLIB_SUFFIX=".dll"
13571367
SHLIB_LD_LIBS="${SHLIB_LD_LIBS} -Wl,--out-implib,\$[@].a"
13581368
EXEEXT=".exe"
@@ -1362,7 +1372,7 @@ AC_DEFUN([TEA_CONFIG_CFLAGS], [
13621372
;;
13631373
dgux*)
13641374
SHLIB_CFLAGS="-K PIC"
1365-
SHLIB_LD='${CC} -G'
1375+
SHLIB_LD='${CCLD} -G'
13661376
SHLIB_LD_LIBS=""
13671377
SHLIB_SUFFIX=".so"
13681378
CC_SEARCH_FLAGS=""
@@ -1372,7 +1382,7 @@ AC_DEFUN([TEA_CONFIG_CFLAGS], [
13721382
LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
13731383
SHLIB_CFLAGS="-fPIC"
13741384
SHLIB_SUFFIX=".so"
1375-
SHLIB_LD='${CC} ${CFLAGS} ${LDFLAGS} -shared'
1385+
SHLIB_LD='${CCLD} ${CFLAGS} ${LDFLAGS} -shared'
13761386
AC_CHECK_LIB(network, inet_ntoa, [LIBS="$LIBS -lnetwork"])
13771387
;;
13781388
HP-UX-*.11.*)
@@ -1397,7 +1407,7 @@ AC_DEFUN([TEA_CONFIG_CFLAGS], [
13971407
LD_LIBRARY_PATH_VAR="SHLIB_PATH"
13981408
])
13991409
AS_IF([test "$GCC" = yes], [
1400-
SHLIB_LD='${CC} -shared'
1410+
SHLIB_LD='${CCLD} -shared'
14011411
LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
14021412
], [
14031413
CFLAGS="$CFLAGS -z"
@@ -1410,7 +1420,7 @@ AC_DEFUN([TEA_CONFIG_CFLAGS], [
14101420
hppa64*)
14111421
# 64-bit gcc in use. Fix flags for GNU ld.
14121422
do64bit_ok=yes
1413-
SHLIB_LD='${CC} -shared'
1423+
SHLIB_LD='${CCLD} -shared'
14141424
AS_IF([test $doRpath = yes], [
14151425
CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'])
14161426
LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
@@ -1498,7 +1508,7 @@ AC_DEFUN([TEA_CONFIG_CFLAGS], [
14981508
CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer"
14991509
15001510
# TEA specific: use LDFLAGS_DEFAULT instead of LDFLAGS
1501-
SHLIB_LD='${CC} ${CFLAGS} ${LDFLAGS_DEFAULT} -shared'
1511+
SHLIB_LD='${CCLD} ${CFLAGS} ${LDFLAGS_DEFAULT} -shared'
15021512
LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
15031513
15041514
case $system in
@@ -1540,7 +1550,7 @@ AC_DEFUN([TEA_CONFIG_CFLAGS], [
15401550
SHLIB_CFLAGS="-fPIC"
15411551
SHLIB_SUFFIX=".so"
15421552
CFLAGS_OPTIMIZE=-02
1543-
SHLIB_LD='${CC} -shared'
1553+
SHLIB_LD='${CCLD} -shared'
15441554
LD_FLAGS="-Wl,--export-dynamic"
15451555
AS_IF([test $doRpath = yes], [
15461556
CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'
@@ -1556,7 +1566,7 @@ AC_DEFUN([TEA_CONFIG_CFLAGS], [
15561566
SHLIB_CFLAGS="-fpic"
15571567
;;
15581568
esac
1559-
SHLIB_LD='${CC} ${SHLIB_CFLAGS} -shared'
1569+
SHLIB_LD='${CCLD} ${SHLIB_CFLAGS} -shared'
15601570
SHLIB_SUFFIX=".so"
15611571
AS_IF([test $doRpath = yes], [
15621572
CC_SEARCH_FLAGS='"-Wl,-rpath,${LIB_RUNTIME_DIR}"'])
@@ -1575,7 +1585,7 @@ AC_DEFUN([TEA_CONFIG_CFLAGS], [
15751585
NetBSD-*)
15761586
# NetBSD has ELF and can use 'cc -shared' to build shared libs
15771587
SHLIB_CFLAGS="-fPIC"
1578-
SHLIB_LD='${CC} ${SHLIB_CFLAGS} -shared'
1588+
SHLIB_LD='${CCLD} ${SHLIB_CFLAGS} -shared'
15791589
SHLIB_SUFFIX=".so"
15801590
LDFLAGS="$LDFLAGS -export-dynamic"
15811591
AS_IF([test $doRpath = yes], [
@@ -1634,7 +1644,7 @@ AC_DEFUN([TEA_CONFIG_CFLAGS], [
16341644
fat_32_64=yes])
16351645
])
16361646
# TEA specific: use LDFLAGS_DEFAULT instead of LDFLAGS
1637-
SHLIB_LD='${CC} -dynamiclib ${CFLAGS} ${LDFLAGS_DEFAULT}'
1647+
SHLIB_LD='${CCLD} -dynamiclib ${CFLAGS} ${LDFLAGS_DEFAULT}'
16381648
AC_CACHE_CHECK([if ld accepts -single_module flag], tcl_cv_ld_single_module, [
16391649
hold_ldflags=$LDFLAGS
16401650
LDFLAGS="$LDFLAGS -dynamiclib -Wl,-single_module"
@@ -1772,7 +1782,7 @@ AC_DEFUN([TEA_CONFIG_CFLAGS], [
17721782
SHLIB_CFLAGS="-KPIC"
17731783
SHLIB_SUFFIX=".so"
17741784
AS_IF([test "$GCC" = yes], [
1775-
SHLIB_LD='${CC} -shared'
1785+
SHLIB_LD='${CCLD} -shared'
17761786
CC_SEARCH_FLAGS='"-Wl,-R,${LIB_RUNTIME_DIR}"'
17771787
LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
17781788
], [
@@ -1842,7 +1852,7 @@ AC_DEFUN([TEA_CONFIG_CFLAGS], [
18421852
18431853
SHLIB_SUFFIX=".so"
18441854
AS_IF([test "$GCC" = yes], [
1845-
SHLIB_LD='${CC} -shared'
1855+
SHLIB_LD='${CCLD} -shared'
18461856
CC_SEARCH_FLAGS='"-Wl,-R,${LIB_RUNTIME_DIR}"'
18471857
LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
18481858
AS_IF([test "$do64bit_ok" = yes], [
@@ -1866,7 +1876,7 @@ AC_DEFUN([TEA_CONFIG_CFLAGS], [
18661876
case $system in
18671877
SunOS-5.[[1-9]][[0-9]]*)
18681878
# TEA specific: use LDFLAGS_DEFAULT instead of LDFLAGS
1869-
SHLIB_LD='${CC} -G -z text ${LDFLAGS_DEFAULT}';;
1879+
SHLIB_LD='${CCLD} -G -z text ${LDFLAGS_DEFAULT}';;
18701880
*)
18711881
SHLIB_LD='/usr/ccs/bin/ld -G -z text';;
18721882
esac
@@ -1876,7 +1886,7 @@ AC_DEFUN([TEA_CONFIG_CFLAGS], [
18761886
;;
18771887
UNIX_SV* | UnixWare-5*)
18781888
SHLIB_CFLAGS="-KPIC"
1879-
SHLIB_LD='${CC} -G'
1889+
SHLIB_LD='${CCLD} -G'
18801890
SHLIB_LD_LIBS=""
18811891
SHLIB_SUFFIX=".so"
18821892
# Some UNIX_SV* systems (unixware 1.1.2 for example) have linkers
@@ -2675,6 +2685,11 @@ AC_DEFUN([TEA_TCL_64BIT_FLAGS], [
26752685
# a compiler.
26762686
#------------------------------------------------------------------------
26772687

2688+
AC_DEFUN([TEA_INIT_CXX], [
2689+
# request setup for C++ compilation
2690+
TEA_CXX="yes"
2691+
])
2692+
26782693
AC_DEFUN([TEA_INIT], [
26792694
TEA_VERSION="3.13"
26802695
@@ -2966,6 +2981,8 @@ AC_DEFUN([TEA_ADD_LIBS], [
29662981
AC_DEFUN([TEA_ADD_CFLAGS], [
29672982
PKG_CFLAGS="$PKG_CFLAGS $@"
29682983
AC_SUBST(PKG_CFLAGS)
2984+
AC_SUBST(CCLD)
2985+
AC_SUBST(INSTALL_FLAGS)
29692986
])
29702987

29712988
#------------------------------------------------------------------------
@@ -3021,6 +3038,65 @@ AC_DEFUN([TEA_PREFIX], [
30213038
fi
30223039
])
30233040

3041+
# ===========================================================================
3042+
# https://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html
3043+
# ===========================================================================
3044+
#
3045+
# SYNOPSIS
3046+
#
3047+
# AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
3048+
#
3049+
# DESCRIPTION
3050+
#
3051+
# Check whether the given FLAG works with the linker or gives an error.
3052+
# (Warnings, however, are ignored)
3053+
#
3054+
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
3055+
# success/failure.
3056+
#
3057+
# If EXTRA-FLAGS is defined, it is added to the linker's default flags
3058+
# when the check is done. The check is thus made with the flags: "LDFLAGS
3059+
# EXTRA-FLAGS FLAG". This can for example be used to force the linker to
3060+
# issue an error when a bad flag is given.
3061+
#
3062+
# INPUT gives an alternative input source to AC_LINK_IFELSE.
3063+
#
3064+
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
3065+
# macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG.
3066+
#
3067+
# LICENSE
3068+
#
3069+
# Copyright (c) 2008 Guido U. Draheim <[email protected]>
3070+
# Copyright (c) 2011 Maarten Bosmans <[email protected]>
3071+
#
3072+
# Copying and distribution of this file, with or without modification, are
3073+
# permitted in any medium without royalty provided the copyright notice
3074+
# and this notice are preserved. This file is offered as-is, without any
3075+
# warranty.
3076+
3077+
#serial 6
3078+
3079+
AC_DEFUN([AX_CHECK_LINK_FLAG],
3080+
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
3081+
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl
3082+
AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [
3083+
ax_check_save_flags=$LDFLAGS
3084+
LDFLAGS="$LDFLAGS $4 $1"
3085+
AC_LINK_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
3086+
[AS_VAR_SET(CACHEVAR,[yes])],
3087+
[AS_VAR_SET(CACHEVAR,[no])])
3088+
LDFLAGS=$ax_check_save_flags])
3089+
AS_VAR_IF(CACHEVAR,yes,
3090+
[m4_default([$2], :)],
3091+
[m4_default([$3], :)])
3092+
AS_VAR_POPDEF([CACHEVAR])dnl
3093+
])dnl AX_CHECK_LINK_FLAGS
3094+
3095+
# use AX_CHECK_LINK_FLAG to add a linker flag if it is available
3096+
AC_DEFUN([AX_ADDTO_LINK_FLAG],
3097+
[AX_CHECK_LINK_FLAGS([$1], [LDFLAGS="$LDFLAGS $1"], [])
3098+
])
3099+
30243100
#------------------------------------------------------------------------
30253101
# TEA_SETUP_COMPILER_CC --
30263102
#
@@ -3039,6 +3115,11 @@ AC_DEFUN([TEA_SETUP_COMPILER_CC], [
30393115
# in this macro, they need to go into TEA_SETUP_COMPILER instead.
30403116
30413117
AC_PROG_CC
3118+
3119+
if test "x$TEA_CXX" != "x"; then
3120+
AC_PROG_CXX
3121+
fi
3122+
30423123
AC_PROG_CPP
30433124
30443125
#--------------------------------------------------------------------
@@ -3094,6 +3175,13 @@ AC_DEFUN([TEA_SETUP_COMPILER], [
30943175
fi
30953176
fi
30963177
3178+
if test "x$TEA_CXX" != "x"; then
3179+
# try to link the C++ libraries statically
3180+
AC_LANG_PUSH([C++])
3181+
AX_ADDTO_LINK_FLAGS([-static-libgcc])
3182+
AX_ADDTO_LINK_FLAGS([-static-libstdc++])
3183+
AC_LANG_POP([C++])
3184+
fi
30973185
#--------------------------------------------------------------------
30983186
# Common compiler flag setup
30993187
#--------------------------------------------------------------------

0 commit comments

Comments
 (0)