Restructure how we look for Read files slightly.
[fvwm.git] / perllib / FVWM / create-constants
bloba5b66ba60948eb0b0cdbfdd6a33f4188fa5ba3b6
1 #!/bin/sh
3 : ${fvwm_libdir=../../libs}
5 infile=${fvwm_libdir}/Module.h
6 outfile=`dirname $0`/Constants.pm
8 ( \
9 echo "# Autogenerated from the fvwm sources."; \
10 echo ""; \
11 echo "package FVWM::Constants;"; \
12 echo "use Exporter;"; \
13 echo "use Config;"; \
14 echo "@ISA = qw(Exporter);"; \
15 echo ""; \
16 ) \
17 >$outfile
19 ( \
20 grep "#define M_" $infile; \
21 grep "#define MX_" $infile | sed 's/ | /|/'; \
22 grep "#define MAX_MSG_MASK " $infile; \
23 grep "#define MAX_XMSG_MASK " $infile; \
24 grep "#define FvwmPacketHeaderSize " $infile | sed 's/FvwmPacketHeaderSize/HEADER_SIZE/'; \
25 grep "#define START_FLAG " $infile; \
26 grep "#define ModuleFinishedStartupResponse " $infile | tr ' ' : | sed 's/:ModuleFinishedStartupResponse:\+/ RESPONSE_READY /'; \
27 grep "#define ModuleUnlockResponse " $infile | tr ' ' : | sed 's/:ModuleUnlockResponse:\+/ RESPONSE_UNLOCK /'; \
28 ) \
29 | awk '{ print "use constant " $2 " => " $3 ";" }' \
30 | tr : ' ' \
31 >>$outfile
33 ( \
34 echo "use constant ON_EXIT => '1e20';"; \
35 echo "use constant INTSIZE => \$Config{longsize};" \
36 ) \
37 >>$outfile
39 ( \
40 grep constant $outfile | cut -d" " -f3 | awk '{ print " " $1 }'; \
41 ) \
42 >"$outfile.tmp"
44 ( \
45 echo '@EXPORT = qw('; \
46 cat "$outfile.tmp"; \
47 echo ');' \
48 ) \
49 >>$outfile
51 ( \
52 echo "
55 __END__
57 =head1 NAME
59 FVWM::Constants - exports fvwm specific constants
61 =head1 DESCRIPTION
63 This class is used to load fvwm constants into your perl script or class.
64 Note, if you use I<FVWM::Module> the constants are automatically exported.
65 So you usually do not need to include this class.
67 =head1 USAGE
69 use FVWM::Constants;
71 =head1 SEE ALSO
73 For more information, see L<FVWM::Module>.
75 =head1 EXPORTED CONSTANTS
76 "; \
77 cat "$outfile.tmp"; \
78 ) \
79 >>$outfile
81 rm "$outfile.tmp"