1#!/bin/sh
2
3# Create Makefile.am
4echo > Makefile.am
5echo 'EXTRA_DIST = \' >> Makefile.am
6ls *.xpm | sed -e 's/^/	/' -e 's/$/ \\/' >> Makefile.am
7echo '	makeflags.sh' >> Makefile.am
8
9# Create CountryFlags.h and header
10echo > CountryFlags.h
11echo >> CountryFlags.h
12echo '#ifndef COUNTRY_FLAGS_H' >> CountryFlags.h
13echo '#define COUNTRY_FLAGS_H' >> CountryFlags.h
14echo >> CountryFlags.h
15echo 'namespace flags {' >> CountryFlags.h
16echo >> CountryFlags.h
17
18# Create include directives
19ls *.xpm | sed -e 's/^/#include "/' -e 's/$/"/' >> CountryFlags.h
20echo >> CountryFlags.h
21echo >> CountryFlags.h
22
23# Define the struct
24echo 'struct FlagXPMCode' >> CountryFlags.h
25echo '{' >> CountryFlags.h
26echo '	const char **xpm;' >> CountryFlags.h
27echo '	const char *code;' >> CountryFlags.h
28echo '};' >> CountryFlags.h
29echo >> CountryFlags.h
30echo >> CountryFlags.h
31
32# "do" is a reserved word, we can't use it
33#sed -i -e 's/do\[\]/do_\[\]/' do.xpm
34
35# Create the flag/Code vector
36echo 'static struct FlagXPMCode flagXPMCodeVector[] = {'>> CountryFlags.h
37ls *.xpm | sed -e 's/\.xpm$//;/\//s:.*/\([^/][^/]*\):\1:' | \
38	sed -e 's/[A-Za-z]*/	{&, "&"},/' | \
39	sed -e 's/do/do_/1' \
40	>> CountryFlags.h
41echo '};'>> CountryFlags.h
42echo >> CountryFlags.h
43echo >> CountryFlags.h
44
45# Calculate the vector size
46echo 'static const int FLAGS_XPM_SIZE = (sizeof flagXPMCodeVector) / (sizeof flagXPMCodeVector[0]);' >> CountryFlags.h
47echo >> CountryFlags.h
48echo >> CountryFlags.h
49
50# Finish
51echo '}	// namespace flags' >> CountryFlags.h
52echo '#endif // COUNTRY_FLAGS_H' >> CountryFlags.h
53
54