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

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

Removed dependency to cblas in libyat. There are three new make
variables: YAT_LIBS, YAT_LIBS_WITHOUT_CLAS and YAT_CBLAS_LIB.

  • The variable YAT_LIBS is created as follows: First the LIBS provided

by user is saved (most often empty). Then when detecting libs, they
are added to the variable LIBS and in the end of the configure run
YAT_LIBS is created as the difference between LIBS and the original
LIBS.

  • YAT_CLAS_LIB is detected as before.
  • YAT_LIBS_WITHOUT_CLAS is copied from YAT_LIBS but ignoring YAT_CLAS_LIB

I also changed the name of some variables to make the code clearer (I
hope). The prefix INTERNAL_ is used for flags that should only be used
when building yat and not needed for a user building against
yat. Flags that should be propagated have no prefix, for example,
CPPFLAGS.

In the end of configure these flags are used to create YAT_CPPFLAGS
using the same mechanism as when creating YAT_LIBS.

In the last step variables such as AM_CPPFLAGS is created as the
'union' of YAT_CPPFLAGS and INTERNAL_CPPFLAGS and these are propagated
to the Makefiles where they are used by Automake generated rules.

refs #518

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