From 13158f86e3904284dce3dad36b64f07414459551 Mon Sep 17 00:00:00 2001 From: rmanfredi Date: Sat, 27 Nov 2010 11:55:39 +0000 Subject: Applied mega patch from Christian Biere to greatly improve feature detection and make a huge step towards better support for cross-compiling. git-svn-id: svn://svn.code.sf.net/p/dist/code/trunk/dist@34 2592e710-e01b-42a5-8df0-11608a6cc53d --- mcon/U/Trylink.U | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 mcon/U/Trylink.U (limited to 'mcon/U/Trylink.U') diff --git a/mcon/U/Trylink.U b/mcon/U/Trylink.U new file mode 100644 index 0000000..48536b4 --- /dev/null +++ b/mcon/U/Trylink.U @@ -0,0 +1,61 @@ +?RCS: $Id$ +?RCS: +?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi +?RCS: +?RCS: You may redistribute only under the terms of the Artistic Licence, +?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 Licence; 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: 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. +?X: +?MAKE:Trylink: Setvar Oldconfig cat rm test +cc +ccflags +ldflags +?MAKE: -pick add $@ %< +?LINT:define trylink +?V:trylink +?S:trylink: +?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. +?S:. +?T:var file val nparams +: see whether the try.c file compiles and links +trylink=' +var=$1; +shift; +val=$undef; +file=trylink.log; +nparams=$#; +echo "--- $var ---" >> "$file"; +$cat try.c >> "$file"; +while :; do + 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"; +set $var; eval $setvar; +' + -- cgit v1.2.3 From e1369f5a1a89361f23f54c61a9f3b4384db35c6d Mon Sep 17 00:00:00 2001 From: rmanfredi Date: Sat, 27 Nov 2010 20:54:48 +0000 Subject: Added the generic units from gtk-gnutella. Made Trylink verbose to tell them what is tested and what the outcome is. git-svn-id: svn://svn.code.sf.net/p/dist/code/trunk/dist@40 2592e710-e01b-42a5-8df0-11608a6cc53d --- mcon/U/Trylink.U | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 5 deletions(-) (limited to 'mcon/U/Trylink.U') diff --git a/mcon/U/Trylink.U b/mcon/U/Trylink.U index 48536b4..cdcf5ef 100644 --- a/mcon/U/Trylink.U +++ b/mcon/U/Trylink.U @@ -17,12 +17,28 @@ ?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. +?X: to stop after the production of the config.sh file and be able to +?X: inspect the UU/trylink.log file. ?X: -?MAKE:Trylink: Setvar Oldconfig cat rm test +cc +ccflags +ldflags +?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 +?V:trylink:cyn ?S:trylink: ?S: This shell variable is used internally by Configure to check ?S: wether a given function is defined or not. A typical use is: @@ -32,7 +48,7 @@ ?S: That will print a message, saying wether function was found or ?S: not and set d_func accordingly. ?S:. -?T:var file val nparams +?T:var file val nparams msg yes no : see whether the try.c file compiles and links trylink=' var=$1; @@ -40,7 +56,25 @@ shift; val=$undef; file=trylink.log; nparams=$#; -echo "--- $var ---" >> "$file"; +?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 if $cc $ccflags -o try try.c $ldflags $1 >> "$file" 2>&1; then @@ -56,6 +90,18 @@ while :; do 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="" ' -- cgit v1.2.3 From 8233fb6494e96dff527497d4ae5eada2765be91b Mon Sep 17 00:00:00 2001 From: rmanfredi Date: Thu, 9 Feb 2012 16:42:50 +0000 Subject: Make example stand out and include the cyn variable setting. git-svn-id: svn://svn.code.sf.net/p/dist/code/trunk/dist@129 2592e710-e01b-42a5-8df0-11608a6cc53d --- mcon/U/Trylink.U | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'mcon/U/Trylink.U') diff --git a/mcon/U/Trylink.U b/mcon/U/Trylink.U index cdcf5ef..8c3316c 100644 --- a/mcon/U/Trylink.U +++ b/mcon/U/Trylink.U @@ -11,8 +11,10 @@ ?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: set d_func [optional cc flags to try in sequence] -?X: eval $trylink +?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 -- cgit v1.2.3 From eebe137986ea89031cd490f6ec39c5617e9fd341 Mon Sep 17 00:00:00 2001 From: rmanfredi Date: Fri, 10 Feb 2012 15:54:01 +0000 Subject: Remove executable before compiling, just in case. git-svn-id: svn://svn.code.sf.net/p/dist/code/trunk/dist@134 2592e710-e01b-42a5-8df0-11608a6cc53d --- mcon/U/Trylink.U | 1 + 1 file changed, 1 insertion(+) (limited to 'mcon/U/Trylink.U') diff --git a/mcon/U/Trylink.U b/mcon/U/Trylink.U index 8c3316c..c91494c 100644 --- a/mcon/U/Trylink.U +++ b/mcon/U/Trylink.U @@ -79,6 +79,7 @@ case "$cyn" in 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; -- cgit v1.2.3 From a48d4a094464be38b11b832a31394b240e88ea83 Mon Sep 17 00:00:00 2001 From: rmanfredi Date: Wed, 8 May 2013 17:58:00 +0000 Subject: Fixed spelling: Licence -> License. git-svn-id: svn://svn.code.sf.net/p/dist/code/trunk/dist@167 2592e710-e01b-42a5-8df0-11608a6cc53d --- mcon/U/Trylink.U | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mcon/U/Trylink.U') diff --git a/mcon/U/Trylink.U b/mcon/U/Trylink.U index c91494c..42504fb 100644 --- a/mcon/U/Trylink.U +++ b/mcon/U/Trylink.U @@ -2,10 +2,10 @@ ?RCS: ?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi ?RCS: -?RCS: You may redistribute only under the terms of the Artistic Licence, +?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 Licence; a copy of which may be found at the root +?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. -- cgit v1.2.3 From 77e4271ceb24212cfd025be9ce880bdeb5a14013 Mon Sep 17 00:00:00 2001 From: "H.Merijn Brand" Date: Sun, 22 May 2016 17:07:59 +0200 Subject: Remove trailing whitespace in meta-lines in units (#3) --- mcon/U/Trylink.U | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mcon/U/Trylink.U') diff --git a/mcon/U/Trylink.U b/mcon/U/Trylink.U index 42504fb..d45ffe2 100644 --- a/mcon/U/Trylink.U +++ b/mcon/U/Trylink.U @@ -1,7 +1,7 @@ ?RCS: $Id$ ?RCS: ?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi -?RCS: +?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 -- cgit v1.2.3 From 2f64ea88c70b412b1543e36e5f7421c48bfd464e Mon Sep 17 00:00:00 2001 From: Raphael Manfredi Date: Mon, 16 Mar 2020 17:11:08 +0100 Subject: Added space to be consistent. --- mcon/U/Trylink.U | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mcon/U/Trylink.U') diff --git a/mcon/U/Trylink.U b/mcon/U/Trylink.U index d45ffe2..4ed9128 100644 --- a/mcon/U/Trylink.U +++ b/mcon/U/Trylink.U @@ -74,7 +74,7 @@ case "$cyn" in "") echo "--- $var ---" >> "$file";; *) echo " "; $echo $n "Checking $msg...$c" >&4; - echo "--- $var --- ($msg)" >>"$file" + echo "--- $var --- ($msg)" >> "$file" ;; esac; $cat try.c >> "$file"; -- cgit v1.2.3