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

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

Add support for using uninstalled yat-config. Options --cppflags and
--link-libtool now work prior installation. --ldflags is not supported
because I'm not sure how to link against unistalled library and user
should be advised to use libool anyway.

refs #428

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 5.4 KB
Line 
1# $Id: yat-config.in 1697 2009-01-06 16:42:41Z peter $
2
3# Copyright (C) 2008 2009 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
26installed=no
27
28CXX="@CXX@"
29CXXCPP="@CXXCPP@"
30CPPFLAGS="@CPPFLAGS@"
31CXXFLAGS="@CXXFLAGS@"
32LDFLAGS="@LDFLAGS@"
33LIBS="@LIBS@"
34EXTRA_CPPFLAGS="@EXTRA_CPPFLAGS@"
35EXTRA_CXXFLAGS="@EXTRA_CXXFLAGS@"
36EXTRA_LDFLAGS="@EXTRA_LDFLAGS@"
37
38LA_FILE="$libdir/lib@YAT_LIBNAME@.la"
39if test x$installed = xno; then
40  LA_FILE="@abs_top_builddir@/lib@YAT_LIBNAME@.la"
41fi
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 1
76fi
77
78flags=""
79
80while test $# -gt 0; do
81    case "$1" in
82    --prefix)
83    @ECHO@ $prefix
84    exit 0
85    ;;
86    --bindir)
87    @ECHO@ $bindir
88    exit 0
89    ;;
90    --includedir)
91    @ECHO@ $includedir
92    exit 0
93    ;;
94    --libdir)
95    @ECHO@ $libdir
96    exit 0
97    ;;
98    --cxx)
99    @ECHO@ $CXX
100    exit 0
101    ;;
102    --cxxcpp)
103    @ECHO@ $CXXCPP
104    exit 0
105    ;;
106    --cppflags)
107    if test $installed = yes; then
108       flags="$flags -I$includedir"
109    else
110       # second part is for VPATH builds. No need to separate the
111       # cases because redundancy will be removed by unique filtering
112       # below.
113       flags="$flags -I@abs_top_srcdir@ -I@abs_top_builddir@"
114    fi
115    flags="$flags $EXTRA_CPPFLAGS $CPPFLAGS"
116    ;;
117    --cxxflags)
118    flags="$flags $EXTRA_CXXFLAGS $CXXFLAGS"
119    ;;
120    --libs)
121    flags="$flags -l@YAT_LIBNAME@ $LIBS"
122    ;;
123    --ldflags)
124    flags="$flags -L$libdir $EXTRA_LDFLAGS $LDFLAGS"
125    ;;
126    --link-libtool)
127    flags="$flags $LA_FILE"
128    ;;
129    --atleast-version=*)
130      optarg=`@ECHO@ "$1" | sed 's/--atleast-version=//'`
131      min_major=`@ECHO@ "$optarg" | sed 's/\([0-9]*\).*/\1/'`
132      if test "$optarg" = "$min_major"; then
133         min_minor="0";
134      else
135         min_minor=`@ECHO@ "$optarg" | sed 's/[0-9]*.\([0-9]*\).*/\1/'`
136      fi
137      if test "$optarg" = "$min_major.$min_minor"; then
138         min_patch="0";
139      else
140         min_patch=`@ECHO@ "$optarg" | sed 's/[0-9]*.[0-9]*.\([0-9]*\).*/\1/'`
141      fi
142      if test "$optarg" = "$min_patch"; then
143        echo "yat-config: \`$optarg' is not a valid VERSION"
144        exit 255
145      fi
146      if !(test -n "$min_major" && test -n "$min_minor" \
147           && test -n "$min_patch"); then
148        echo "yat-config: \`$optarg' is not a valid VERSION"
149        exit 255
150      fi
151      if ( test $min_major -gt @YAT_MAJOR_VERSION@ || \
152           ( test $min_major -eq @YAT_MAJOR_VERSION@ && \
153             ( test $min_minor -gt @YAT_MINOR_VERSION@ || \
154         ( test $min_minor -eq @YAT_MINOR_VERSION@ && \
155                 ( test $min_patch -gt @YAT_PATCH_VERSION@ ||
156                   (test $min_patch -eq @YAT_PATCH_VERSION@ &&
157                    test "@YAT_DEV_BUILD@" = "true" )))))) ; then
158   exit 1;
159      fi
160      exit 0
161    ;;
162    --version)
163    @ECHO@ @VERSION@
164    exit 0
165    ;;
166    --version-major)
167    @ECHO@ @YAT_MAJOR_VERSION@
168    exit 0
169    ;;
170    --version-minor)
171    @ECHO@ @YAT_MINOR_VERSION@
172    exit 0
173    ;;
174    --version-patch)
175    @ECHO@ @YAT_PATCH_VERSION@
176    exit 0
177    ;;
178    --help)
179    usage 0
180    ;;
181    *)
182    usage 1
183    ;;
184    esac
185
186    # Next please.
187    shift
188done
189
190# only keep last of replicates
191if test -n "$flags"; then
192   reversed_flags=
193   for opt in $flags; do
194     reversed_flags="$opt $reversed_flags"
195   done
196   unique_flags=
197   for opt in $reversed_flags; do
198     unique=1;       
199     for opt2 in $unique_flags; do
200       if test $opt = $opt2; then
201         unique=0
202       fi
203     done
204     if test $unique -eq 1; then
205       unique_flags="$opt $unique_flags"
206     fi
207   done
208   @ECHO@ $unique_flags
209fi
210
211exit 0
Note: See TracBrowser for help on using the repository browser.