X-Git-Url: https://ruderich.org/simon/gitweb/?p=config%2Fdotfiles.git;a=blobdiff_plain;f=lib.sh;h=88b7b98a26f2ba84cf2c141191bc296dbac48ddc;hp=ea61359e2e806be5b26aaff201930743d7214b5a;hb=8c731331a353d82adc61a81bd3cb92e79f3c2dc8;hpb=144b79caff995d7c5773e3efb66813bf131de0e2 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 }