92fcda68b758ae25a890159cd8cd06d5960466ed
[ncurses.git] / gen-pkgconfig.in
1 #!@SHELL@
2 # $Id: gen-pkgconfig.in,v 1.16 2014/01/18 20:21:45 tom Exp $
3 ##############################################################################
4 # Copyright (c) 2009-2013,2014 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
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_NAME@
43 MENU_NAME=@MENU_NAME@
44 FORM_NAME=@FORM_NAME@
45 CXX_NAME=@CXX_NAME@
46 DFT_DEP_SUFFIX=@DFT_DEP_SUFFIX@
47 TINFO_ARG_SUFFIX=@TINFO_ARG_SUFFIX@
48 CXX_LIB_SUFFIX=@CXX_LIB_SUFFIX@
49
50 prefix="@prefix@"
51 exec_prefix="@exec_prefix@"
52 includedir="@includedir@@includesubdir@"
53 libdir="@libdir@"
54
55 show_prefix='@prefix@'
56 show_exec_prefix='@exec_prefix@'
57 show_includedir='@includedir@@includesubdir@'
58 show_libdir='@libdir@'
59
60 MAIN_LIBRARY="${LIB_NAME}@DFT_ARG_SUFFIX@"
61 SUB_LIBRARY="${TINFO_ARG_SUFFIX}"
62 PANEL_LIBRARY="${PANEL_NAME}@DFT_ARG_SUFFIX@"
63 MENU_LIBRARY="${MENU_NAME}@DFT_ARG_SUFFIX@"
64 FORM_LIBRARY="${FORM_NAME}@DFT_ARG_SUFFIX@"
65
66 if test "$includedir" = "/usr/include" ; then
67         CFLAGS=
68 else
69         CFLAGS="-I\${includedir}"
70 fi
71
72 if test "$libdir" = "/usr/lib" ; then
73         LDFLAGS=
74 else
75         LDFLAGS="-L\${libdir}"
76 fi
77
78 for name in @PC_MODULES_TO_MAKE@
79 do
80         name="${name}"
81
82         desc="ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@"
83         reqs=
84
85         if test $name = $MAIN_LIBRARY ; then
86                 desc="$desc library"
87         elif test $name = $SUB_LIBRARY ; then
88                 desc="$desc terminal interface library"
89         elif expr $name : ".*${CXX_NAME}.*" >/dev/null ; then
90                 reqs="$PANEL_LIBRARY, $MENU_LIBRARY, $FORM_LIBRARY, $MAIN_LIBRARY"
91                 desc="$desc add-on library"
92         else
93                 reqs="$MAIN_LIBRARY"
94                 desc="$desc add-on library"
95         fi
96
97         if test $name != $SUB_LIBRARY && test $SUB_LIBRARY != $MAIN_LIBRARY ; then
98                 if test $name != $TINFO_NAME ; then
99                         test -n "$reqs" && reqs="$reqs, "
100                         reqs="${reqs}${SUB_LIBRARY}"
101                 fi
102         fi
103
104         echo "** creating ${name}.pc"
105         cat >${name}.pc <<EOF
106 prefix=$show_prefix
107 exec_prefix=$show_exec_prefix
108 libdir=$show_libdir
109 includedir=$show_includedir
110 major_version=@NCURSES_MAJOR@
111 version=@NCURSES_MAJOR@.@NCURSES_MINOR@.@NCURSES_PATCH@
112
113 Name: $name
114 Description: $desc
115 Version: \${version}
116 URL: http://invisible-island.net/ncurses
117 Requires.private: $reqs
118 Libs: $LDFLAGS -l$name
119 Libs.private: @LIBS@
120 Cflags: $CFLAGS
121 EOF
122
123         #pr -f ${name}.pc
124 done
125 # vile:shmode