source: trunk/build_support/yat-config.in

Last change on this file was 3800, checked in by Peter, 2 years ago

allow multiple arguments in yat-config. closes #911

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