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

Last change on this file since 1349 was 1348, checked in by Peter, 15 years ago

adding a yat-config script (fixes #353)
also fixes ticket #376 by using some magic from apr

File size: 3.5 KB
Line 
1#! @SHELL@
2# @configure_input@
3
4# $Id$
5
6# Copyright (C) 2008 Peter Johansson
7#
8# This file is part of the yat library, http://trac.thep.lu.se/yat
9#
10# The yat library is free software; you can redistribute it and/or
11# modify it under the terms of the GNU General Public License as
12# published by the Free Software Foundation; either version 2 of the
13# License, or (at your option) any later version.
14#
15# The yat library is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18# General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program; if not, write to the Free Software
22# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23# 02111-1307, USA.
24
25prefix="@prefix@"
26exec_prefix="@exec_prefix@"
27bindir="@bindir@"
28libdir="@libdir@"
29includedir="@includedir@"
30
31CXX="@CXX@"
32CXXCPP="@CXXCPP@"
33CPPFLAGS="@CPPFLAGS@"
34CXXFLAGS="@CXXFLAGS@"
35LDFLAGS="@LDFLAGS@"
36LIBS="@LIBS@"
37EXTRA_CPPFLAGS="@EXTRA_CPPFLAGS@"
38EXTRA_CXXFLAGS="@EXTRA_CXXFLAGS@"
39EXTRA_LDFLAGS="@EXTRA_LDFLAGS@"
40YAT_LIBNAME="@YAT_LIBNAME@"
41
42usage()
43{
44    cat <<EOF
45Usage: yat-config [OPTION]...
46
47Known values for OPTION are:
48  --prefix          print yat installation prefix
49  --bindir          print location where binaries are installed
50  --includedir      print location where headers are installed
51  --cxx             print C++ compiler name
52  --cxxcpp          print C++ preprocessor name and any required options
53  --cppflags        print C++ preprocessor flags
54  --cxxflags        print C++ compiler flags
55  --ldflags         print linker flags
56  --libs            print additional libraries to link against
57  --link-ld         print link switch(es) for linking to yat
58  --version         print yat's version
59  --version-major   print yat's MAJOR version
60  --version-minor   print yat's MINOR version
61  --version-patch   print yat's PATCH version
62  --help            print this help
63
64EOF
65
66    exit $1
67}
68
69
70if test $# -eq 0; then
71    usage
72    exit 1
73fi
74
75flags=""
76
77while test $# -gt 0; do
78    case "$1" in
79    --prefix)
80    @ECHO@ $prefix
81    exit 0
82    ;;
83    --bindir)
84    @ECHO@ $bindir
85    exit 0
86    ;;
87    --includedir)
88    @ECHO@ $includedir
89    exit 0
90    ;;
91    --cxx)
92    @ECHO@ $CXX
93    exit 0
94    ;;
95    --cxxcpp)
96    @ECHO@ $CXXCPP
97    exit 0
98    ;;
99    --cppflags)
100    flags="$flags -I$includedir $EXTRA_CPPFLAGS $CPPFLAGS"
101    ;;
102    --cxxflags)
103    flags="$flags $EXTRA_CXXFLAGS $CXXFLAGS"
104    ;;
105    --libs)
106    flags="$flags $LIBS"
107    ;;
108    --ldflags)
109    flags="$flags $EXTRA_LDFLAGS $LDFLAGS"
110    ;;
111    --link-ld)
112    flags="$flags -L$libdir -l${YAT_LIBNAME}"
113    ;;
114    --version)
115    @ECHO@ @VERSION@
116    exit 0
117    ;;
118    --version-major)
119    @ECHO@ @YAT_MAJOR_VERSION@
120    exit 0
121    ;;
122    --version-minor)
123    @ECHO@ @YAT_MINOR_VERSION@
124    exit 0
125    ;;
126    --version-patch)
127    @ECHO@ @YAT_PATCH_VERSION@
128    exit 0
129    ;;
130    --help)
131    usage
132    exit 0
133    ;;
134    *)
135    usage
136    exit 1
137    ;;
138    esac
139
140    # Next please.
141    shift
142done
143
144# only keep last of replicates
145if test -n "$flags"; then
146   reversed_flags=
147   for opt in $flags; do
148     reversed_flags="$opt $reversed_flags"
149   done
150   unique_flags=
151   for opt in $reversed_flags; do
152     unique=1;       
153     for opt2 in $unique_flags; do
154       if test $opt = $opt2; then
155         unique=0
156       fi
157     done
158     if test $unique -eq 1; then
159       unique_flags="$opt $unique_flags"
160     fi
161   done
162   @ECHO@ $unique_flags
163fi
164
165exit 0
Note: See TracBrowser for help on using the repository browser.