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

Last change on this file since 3133 was 3133, checked in by Peter, 8 years ago

yat-config: mention that YAT_CBLAS_LIB is overideable; doxygen docs: prefer quotation like 'this', remove trailing WS, and give an easy example using yat-config in Makefile with default rules.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 7.0 KB
Line 
1# $Id: yat-config.in 3133 2013-11-24 01:06:28Z peter $
2
3# Copyright (C) 2008 Jari Häkkinen, Peter Johansson
4# Copyright (C) 2009, 2010, 2011, 2012, 2013 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
27abs_top_builddir="@abs_top_builddir@"
28abs_top_srcdir="@abs_top_srcdir@"
29
30installed=no
31
32CXX="@CXX@"
33CXXCPP="@CXXCPP@"
34CPPFLAGS="@CPPFLAGS@"
35CXXFLAGS="@CXXFLAGS@"
36LDFLAGS="@LDFLAGS@"
37LIBS="@LIBS@"
38YAT_CPPFLAGS="@YAT_CPPFLAGS@"
39YAT_CXXFLAGS="@YAT_CXXFLAGS@"
40YAT_LDFLAGS="@YAT_LDFLAGS@"
41YAT_PRIMARY_LIBS="@YAT_PRIMARY_LIBS@"
42YAT_STATIC_LIBS="@YAT_STATIC_LIBS@"
43LIBM="@LIBM@"
44
45# user is always right
46test -z "$YAT_CBLAS_LIB" && YAT_CBLAS_LIB="@YAT_CBLAS_LIB@"
47
48LA_FILE="$libdir/libyat.la"
49if test x$installed = xno; then
50  LA_FILE="@abs_top_builddir@/yat/libyat.la"
51fi
52
53usage()
54{
55    cat <<EOF
56Usage: yat-config [OPTION]...
57
58Known values for OPTION are:
59  --prefix                    print prefix
60  --bindir                    print location where binaries are installed
61  --includedir                print location where headers are installed
62  --libdir                    print location where @PACKAGE@ library is installed
63  --cxx                       print C++ compiler name
64  --cxxcpp                    print C++ preprocessor name and required options
65  --cppflags                  print C++ preprocessor flags
66  --cxxflags                  print C++ compiler flags
67  --ldflags                   print linker flags
68  --libs                      print libraries to link against
69  --libs-without-cblas        print libraries to link against except cblas
70  --link-libtool              print the libtool inputs for linking to @PACKAGE@
71  --yat-la-file               print the path to the .la file
72  --atleast-version=VERSION   return 0 if @PACKAGE@ is at least version VERSION
73  --version                   print @PACKAGE@'s version
74  --version-major             print @PACKAGE@'s MAJOR version
75  --version-minor             print @PACKAGE@'s MINOR version
76  --version-patch             print @PACKAGE@'s PATCH version
77  --help                      print this help and exit
78
79An alternative CBLAS library can be specified using the YAT_CBLAS_LIB
80environment variable. The CBLAS library detected during configuration
81is used by default (@YAT_CBLAS_LIB@).
82
83Report bugs to <@PACKAGE_BUGREPORT@>.
84EOF
85
86    exit $1
87}
88
89
90if test $# -eq 0; then
91    usage 1
92fi
93
94flags=""
95
96while test $# -gt 0; do
97    case "$1" in
98    --prefix)
99    echo $prefix
100    exit 0
101    ;;
102    --bindir)
103    echo $bindir
104    exit 0
105    ;;
106    --includedir)
107    echo $includedir
108    exit 0
109    ;;
110    --libdir)
111    echo $libdir
112    exit 0
113    ;;
114    --cxx)
115    echo $CXX
116    exit 0
117    ;;
118    --cxxcpp)
119    echo $CXXCPP
120    exit 0
121    ;;
122    --cppflags)
123    if test $installed = yes; then
124       if test "x$includedir" = "x/usr/include"; then
125         : # ignore standard include
126       elif (test "$CXX" = "g++" &&
127             test "x$includedir" = "x/usr/local/include"); then
128         : # ignore /usr/local/include if we use g++
129       else
130         flags="$flags -I$includedir"
131       fi
132    else
133       # For VPATH build we need to add path to some generated files
134       # The second part is to allow header files in `yat/utility' to
135       # include generated files simply as "generated.h".
136       if test "x$abs_top_builddir" != "x$abs_top_srcdir"; then
137          flags="$flags -I$abs_top_builddir"
138          flags="$flags -I$abs_top_builddir/yat/utility"
139       fi
140       flags="$flags -I$abs_top_srcdir"
141    fi
142    flags="$flags $YAT_CPPFLAGS $CPPFLAGS"
143    ;;
144    --cxxflags)
145    flags="$flags $YAT_CXXFLAGS $CXXFLAGS"
146    ;;
147    --libs)
148    flags="$flags -lyat $YAT_STATIC_LIBS $YAT_PRIMARY_LIBS $YAT_CBLAS_LIB $LIBM $LIBS"
149    ;;
150    --libs-without-cblas)
151    flags="$flags -lyat $YAT_STATIC_LIBS $YAT_PRIMARY_LIBS $LIBM $LIBS"
152    ;;
153    --ldflags)
154    if test "x$libdir" = "x/usr/lib"; then
155      : # ignore standard '/usr/lib'
156    elif (test "$CXX" = "g++" &&
157          test "x$libdir" = "x/usr/local/lib"); then
158      : # ignore '/usr/local/lib' if we use g++
159    else
160      flags="$flags -L$libdir"
161    fi
162    flags="$flags $YAT_LDFLAGS $LDFLAGS"
163    ;;
164    --link-libtool)
165    flags="$flags $LA_FILE $YAT_STATIC_LIBS $YAT_CBLAS_LIB"
166    ;;
167    --yat-la-file)
168    flags="$flags $LA_FILE"
169    ;;
170    --atleast-version=*)
171      optarg=`echo "$1" | sed 's/--atleast-version=//'`
172      min_major=`echo "$optarg" | sed 's/\([0-9]*\).*/\1/'`
173      if test "$optarg" = "$min_major"; then
174         min_minor="0";
175      else
176         min_minor=`echo "$optarg" | sed 's/[0-9]*.\([0-9]*\).*/\1/'`
177      fi
178      if test "$optarg" = "$min_major.$min_minor"; then
179         min_patch="0";
180      else
181         min_patch=`echo "$optarg" | sed 's/[0-9]*.[0-9]*.\([0-9]*\).*/\1/'`
182      fi
183      if test "$optarg" = "$min_patch"; then
184        echo "yat-config: \`$optarg' is not a valid VERSION"
185        exit 255
186      fi
187      if !(test -n "$min_major" && test -n "$min_minor" \
188           && test -n "$min_patch"); then
189        echo "yat-config: \`$optarg' is not a valid VERSION"
190        exit 255
191      fi
192      if ( test $min_major -gt @YAT_MAJOR_VERSION@ || \
193           ( test $min_major -eq @YAT_MAJOR_VERSION@ && \
194             ( test $min_minor -gt @YAT_MINOR_VERSION@ || \
195               ( test $min_minor -eq @YAT_MINOR_VERSION@ && \
196                 ( test $min_patch -gt @YAT_PATCH_VERSION@ ||
197                   (test $min_patch -eq @YAT_PATCH_VERSION@ &&
198                    test "@YAT_DEV_BUILD@" = "true" )))))) ; then
199      exit 1;
200      fi
201      exit 0
202    ;;
203    --version)
204    echo @VERSION@
205    exit 0
206    ;;
207    --version-major)
208    echo @YAT_MAJOR_VERSION@
209    exit 0
210    ;;
211    --version-minor)
212    echo @YAT_MINOR_VERSION@
213    exit 0
214    ;;
215    --version-patch)
216    echo @YAT_PATCH_VERSION@
217    exit 0
218    ;;
219    --help)
220    usage 0
221    ;;
222    *)
223    echo "yat-config: unrecognized option '$1'" >&2
224    echo "Try \`yat-config --help' for more information." >&2
225    exit 1
226    ;;
227    esac
228
229    # Next please.
230    shift
231done
232
233# only keep last of replicates
234if test -n "$flags"; then
235   reversed_flags=
236   for opt in $flags; do
237     reversed_flags="$opt $reversed_flags"
238   done
239   unique_flags=
240   for opt in $reversed_flags; do
241     unique=1;
242     for opt2 in $unique_flags; do
243       if test $opt = $opt2; then
244         unique=0
245       fi
246     done
247     if test $unique -eq 1; then
248       unique_flags="$opt $unique_flags"
249     fi
250   done
251   echo $unique_flags
252fi
253
254exit 0
Note: See TracBrowser for help on using the repository browser.