Fix Portland compiler warnings
[alexxy/gromacs.git] / src / gromacs / selection / regenerate_parser.sh
1 #!/bin/bash
2 #
3 # This script runs Bison and/or Flex to regenerate the files as follows:
4 #   parser.y  -> parser.cpp, parser.h
5 #   scanner.l -> scanner.cpp, scanner_flex.h
6 # The commands are run only if the generated files are older than the
7 # Bison/Flex input files, or if a '-f' flag is provided.
8
9 # Note: You can check parser.cpp/scanner.cpp for the exact versions of
10 # bison/flex that were used in the generation. Some OSs have older versions
11 # of these tools installed.
12
13 FORCE=
14 if [ "x$1" == "x-f" ] ; then
15     FORCE=1
16 fi
17
18 if [ "x$BISON" == "x" ] ; then
19     BISON=bison
20 fi
21 if [ "x$FLEX" == "x" ] ; then
22     FLEX=flex
23 fi
24
25 # For convenience, change to the directory where the files are located
26 # if the script is run from the root of the source tree.
27 dirname=src/gromacs/selection
28 if [[ -f $dirname/parser.y && -f $dirname/scanner.l ]] ; then
29     cd $dirname
30 fi
31
32 # We apply some trivial patches to the output to avoid warnings for PGI
33 # (and maybe other) compilers
34 [[ $FORCE || parser.y  -nt parser.cpp ]]  && $BISON -t -o parser.cpp --defines=parser.h parser.y && patch -p0 < parser.patch && rm -f parser.cpp.orig
35 [[ $FORCE || scanner.l -nt scanner.cpp ]] && $FLEX -o scanner.cpp scanner.l && patch -p0 < scanner.patch && rm -f scanner.cpp.orig