#!/usr/bin/awk -f BEGIN { f = "plugins.h" printf "#ifndef PLUGIN_H\n#define PLUGIN_H\n#include \"sm.h\"\n" >f } # We read the list of plugins from stdin { plugins[i++] = $0 printf "extern Plugin %s;\n", $0 >f } END { printf "#define NPLUGINS %d\n#ifdef MAIN\nPlugin *plugins[%d] = {\n", NR, NR >f for (i in plugins) { printf "\t&%s,\n", plugins[i] >f } printf "};\n#endif /* MAIN */\n\n#endif /* ! PLUGIN_H */" >f }