Skip to content

Instantly share code, notes, and snippets.

@louisswarren
Last active November 25, 2020 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save louisswarren/fc5cd9c91387d9822dcbcc16909341a6 to your computer and use it in GitHub Desktop.
Save louisswarren/fc5cd9c91387d9822dcbcc16909341a6 to your computer and use it in GitHub Desktop.
Mutex files with preprocessing
#!/bin/sh
# Generate all .m4 file outputs - being lazy and just re-running the script
# with an argument. To be safe AND lazy, add a useless argument just to make
# sure this doesn't fork bomb me some day if I change how this is done.
if [ -z "$1" ]; then
exec find $(dirname -- "$0") -name '*.m4' -exec "./$0" '{}' 'safety' \;
fi
# Generate $1 from its .m4 file.
# Piping this program into .gitignore is a good idea
echo "${1%.m4}"
m4 --prefix-builtins - "$1" > "${1%.m4}" << 'EOF'
m4_define(HOST, m4_esyscmd(`echo -n $(hostname)'))
m4_define(`if_host', `m4_ifelse(HOST, $1, $2, $3)')
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment