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

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

fixes #523

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 6.3 KB
Line 
1# $Id: yat-config.in 1898 2009-04-16 15:11:10Z 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@"
35YAT_CPPFLAGS="@YAT_CPPFLAGS@"
36YAT_CXXFLAGS="@YAT_CXXFLAGS@"
37YAT_LDFLAGS="@YAT_LDFLAGS@"
38YAT_PRIMARY_LIBS="@YAT_PRIMARY_LIBS@"
39LIBM="@LIBM@"
40
41if test "x$YAT_CBLAS_LIB" = "x"; then
42  YAT_CBLAS_LIB=@YAT_CBLAS_LIB@
43fi
44
45LA_FILE="$libdir/lib@YAT_LIBNAME@.la"
46if test x$installed = xno; then
47  LA_FILE="@abs_top_builddir@/yat/lib@YAT_LIBNAME@.la"
48fi
49
50usage()
51{
52    cat <<EOF
53Usage: yat-config [OPTION]...
54
55Known values for OPTION are:
56  --prefix                    print prefix
57  --bindir                    print location where binaries are installed
58  --includedir                print location where headers are installed
59  --libdir                    print location where @PACKAGE@ library is installed
60  --cxx                       print C++ compiler name
61  --cxxcpp                    print C++ preprocessor name and required options
62  --cppflags                  print C++ preprocessor flags
63  --cxxflags                  print C++ compiler flags
64  --ldflags                   print linker flags
65  --libs                      print libraries to link against
66  --libs-without-cblas        print libraries to link against except cblas
67  --link-libtool              print the libtool inputs for linking to @PACKAGE@
68  --atleast-version=VERSION   return 0 if @PACKAGE@ is at least version VERSION
69  --version                   print @PACKAGE@'s version
70  --version-major             print @PACKAGE@'s MAJOR version
71  --version-minor             print @PACKAGE@'s MINOR version
72  --version-patch             print @PACKAGE@'s PATCH version
73  --help                      print this help
74
75Report bugs to <@PACKAGE_BUGREPORT@>.
76EOF
77
78    exit $1
79}
80
81
82if test $# -eq 0; then
83    usage 1
84fi
85
86flags=""
87
88while test $# -gt 0; do
89    case "$1" in
90    --prefix)
91    @ECHO@ $prefix
92    exit 0
93    ;;
94    --bindir)
95    @ECHO@ $bindir
96    exit 0
97    ;;
98    --includedir)
99    @ECHO@ $includedir
100    exit 0
101    ;;
102    --libdir)
103    @ECHO@ $libdir
104    exit 0
105    ;;
106    --cxx)
107    @ECHO@ $CXX
108    exit 0
109    ;;
110    --cxxcpp)
111    @ECHO@ $CXXCPP
112    exit 0
113    ;;
114    --cppflags)
115    if test $installed = yes; then
116       if test "x$includedir" = "x/usr/include"; then
117         : # ignore standard include
118       elif (test "$CXX"="g++" &&
119             test "x$includedir"="x/usr/local/include"); then
120         : # ignore /usr/local/include if we use g++
121       else
122         flags="$flags -I$includedir"
123       fi
124    else
125       # second part is for VPATH builds. No need to separate the
126       # cases because redundancy will be removed by unique filtering
127       # below.
128       flags="$flags -I@abs_top_srcdir@ -I@abs_top_builddir@"
129    fi
130    flags="$flags $YAT_CPPFLAGS $CPPFLAGS"
131    ;;
132    --cxxflags)
133    flags="$flags $YAT_CXXFLAGS $CXXFLAGS"
134    ;;
135    --libs)
136    flags="$flags -l@YAT_LIBNAME@ $YAT_PRIMARY_LIBS $YAT_CBLAS_LIB $LIBM $LIBS"
137    ;;
138    --libs-without-cblas)
139    flags="$flags -l@YAT_LIBNAME@ $YAT_PRIMARY_LIBS $LIBM $LIBS"
140    ;;
141    --ldflags)
142    if test "x$libdir" = "x/usr/lib"; then
143      : # ignore standard '/usr/lib'
144    elif (test "$CXX"="g++" &&
145          test "x$libdir"="x/usr/local/lib"); then
146      : # ignore '/usr/local/lib' if we use g++
147    else
148      flags="$flags -L$libdir"
149    fi
150    flags="$flags $YAT_LDFLAGS $LDFLAGS"
151    ;;
152    --link-libtool)
153    flags="$flags $LA_FILE $YAT_CBLAS_LIB"
154    ;;
155    --atleast-version=*)
156      optarg=`@ECHO@ "$1" | sed 's/--atleast-version=//'`
157      min_major=`@ECHO@ "$optarg" | sed 's/\([0-9]*\).*/\1/'`
158      if test "$optarg" = "$min_major"; then
159         min_minor="0";
160      else
161         min_minor=`@ECHO@ "$optarg" | sed 's/[0-9]*.\([0-9]*\).*/\1/'`
162      fi
163      if test "$optarg" = "$min_major.$min_minor"; then
164         min_patch="0";
165      else
166         min_patch=`@ECHO@ "$optarg" | sed 's/[0-9]*.[0-9]*.\([0-9]*\).*/\1/'`
167      fi
168      if test "$optarg" = "$min_patch"; then
169        echo "yat-config: \`$optarg' is not a valid VERSION"
170        exit 255
171      fi
172      if !(test -n "$min_major" && test -n "$min_minor" \
173           && test -n "$min_patch"); then
174        echo "yat-config: \`$optarg' is not a valid VERSION"
175        exit 255
176      fi
177      if ( test $min_major -gt @YAT_MAJOR_VERSION@ || \
178           ( test $min_major -eq @YAT_MAJOR_VERSION@ && \
179             ( test $min_minor -gt @YAT_MINOR_VERSION@ || \
180         ( test $min_minor -eq @YAT_MINOR_VERSION@ && \
181                 ( test $min_patch -gt @YAT_PATCH_VERSION@ ||
182                   (test $min_patch -eq @YAT_PATCH_VERSION@ &&
183                    test "@YAT_DEV_BUILD@" = "true" )))))) ; then
184   exit 1;
185      fi
186      exit 0
187    ;;
188    --version)
189    @ECHO@ @VERSION@
190    exit 0
191    ;;
192    --version-major)
193    @ECHO@ @YAT_MAJOR_VERSION@
194    exit 0
195    ;;
196    --version-minor)
197    @ECHO@ @YAT_MINOR_VERSION@
198    exit 0
199    ;;
200    --version-patch)
201    @ECHO@ @YAT_PATCH_VERSION@
202    exit 0
203    ;;
204    --help)
205    usage 0
206    ;;
207    *)
208    usage 1
209    ;;
210    esac
211
212    # Next please.
213    shift
214done
215
216# only keep last of replicates
217if test -n "$flags"; then
218   reversed_flags=
219   for opt in $flags; do
220     reversed_flags="$opt $reversed_flags"
221   done
222   unique_flags=
223   for opt in $reversed_flags; do
224     unique=1;       
225     for opt2 in $unique_flags; do
226       if test $opt = $opt2; then
227         unique=0
228       fi
229     done
230     if test $unique -eq 1; then
231       unique_flags="$opt $unique_flags"
232     fi
233   done
234   @ECHO@ $unique_flags
235fi
236
237exit 0
Note: See TracBrowser for help on using the repository browser.