source: trunk/build_support/yat-config.in @ 1689

Last change on this file since 1689 was 1689, checked in by Peter, 13 years ago

correcting exit code

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 5.0 KB
Line 
1# $Id: yat-config.in 1689 2008-12-31 13:43:44Z peter $
2
3# Copyright (C) 2008 Peter Johansson
4#
5# This file is part of the yat library, http://dev.thep.lu.se/yat
6#
7# The yat library is free software; you can redistribute it and/or
8# modify it under the terms of the GNU General Public License as
9# published by the Free Software Foundation; either version 3 of the
10# License, or (at your option) any later version.
11#
12# The yat library is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15# General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with yat. If not, see <http://www.gnu.org/licenses/>.
19
20prefix="@prefix@"
21exec_prefix="@exec_prefix@"
22bindir="@bindir@"
23libdir="@libdir@"
24includedir="@includedir@"
25
26CXX="@CXX@"
27CXXCPP="@CXXCPP@"
28CPPFLAGS="@CPPFLAGS@"
29CXXFLAGS="@CXXFLAGS@"
30LDFLAGS="@LDFLAGS@"
31LIBS="@LIBS@"
32EXTRA_CPPFLAGS="@EXTRA_CPPFLAGS@"
33EXTRA_CXXFLAGS="@EXTRA_CXXFLAGS@"
34EXTRA_LDFLAGS="@EXTRA_LDFLAGS@"
35
36LA_FILE="$libdir/lib@YAT_LIBNAME@.la"
37
38usage()
39{
40    cat <<EOF
41Usage: yat-config [OPTION]...
42
43Known values for OPTION are:
44  --prefix                    print prefix
45  --bindir                    print location where binaries are installed
46  --includedir                print location where headers are installed
47  --libdir                    print location where @PACKAGE@ library is installed
48  --cxx                       print C++ compiler name
49  --cxxcpp                    print C++ preprocessor name and required options
50  --cppflags                  print C++ preprocessor flags
51  --cxxflags                  print C++ compiler flags
52  --ldflags                   print linker flags
53  --libs                      print libraries to link against
54  --link-libtool              print the libtool inputs for linking to @PACKAGE@
55  --atleast-version=VERSION   return 0 if @PACKAGE@ is at least version VERSION
56  --version                   print @PACKAGE@'s version
57  --version-major             print @PACKAGE@'s MAJOR version
58  --version-minor             print @PACKAGE@'s MINOR version
59  --version-patch             print @PACKAGE@'s PATCH version
60  --help                      print this help
61
62Report bugs to <@PACKAGE_BUGREPORT@>.
63EOF
64
65    exit $1
66}
67
68
69if test $# -eq 0; then
70    usage 1
71fi
72
73flags=""
74
75while test $# -gt 0; do
76    case "$1" in
77    --prefix)
78    @ECHO@ $prefix
79    exit 0
80    ;;
81    --bindir)
82    @ECHO@ $bindir
83    exit 0
84    ;;
85    --includedir)
86    @ECHO@ $includedir
87    exit 0
88    ;;
89    --libdir)
90    @ECHO@ $libdir
91    exit 0
92    ;;
93    --cxx)
94    @ECHO@ $CXX
95    exit 0
96    ;;
97    --cxxcpp)
98    @ECHO@ $CXXCPP
99    exit 0
100    ;;
101    --cppflags)
102    flags="$flags -I$includedir $EXTRA_CPPFLAGS $CPPFLAGS"
103    ;;
104    --cxxflags)
105    flags="$flags $EXTRA_CXXFLAGS $CXXFLAGS"
106    ;;
107    --libs)
108    flags="$flags -l@YAT_LIBNAME@ $LIBS"
109    ;;
110    --ldflags)
111    flags="$flags -L$libdir $EXTRA_LDFLAGS $LDFLAGS"
112    ;;
113    --link-libtool)
114    flags="$flags $LA_FILE"
115    ;;
116    --atleast-version=*)
117      optarg=`@ECHO@ "$1" | sed 's/--atleast-version=//'`
118      min_major=`@ECHO@ "$optarg" | sed 's/\([0-9]*\).*/\1/'`
119      if test "$optarg" = "$min_major"; then
120         min_minor="0";
121      else
122         min_minor=`@ECHO@ "$optarg" | sed 's/[0-9]*.\([0-9]*\).*/\1/'`
123      fi
124      if test "$optarg" = "$min_major.$min_minor"; then
125         min_patch="0";
126      else
127         min_patch=`@ECHO@ "$optarg" | sed 's/[0-9]*.[0-9]*.\([0-9]*\).*/\1/'`
128      fi
129      if test "$optarg" = "$min_patch"; then
130        echo "yat-config: \`$optarg' is not a valid VERSION"
131        exit 255
132      fi
133      if !(test -n "$min_major" && test -n "$min_minor" \
134           && test -n "$min_patch"); then
135        echo "yat-config: \`$optarg' is not a valid VERSION"
136        exit 255
137      fi
138      if ( test $min_major -gt @YAT_MAJOR_VERSION@ || \
139           ( test $min_major -eq @YAT_MAJOR_VERSION@ && \
140             ( test $min_minor -gt @YAT_MINOR_VERSION@ || \
141         ( test $min_minor -eq @YAT_MINOR_VERSION@ && \
142                 ( test $min_patch -gt @YAT_PATCH_VERSION@ ||
143                   (test $min_patch -eq @YAT_PATCH_VERSION@ &&
144                    test "@YAT_DEV_BUILD@" = "true" )))))) ; then
145   exit 1;
146      fi
147      exit 0
148    ;;
149    --version)
150    @ECHO@ @VERSION@
151    exit 0
152    ;;
153    --version-major)
154    @ECHO@ @YAT_MAJOR_VERSION@
155    exit 0
156    ;;
157    --version-minor)
158    @ECHO@ @YAT_MINOR_VERSION@
159    exit 0
160    ;;
161    --version-patch)
162    @ECHO@ @YAT_PATCH_VERSION@
163    exit 0
164    ;;
165    --help)
166    usage 0
167    ;;
168    *)
169    usage 1
170    ;;
171    esac
172
173    # Next please.
174    shift
175done
176
177# only keep last of replicates
178if test -n "$flags"; then
179   reversed_flags=
180   for opt in $flags; do
181     reversed_flags="$opt $reversed_flags"
182   done
183   unique_flags=
184   for opt in $reversed_flags; do
185     unique=1;       
186     for opt2 in $unique_flags; do
187       if test $opt = $opt2; then
188         unique=0
189       fi
190     done
191     if test $unique -eq 1; then
192       unique_flags="$opt $unique_flags"
193     fi
194   done
195   @ECHO@ $unique_flags
196fi
197
198exit 0
Note: See TracBrowser for help on using the repository browser.