?RCS: $Id$ ?RCS: ?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi ?RCS: ?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: ?X: This unit tries to compile and link a test program. ?X: ?X: To use it, put the program to compile in try.c, then say: ?X: ?X: cyn=func ?X: set d_func [optional cc flags to try in sequence] ?X: eval $trylink ?X: ?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: ?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: ?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: ?X: The "$cyn" variable is explicitly reset at the end, and nothing is ?X: printed if it is empty upon entry. ?X: ?MAKE:Trylink: Setvar Oldconfig cat rm test +cc +ccflags +ldflags echo c n ?MAKE: -pick add $@ %< ?LINT:define trylink ?V:trylink:cyn ?S:trylink: ?S: This shell variable is used internally by Configure to check ?S: whether 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 whether function was found or ?S: not and set d_func accordingly. ?S:. ?T:var file val nparams msg yes no : see whether the try.c file compiles and links trylink=' var=$1; shift; val=$undef; file=trylink.log; nparams=$#; ?X: If they supplied a $cyn, display it now. case "$cyn" in "") msg="";; *" "*) 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;; esac ;; esac; case "$cyn" in "") echo "--- $var ---" >> "$file";; *) echo " "; $echo $n "Checking $msg...$c" >&4; echo "--- $var --- ($msg)" >>"$file" ;; esac; $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; val=$define; break; fi; if $test $# -lt 1; then break; fi; echo "==> FAILED with \"$1\"" >> "$file"; shift; done; $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;; esac ;; esac; set $var; eval $setvar; ?X: Cleanup so that next unit using $trylink does not have to do that cyn="" '