35ae12602e8cc6ca9b7bdf419229345e8d040cae
[ncurses.git] / misc / gen-pkgconfig.in
1 #!@SHELL@
2 # $Id: gen-pkgconfig.in,v 1.7 2009/03/14 20:37:54 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 PANEL_NAME=panel # @PANEL_NAME@
43 MENU_NAME=menu # @MENU_NAME@
44 FORM_NAME=form # @FORM_NAME@
45 CXX_NAME=ncurses++ # @CXX_NAME@
46 DFT_DEP_SUFFIX=@DFT_DEP_SUFFIX@
47 CXX_LIB_SUFFIX=@CXX_LIB_SUFFIX@
48
49 prefix="@prefix@"
50 exec_prefix="@exec_prefix@"
51 includedir="@includedir@"
52 libdir="@libdir@"
53
54 show_prefix='@prefix@'
55 show_exec_prefix='@exec_prefix@'
56 show_includedir='@includedir@'
57 show_libdir='@libdir@'
58
59 MAIN_LIBRARY="${LIB_NAME}@DFT_ARG_SUFFIX@"
60 SUB_LIBRARY="${TINFO_NAME}@DFT_ARG_SUFFIX@"
61 PANEL_LIBRARY="${PANEL_NAME}@DFT_ARG_SUFFIX@"
62 MENU_LIBRARY="${MENU_NAME}@DFT_ARG_SUFFIX@"
63 FORM_LIBRARY="${FORM_NAME}@DFT_ARG_SUFFIX@"
64
65 SUB_LIBRARY_REQ=${SUB_LIBRARY}
66 TINFO_NAME_REQ=${TINFO_NAME}
67 if test $TINFO_NAME = $LIB_NAME ; then
68         SUB_LIBRARY_REQ=
69         TINFO_NAME_REQ=
70 fi
71
72 for lib in ../lib/*
73 do
74         name=`basename $lib`
75         if test "$name" = "*" ; then
76                 break
77         fi
78
79         root=`basename $name "$DFT_DEP_SUFFIX"`
80         if test "$name" = "$root" ; then
81                 root=`basename $name "$CXX_LIB_SUFFIX"`
82                 if test "$name" = "$root" ; then
83                         continue
84                 fi
85         fi
86
87         name=`echo "$name" | sed -e 's/^lib//' -e 's/\..*$//'`
88
89         desc="ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@"
90         if test $name = $MAIN_LIBRARY ; then
91                 reqs=$TINFO_NAME_REQ
92                 desc="$desc library"
93         elif test $name = $SUB_LIBRARY ; then
94                 reqs=
95                 desc="$desc terminal interface library"
96         elif expr $name : ".*${CXX_NAME}.*" >/dev/null ; then
97                 reqs="$PANEL_LIBRARY $MENU_LIBRARY $FORM_LIBRARY $MAIN_LIBRARY $SUB_LIBRARY_REQ"
98                 desc="$desc add-on library"
99         else
100                 reqs="$MAIN_LIBRARY $SUB_LIBRARY_REQ"
101                 desc="$desc add-on library"
102         fi
103
104         if test "$includedir" = "/usr/include" ; then
105                 cflags=
106         else
107                 cflags="-I\${includedir}"
108         fi
109
110         if test "$libdir" = "/usr/lib" ; then
111                 libs=
112         else
113                 libs="-L\${libdir}"
114         fi
115         libs="$libs -l$name"
116
117         # add dependencies that pkg-config cannot guess about
118         if test -z "$reqs" ; then
119                 libs="$libs @LIBS@"
120         fi
121
122         echo "** creating ${name}.pc"
123         cat >${name}.pc <<EOF
124 prefix=$show_prefix
125 exec_prefix=$show_exec_prefix
126 libdir=$show_libdir
127 includedir=$show_includedir
128 major_version=@NCURSES_MAJOR@
129 version=@NCURSES_MAJOR@.@NCURSES_MINOR@.@NCURSES_PATCH@
130
131 Name: $name
132 Description: $desc
133 Version: \${version}
134 Requires: $reqs
135 Libs: $libs
136 Cflags: $cflags
137 EOF
138         # pr -f ${name}.pc
139 done
140 # vile:shmode