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