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

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

corrected bug in parsing of argument and added error msg when arg is not valid

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