summaryrefslogtreecommitdiff
blob: 94bf16ef3100c53dc65947ae998135780e79ee9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
From: Nathan Phillip Brink <binki@gentoo.org>
Subject: Make dependence on TCL not be automagic (so that --with-tcl
	errors out if TCL can't be found and not specifying --with-tcl
	does the normal automagic behavior).  Support
	LDFLAGS=-Wl,--as-needed by using LIBS instead of LDFLAGS for
	-ltcl as appropriate.

--- a/configure.in
+++ b/configure.in
@@ -1122,43 +1122,41 @@
 dnl
 dnl Tcl support?
 dnl
-AC_ARG_WITH(tcl,
-[  --with-tcl[=PATH_TO_tclConfig.sh]      Compile with tcl support.],
-[
-	tclconfig=$withval
-],
-	tclconfig="yes"
-)
-
-if test "x$tclconfig" = "xyes" ; then
-	for i in /usr/lib /usr/local/lib /usr/local/lib/tcl8.4 ; do
-		if test -r $i/tclConfig.sh ; then
-			tclconfig=$i/tclConfig.sh
-			break;
-		fi
-	done
-fi
+AC_ARG_WITH([tcl], [AS_HELP_STRING([--with-tcl[=PATH_TO_tclConfig.sh]], [Compile with tcl support.])],
+	[], [with_tcl=maybe])
 
 AC_MSG_CHECKING(whether to support TCL)
-if test "x$tclconfig" = "xno"; then
+if test "x$with_tcl" = "xno"; then
 	AC_MSG_RESULT(no)
 else
-	if test ! -r $tclconfig ; then
+	with_tcl_errormsg="You specified --with-tcl=$with_tcl but I could not find TCL. Please specify --with-tcl=/path/to/tclConfig.sh or remove --with-tcl from ./configure's commandline."
+	if test "x$with_tcl" = "xmaybe" -o "x$with_tcl" = "xyes"; then
+		for i in /usr/lib /usr/local/lib /usr/local/lib/tcl8.4 ; do
+			if test -r "$i"/tclConfig.sh ; then
+				tclconfig="$i"/tclConfig.sh
+				break;
+			fi
+		done
+	else
+		tclconfig="$with_tcl"
+	fi
+	if test ! -r "$tclconfig" ; then
+		dnl Avoid being automagic unless if the user wants us to be.
+		AS_IF([test "x$with_tcl" != "xmaybe"],
+			[AC_MSG_ERROR([$with_tcl_errormsg])])
 		AC_MSG_RESULT(no)
 	else
 		AC_MSG_RESULT(yes)
-		TCLCFLAGS=`(. $tclconfig && echo $TCL_INCLUDE_SPEC)`
-		TCLLDFLAGS1=`(. $tclconfig && echo $TCL_LIB_SPEC)`
-		TCLLDFLAGS2=`(. $tclconfig && echo $TCL_LIBS)`
-		TCLLDFLAGS=$(eval echo "$TCLLDFLAGS1 $TCLLDFLAGS2")
+		TCLCFLAGS=`(. "$tclconfig" && echo $TCL_INCLUDE_SPEC)`
+		TCLLIBS=`(. "$tclconfig" && echo $TCL_LIB_SPEC $TCL_LIBS)`
 		TCLDOTOH="tcl.o"
 
 		AC_MSG_CHECKING(whether embedded tcl works the way I expect)
 		have_embedded_tcl="no"
 		old_CFLAGS="$CFLAGS"
-		old_LDFLAGS="$LDFLAGS"
+		old_LIBS="$LIBS"
 		CFLAGS="$CFLAGS $TCLCFLAGS"
-		LDFLAGS="$LDFLAGS $TCLLDFLAGS"
+		LIBS="$LIBS $TCLLIBS"
 		AC_TRY_LINK([
 #include <tcl.h>
 	   Tcl_Interp *my_tcl;
@@ -1175,14 +1173,16 @@
 ], have_embedded_tcl="yes")
 
 		CFLAGS="$old_CFLAGS"
-		LDFLAGS="$old_LDFLAGS"
+		LIBS="$old_LIBS"
 		if test $have_embedded_tcl = "yes" ; then
 		    AC_MSG_RESULT(yes)
 		    AC_DEFINE(HAVE_TCL)
 		    AC_DEFINE(TCLCFLAGS)
-		    AC_DEFINE(TCLLDFLAGS)
+		    AC_DEFINE(TCLLIBS)
 		else
-		    AC_MSG_RESULT(no, sorry)
+			AS_IF([test "$with_tcl" != "xmaybe"],
+				[AC_MSG_ERROR([$with_tcl_errormsg])])
+			AC_MSG_RESULT(no, sorry)
 		fi
 	fi
 fi
@@ -1383,7 +1383,7 @@
 AC_SUBST(RUBYLIBS)
 AC_SUBST(TCLDOTOH)
 AC_SUBST(TCLCFLAGS)
-AC_SUBST(TCLLDFLAGS)
+AC_SUBST(TCLLIBS)
 AC_SUBST(PERLDOTOH)
 AC_SUBST(PERLCFLAGS)
 AC_SUBST(PERLLDFLAGS)

--- a/source/Makefile.in
+++ b/source/Makefile.in
@@ -38,7 +38,7 @@
 epic5: $(OBJECTS)
 	sh info.c.sh
 	$(CC) $(CFLAGS) $(INCLUDES) -c info.c
-	$(CC) $(CFLAGS) $(LDFLAGS) -o epic5 $(OBJECTS) info.o @PERLLDFLAGS@ @TCLLDFLAGS@ @RUBYLIBS@ $(LIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o epic5 $(OBJECTS) info.o @PERLLDFLAGS@ @TCLLIBS@ @RUBYLIBS@ $(LIBS)
 	$(RM) info.c info.o
 clean::
 	$(RM) epic5 $(OBJECTS)