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

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

fixes #505

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