|author||Manoj Srivastava <firstname.lastname@example.org>||2014-04-27 17:54:01 -0700|
|committer||Manoj Srivastava <email@example.com>||2014-04-27 17:54:01 -0700|
Imported Upstream version 3.5-36
Diffstat (limited to 'mcon/U/Trylink.U')
1 files changed, 110 insertions, 0 deletions
diff --git a/mcon/U/Trylink.U b/mcon/U/Trylink.U
new file mode 100644
@@ -0,0 +1,110 @@
+?RCS: $Id: Trylink.U 167 2013-05-08 17:58:00Z rmanfredi $
+?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
+?RCS: You may redistribute only under the terms of the Artistic License,
+?RCS: as specified in the README file that comes with the distribution.
+?RCS: You may reuse parts of this distribution only within the terms of
+?RCS: that same Artistic License; a copy of which may be found at the root
+?RCS: of the source tree for dist 4.0.
+?X: This unit tries to compile and link a test program.
+?X: To use it, put the program to compile in try.c, then say:
+?X: set d_func [optional cc flags to try in sequence]
+?X: eval $trylink
+?X: A log of all attempts is kept in the trylink.log file, within the UU
+?X: directory (where Configure runs). This directory is only cleaned-up
+?X: at the end of the Configure run, so do not supply -e to Configure in order
+?X: to stop after the production of the config.sh file and be able to
+?X: inspect the UU/trylink.log file.
+?X: Before calling $trylink, on can also set the $cyn variable (check yes/no)
+?X: with a message that will be printed before the test is made and which
+?X: will indicate whether the test was successful or not. The string
+?X: "Checking $cyn..." is emitted and will be followed by "yes." if the
+?X: compilation succeeds, and "no." otherwise.
+?X: If there are no space in the $cyn variable, then it is expected to hold
+?X: the name of a routine if the variable to test starts with d_, or
+?X: the name of an include file if the variable to test starts with i_.
+?X: In which case the message for success are changed to "found." and
+?X: "missing." on failure.
+?X: The "$cyn" variable is explicitly reset at the end, and nothing is
+?X: printed if it is empty upon entry.
+?MAKE:Trylink: Setvar Oldconfig cat rm test +cc +ccflags +ldflags echo c n
+?MAKE: -pick add $@ %<
+?S: This shell variable is used internally by Configure to check
+?S: wether a given function is defined or not. A typical use is:
+?S: create try.c
+?S: set d_func [optional cc flags to try in sequence]
+?S: eval $trylink
+?S: That will print a message, saying wether function was found or
+?S: not and set d_func accordingly.
+?T:var file val nparams msg yes no
+: see whether the try.c file compiles and links
+?X: If they supplied a $cyn, display it now.
+case "$cyn" in
+*" "*) msg="$cyn"; yes=yes; no=no;;
+ case "$var" in
+ d_*) msg="for $cyn()"; yes=found; no=missing;;
+ i_*) msg="for <$cyn>"; yes=found; no=missing;;
+ *) msg="$cyn"; yes=yes; no=no;;
+case "$cyn" in
+"") echo "--- $var ---" >> "$file";;
+ echo " "; $echo $n "Checking $msg...$c" >&4;
+ echo "--- $var --- ($msg)" >>"$file"
+$cat try.c >> "$file";
+while :; do
+ $rm -f try$_exe;
+ if $cc $ccflags -o try try.c $ldflags $1 >> "$file" 2>&1; then
+ case "$nparams" in 0) ;; *) echo "==> OK with \"$1\"" >> "$file";; esac;
+ if $test $# -lt 1; then
+ echo "==> FAILED with \"$1\"" >> "$file";
+$rm -rf try try.*;
+echo "==> $var=$val" >> "$file";
+?X: Show feedback if they supplied a $cyn
+case "$cyn" in
+ case "$val" in
+ "$define") echo " $yes." >&4;;
+ *) echo " $no." >&4;;
+set $var; eval $setvar;
+?X: Cleanup so that next unit using $trylink does not have to do that