From 8c731331a353d82adc61a81bd3cb92e79f3c2dc8 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 1 Mar 2009 16:19:29 +0100 Subject: [PATCH] lib.sh: m4() define useful macros. At the moment only IF and FI are defined which can be used for easy checking of variables. They use the ifelse() macro. --- lib.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib.sh b/lib.sh index ea61359..88b7b98 100644 --- a/lib.sh +++ b/lib.sh @@ -73,6 +73,11 @@ link() { # to $1 with a warning at the beginning to not edit the generated file. # # All arguments (except the first which is the filename) are passed to m4. +# +# The following macros are defined: IF and FI. Example: +# IF(OS, debian) +# ... +# FI m4() { # First argument is file name. file=$1 @@ -88,7 +93,11 @@ m4() { # Process $1.m4 with m4 using the given options. echo "m4(): generating '$file' from '$file.m4' with options '$*'" - $m4 $* $file.m4 >> $file + # Add useful macros. + (echo "define(\`IF', \`ifelse(\`\$1', \`\$2',dnl')dnl +define(\`FI', \`)dnl')dnl"; + # Run the file (and the default macros) through m4. + cat $file.m4) | $m4 $* >> $file unset file } -- 2.45.2