]> ncurses.scripts.mit.edu Git - ncurses.git/blob - misc/gen-pkgconfig.in
75e95b3bfbf3dfd0d9347c91b7a9354cf1e4c1b8
[ncurses.git] / misc / gen-pkgconfig.in
1 #!@SHELL@
2 # $Id: gen-pkgconfig.in,v 1.5 2009/01/24 21:06:36 tom Exp $
3 ##############################################################################
4 # Copyright (c) 2009 Free Software Foundation, Inc.                          #
5 #                                                                            #
6 # Permission is hereby granted, free of charge, to any person obtaining a    #
7 # copy of this software and associated documentation files (the "Software"), #
8 # to deal in the Software without restriction, including without limitation  #
9 # the rights to use, copy, modify, merge, publish, distribute, distribute    #
10 # with modifications, sublicense, and/or sell copies of the Software, and to #
11 # permit persons to whom the Software is furnished to do so, subject to the  #
12 # following conditions:                                                      #
13 #                                                                            #
14 # The above copyright notice and this permission notice shall be included in #
15 # all copies or substantial portions of the Software.                        #
16 #                                                                            #
17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
18 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
19 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
20 # THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
21 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
22 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
23 # DEALINGS IN THE SOFTWARE.                                                  #
24 #                                                                            #
25 # Except as contained in this notice, the name(s) of the above copyright     #
26 # holders shall not be used in advertising or otherwise to promote the sale, #
27 # use or other dealings in this Software without prior written               #
28 # authorization.                                                             #
29 ##############################################################################
30 #
31 # Author: Thomas E. Dickey, 2009
32 #
33 # The complete configure script for ncurses is the ncurses5-config (or similar
34 # name, depending on the flavor, e.g., ncursesw5-config, ncurses6-config, etc).
35 # That provides more information than pkg-config, and is the portable and
36 # recommended solution.
37 #
38 # For each library, generate a ".pc" file which depends on the base ncurses
39 # library, except that the tinfo library does not depend on ncurses.
40 LIB_NAME=@LIB_NAME@
41 TINFO_NAME=@TINFO_NAME@
42 DFT_DEP_SUFFIX=@DFT_DEP_SUFFIX@
43 CXX_LIB_SUFFIX=@CXX_LIB_SUFFIX@
44
45 prefix="@prefix@"
46 exec_prefix="@exec_prefix@"
47 includedir="@includedir@"
48 libdir="@libdir@"
49
50 show_prefix='@prefix@'
51 show_exec_prefix='@exec_prefix@'
52 show_includedir='@includedir@'
53 show_libdir='@libdir@'
54
55 MAIN_LIBRARY="${LIB_NAME}@DFT_ARG_SUFFIX@"
56 SUB_LIBRARY="${TINFO_NAME}@DFT_ARG_SUFFIX@"
57
58 for lib in ../lib/*
59 do
60         name=`basename $lib`
61         root=`basename $name "$DFT_DEP_SUFFIX"`
62         if test "$name" = "$root" ; then
63                 root=`basename $name "$CXX_LIB_SUFFIX"`
64                 if test "$name" = "$root" ; then
65                         continue
66                 fi
67         fi
68
69         name=`echo "$name" | sed -e 's/^lib//' -e 's/\..*$//'`
70
71         desc="ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@"
72         if test $name = $MAIN_LIBRARY ; then
73                 reqs=
74                 desc="$desc library"
75         elif test $name = $SUB_LIBRARY ; then
76                 reqs=
77                 desc="$desc terminal interface library"
78         else
79                 reqs=$MAIN_LIBRARY
80                 desc="$desc add-on library"
81         fi
82
83         if test "$includedir" = "/usr/include" ; then
84                 cflags=
85         else
86                 cflags="-I\${includedir}"
87         fi
88
89         if test "$libdir" = "/usr/lib" ; then
90                 libs=
91         else
92                 libs="-L\${libdir}"
93         fi
94         libs="$libs -l$name"
95
96         # add dependencies that pkg-config cannot guess about
97         if test -z "$reqs" ; then
98                 libs="$libs @LIBS@"
99         fi
100
101         echo "** creating ${name}.pc"
102         cat >${name}.pc <<EOF
103 prefix=$show_prefix
104 exec_prefix=$show_exec_prefix
105 libdir=$show_libdir
106 includedir=$show_includedir
107 major_version=@NCURSES_MAJOR@
108 version=@NCURSES_MAJOR@.@NCURSES_MINOR@.@NCURSES_PATCH@
109
110 Name: $name
111 Description: $desc
112 Version: \${version}
113 Requires: $reqs
114 Libs: $libs
115 Cflags: $cflags
116 EOF
117         # pr -f ${name}.pc
118 done
119 # vile:shmode