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

Last change on this file since 1897 was 1897, checked in by Peter, 12 years ago

fixes #522. Introduced a variable YAT_PRIMARY_LIBS that is YAT_LIBS
minus cblas and mathlib. The variable made it easier to create needed
variables in yat-config (string addition is easier than subtraction,
whatever that means). Removed variable YAT_LIBS_WITHOUT_CBLAS because
it can easily be achied via "YAT_PRIMARY_LIBS LIBM".

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