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