Upstream tarball 20080304
[amule.git] / src / pixmaps / flags_xpm / makeflags.sh
blob8b9ae13333b77e96ea34b6f29c853c2b7b7b2a82
1 #!/bin/sh
3 # Create Makefile.am
4 echo > Makefile.am
5 echo 'EXTRA_DIST = \' >> Makefile.am
6 ls *.xpm | sed -e 's/^/\t/' | sed -e 's/$/ \\/' >> Makefile.am
7 echo ' makeflags.sh' >> Makefile.am
9 # Create CountryFlags.h and header
10 echo > CountryFlags.h
11 echo >> CountryFlags.h
12 echo '#ifndef COUNTRY_FLAGS_H' >> CountryFlags.h
13 echo '#define COUNTRY_FLAGS_H' >> CountryFlags.h
14 echo >> CountryFlags.h
15 echo >> CountryFlags.h
17 # Create include directives
18 ls *.xpm | sed -e 's/^/#include "/' | sed -e 's/$/"/' >> CountryFlags.h
19 echo >> CountryFlags.h
20 echo >> CountryFlags.h
22 # Define the struct
23 echo 'struct FlagXPMCode' >> CountryFlags.h
24 echo '{' >> CountryFlags.h
25 echo ' const char **xpm;' >> CountryFlags.h
26 echo ' const char *code;' >> CountryFlags.h
27 echo '};' >> CountryFlags.h
28 echo >> CountryFlags.h
29 echo >> CountryFlags.h
31 # "do" is a reserved word, we can't use it
32 #sed -i -e 's/do\[\]/do_\[\]/' do.xpm
34 # globally used names by wx
35 #sed -i -e 's/ht\[\]/ht_\[\]/' ht.xpm
36 #sed -i -e 's/it\[\]/it_\[\]/' it.xpm
37 #sed -i -e 's/sz\[\]/sz_\[\]/' sz.xpm
39 # Create the flag/Code vector
40 echo 'static struct FlagXPMCode flagXPMCodeVector[] = {'>> CountryFlags.h
41 ls *.xpm | xargs -i basename '{}' .xpm | \
42 sed -e 's/[A-Za-z]*/\t{&, "&"},/' | \
43 sed -e 's/do/do_/1' |
44 sed -e 's/ht/ht_/1' |
45 sed -e 's/it/it_/1' |
46 sed -e 's/sz/sz_/1' \
47 >> CountryFlags.h
48 echo '};'>> CountryFlags.h
49 echo >> CountryFlags.h
50 echo >> CountryFlags.h
52 # Calculate the vector size
53 echo 'static const int FLAGS_XPM_SIZE = (sizeof flagXPMCodeVector) / (sizeof flagXPMCodeVector[0]);' >> CountryFlags.h
54 echo >> CountryFlags.h
55 echo >> CountryFlags.h
57 # Finish
58 echo '#endif // COUNTRY_FLAGS_H' >> CountryFlags.h