summaryrefslogtreecommitdiffstats
path: root/genplugin.awk
blob: e6f99ac4cb83357583753ab9e90f4d253ea08492 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/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
}