ncurses 6.1 - patch 20180721
[ncurses.git] / misc / gen-pkgconfig.in
1 #!@SHELL@
2 # $Id: gen-pkgconfig.in,v 1.34 2018/06/09 22:21:33 tom Exp $
3 ##############################################################################
4 # Copyright (c) 2009-2015,2018 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 PRIVATE_LIBS="@PRIVATE_LIBS@"
50
51 suffix=@PC_MODULE_SUFFIX@
52 prefix="@prefix@"
53 exec_prefix="@exec_prefix@"
54 includedir="@includedir@@includesubdir@"
55 libdir="@libdir@"
56
57 show_prefix='@prefix@'
58 show_exec_prefix='@exec_prefix@'
59 show_includedir='@includedir@@includesubdir@'
60 show_libdir='@libdir@'
61
62 MAIN_LIBRARY="${LIB_NAME}@USE_ARG_SUFFIX@"
63 SUB_LIBRARY="${TINFO_ARG_SUFFIX}"
64 PANEL_LIBRARY="${PANEL_NAME}@USE_ARG_SUFFIX@"
65 MENU_LIBRARY="${MENU_NAME}@USE_ARG_SUFFIX@"
66 FORM_LIBRARY="${FORM_NAME}@USE_ARG_SUFFIX@"
67
68 CFLAGS="@PKG_CFLAGS@"
69 if test "$includedir" != "/usr/include" ; then
70         includetop=`echo "$includedir" | sed -e 's,/include/[^/]*$,/include,'`
71         test "$includetop" = "/usr/include" && includetop="$includedir"
72         if test "x$includetop" != "x$includedir"
73         then
74                 CFLAGS="$CFLAGS -I${includetop}"
75         fi
76         CFLAGS="$CFLAGS -I\${includedir}"
77 fi
78
79 LDFLAGS=
80 if test "$libdir" != "/usr/lib" ; then
81         LDFLAGS="$LDFLAGS -L\${libdir}"
82 fi
83 if test "x@EXTRA_LDFLAGS@" != "x" ; then
84         LDFLAGS="$LDFLAGS @EXTRA_LDFLAGS@"
85 fi
86
87 # Check if we should specify the tinfo library explicitly so that terminfo
88 # functions or curses variables (which also reside in tinfo) can be linked
89 # using the -lncurses option.
90 NEED_TINFO=no
91 if test "x@TINFO_LIBS@" != "x" && \
92    test "x$TINFO_ARG_SUFFIX" != "x$MAIN_LIBRARY"
93 then
94         NEED_TINFO=yes
95 fi
96
97 for name in @PC_MODULES_TO_MAKE@
98 do
99         name="${name}"
100         LIBS="-l$name"
101
102         desc="ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@"
103         reqs=
104
105         if test $name = $MAIN_LIBRARY ; then
106                 desc="$desc library"
107                 test $NEED_TINFO = yes && LIBS="$LIBS -l$TINFO_ARG_SUFFIX"
108         elif test $name = $SUB_LIBRARY ; then
109                 desc="$desc terminal interface library"
110         elif expr $name : ".*${CXX_NAME}.*" >/dev/null ; then
111                 reqs="$PANEL_LIBRARY${suffix}, $MENU_LIBRARY${suffix}, $FORM_LIBRARY${suffix}, $MAIN_LIBRARY${suffix}"
112                 desc="$desc add-on library"
113         else
114                 reqs="$MAIN_LIBRARY${suffix}"
115                 desc="$desc add-on library"
116         fi
117
118         if test $name != $SUB_LIBRARY && \
119            test $SUB_LIBRARY != $MAIN_LIBRARY && \
120            test $name != $TINFO_NAME && \
121            test $NEED_TINFO != yes ; then
122                 test -n "$reqs" && reqs="$reqs, "
123                 reqs="${reqs}${SUB_LIBRARY}${suffix}"
124         fi
125
126         if test $name = $MAIN_LIBRARY
127         then
128                 main_libs="$PRIVATE_LIBS"
129         else
130                 main_libs=
131         fi
132
133         echo "** creating ${name}${suffix}.pc"
134         cat >${name}${suffix}.pc <<EOF
135 # pkg-config file generated by `basename $0`
136 # vile:makemode
137
138 prefix=$show_prefix
139 exec_prefix=$show_exec_prefix
140 libdir=$show_libdir
141 includedir=$show_includedir
142 abi_version=@cf_cv_abi_version@
143 major_version=@NCURSES_MAJOR@
144 version=@NCURSES_MAJOR@.@NCURSES_MINOR@.@NCURSES_PATCH@
145
146 Name: ${name}${suffix}
147 Description: $desc
148 Version: \${version}
149 URL: https://invisible-island.net/ncurses
150 Requires.private: $reqs
151 Libs: $LDFLAGS $LIBS
152 Libs.private: @LIBS@ $main_libs
153 Cflags: $CFLAGS
154 EOF
155
156 done
157 # vile:shmode