ncurses 6.2 - patch 20210807
[ncurses.git] / misc / ncurses-config.in
1 #!@SHELL@
2 # $Id: ncurses-config.in,v 1.50 2021/08/07 21:36:14 tom Exp $
3 ##############################################################################
4 # Copyright 2018-2020,2021 Thomas E. Dickey                                  #
5 # Copyright 2006-2015,2017 Free Software Foundation, Inc.                    #
6 #                                                                            #
7 # Permission is hereby granted, free of charge, to any person obtaining a    #
8 # copy of this software and associated documentation files (the "Software"), #
9 # to deal in the Software without restriction, including without limitation  #
10 # the rights to use, copy, modify, merge, publish, distribute, distribute    #
11 # with modifications, sublicense, and/or sell copies of the Software, and to #
12 # permit persons to whom the Software is furnished to do so, subject to the  #
13 # following conditions:                                                      #
14 #                                                                            #
15 # The above copyright notice and this permission notice shall be included in #
16 # all copies or substantial portions of the Software.                        #
17 #                                                                            #
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
19 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
20 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
21 # THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
22 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
23 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
24 # DEALINGS IN THE SOFTWARE.                                                  #
25 #                                                                            #
26 # Except as contained in this notice, the name(s) of the above copyright     #
27 # holders shall not be used in advertising or otherwise to promote the sale, #
28 # use or other dealings in this Software without prior written               #
29 # authorization.                                                             #
30 ##############################################################################
31 #
32 # Author: Thomas E. Dickey, 2006-on
33
34 LANG=C;         export LANG
35 LANGUAGE=C;     export LANGUAGE
36 LC_ALL=C;       export LC_ALL
37 LC_CTYPE=C;     export LC_CTYPE
38
39 prefix="@prefix@"
40 exec_prefix="@exec_prefix@"
41
42 bindir="@bindir@"
43 includedir="@includedir@"
44 libdir="@libdir@"
45 datarootdir="@datarootdir@"
46 datadir="@datadir@"
47 mandir="@mandir@"
48
49 THIS="@LIB_NAME@@USE_LIB_SUFFIX@"
50 TINFO_LIB="@TINFO_ARG_SUFFIX@"
51 RPATH_LIST="@RPATH_LIST@"
52
53 includesubdir="@includedir@/${THIS}"
54
55 # Ensure that RPATH_LIST contains only absolute pathnames, if it is nonempty.
56 # We cannot filter it out within the build-process since the variable is used
57 # in some special cases of installation using a relative path.
58 if [ -n "$RPATH_LIST" ]
59 then
60         save_IFS="$IFS"
61         IFS='@PATH_SEPARATOR@'
62         filtered=
63         for item in $RPATH_LIST
64         do
65                 case "$item" in
66                 ./*|../*|*/..|*/../*)
67                         ;;
68                 *)
69                         [ -n "$filtered" ] && filtered="${filtered}@PATH_SEPARATOR@"
70                         filtered="${filtered}${item}"
71                         ;;
72                 esac
73         done
74         IFS="$save_IFS"
75         # if the result is empty, there is little we can do to fix it
76         RPATH_LIST="$filtered"
77 fi
78
79 # with --disable-overwrite, we installed into a subdirectory, but transformed
80 # the headers to include like this:
81 #       <ncurses@LIB_SUFFIX@/curses.h>
82 if [ x@WITH_OVERWRITE@ = xno ]; then
83         case $includedir in
84         $prefix/include/ncurses@LIB_SUFFIX@@EXTRA_SUFFIX@)
85                 includedir=`echo "$includedir" | sed -e 's,/[^/]*$,,'`
86                 ;;
87         esac
88 fi
89
90 LIBS="@LIBS@"
91 if [ "@TINFO_NAME@" = "@LIB_NAME@" ]; then
92         LIBS="-l${THIS} $LIBS"
93 else
94         LIBS="-l${THIS} -l${TINFO_LIB} $LIBS"
95 fi
96
97 # Ignore -L options which do not correspond to an actual directory, or which
98 # are standard library directories (i.e., the linker is supposed to search
99 # those directories).
100 #
101 # There is no portable way to find the list of standard library directories.
102 # Require a POSIX shell anyway, to keep this simple.
103 lib_flags=
104 for opt in -L$libdir @EXTRA_PKG_LDFLAGS@ $LIBS
105 do
106         case $opt in
107         -specs*) # ignore linker specs-files which were used to build library
108                 continue
109                 ;;
110         -Wl,-z,*) # ignore flags used to manipulate shared image
111                 continue
112                 ;;
113         -Wl,--dynamic-linker*) # ignore ELF interpreter
114                 continue
115                 ;;
116         -L*)
117                 lib_check=`echo "x$opt" | sed -e 's/^.-L//'`
118                 [ -d "$lib_check" ] || continue
119                 case "$lib_check" in
120                 @LD_SEARCHPATH@) # skip standard libdir
121                         if [ "$lib_check" = "$libdir" ]
122                         then
123                                 lib_first=yes
124                                 IFS_save="$IFS"
125                                 IFS='|'
126                                 LIBDIRS="@LD_SEARCHPATH@"
127                                 for lib_check in $LIBDIRS
128                                 do
129                                         if [ -d "$lib_check" ]
130                                         then
131                                                 if [ "$lib_check" != "$libdir" ]
132                                                 then
133                                                         lib_first=no
134                                                 fi
135                                                 break
136                                         fi
137                                 done
138                                 IFS="$IFS_save"
139                                 [ $lib_first = yes ] && continue
140                                 found=no
141                                 for check in $lib_flags
142                                 do
143                                         if [ "x$check" = "x$opt" ]
144                                         then
145                                                 found=yes
146                                                 break
147                                         fi
148                                 done
149                                 [ $found = yes ] && continue
150                                 :
151                         else
152                                 continue
153                         fi
154                         ;;
155                 *)
156                         found=no
157                         for check in $lib_flags
158                         do
159                                 if [ "x$check" = "x$opt" ]
160                                 then
161                                         found=yes
162                                         break
163                                 fi
164                         done
165                         [ $found = yes ] && continue
166                         ;;
167                 esac
168                 ;;
169         esac
170         lib_flags="$lib_flags $opt"
171 done
172
173 [ $# = 0 ] && exec @SHELL@ $0 --error
174
175 while [ $# -gt 0 ]; do
176         case "$1" in
177         # basic configuration
178         --prefix)
179                 echo "$prefix"
180                 ;;
181         --exec-prefix)
182                 echo "$exec_prefix"
183                 ;;
184         # compile/link
185         --cflags)
186                 INCS="@PKG_CFLAGS@"
187                 if [ "x@WITH_OVERWRITE@" = xno ]; then
188                         INCS="$INCS -I${includesubdir}"
189                 fi
190                 if [ "${includedir}" != /usr/include ]; then
191                         INCS="$INCS -I${includedir}"
192                 fi
193                 sed -e 's,^[ ]*,,' -e 's, [ ]*, ,g' -e 's,[ ]*$,,' <<-ENDECHO
194                         $INCS
195 ENDECHO
196                 ;;
197         --libs)
198                 OPTS=
199                 for opt in $lib_flags
200                 do
201                         [ -n "$OPTS" ] && OPTS="$OPTS "
202                         OPTS="${OPTS}${opt}"
203                 done
204                 printf "%s\n" "$OPTS"
205                 ;;
206         --libs-only-L)
207                 OPTS=
208                 for opt in $lib_flags
209                 do
210                         case "x$opt" in
211                         x-L*)
212                                 [ -n "$OPTS" ] && OPTS="$OPTS "
213                                 OPTS="${OPTS}${opt}"
214                                 ;;
215                         esac
216                 done
217                 printf "%s\n" "$OPTS"
218                 ;;
219         --libs-only-l)
220                 OPTS=
221                 for opt in $lib_flags
222                 do
223                         case "x$opt" in
224                         x-l*)
225                                 [ -n "$OPTS" ] && OPTS="$OPTS "
226                                 OPTS="${OPTS}${opt}"
227                                 ;;
228                         esac
229                 done
230                 printf "%s\n" "$OPTS"
231                 ;;
232         --libs-only-other)
233                 OPTS=
234                 for opt in $lib_flags
235                 do
236                         case "x$opt" in
237                         x-[lL]*)
238                                 ;;
239                         *)
240                                 [ -n "$OPTS" ] && OPTS="$OPTS "
241                                 OPTS="${OPTS}${opt}"
242                                 ;;
243                         esac
244                 done
245                 printf "%s\n" "$OPTS"
246                 ;;
247         # identification
248         --version)
249                 echo "@NCURSES_MAJOR@.@NCURSES_MINOR@.@NCURSES_PATCH@"
250                 ;;
251         --abi-version)
252                 echo "@cf_cv_abi_version@"
253                 ;;
254         --mouse-version)
255                 echo "@NCURSES_MOUSE_VERSION@"
256                 ;;
257         # locations
258         --bindir)
259                 echo "${bindir}"
260                 ;;
261         --datadir)
262                 echo "${datadir}"
263                 ;;
264         --includedir)
265                 INCS=
266                 if [ "x@WITH_OVERWRITE@" = xno ]; then
267                         INCS="${includesubdir}"
268                 elif [ "${includedir}" != /usr/include ]; then
269                         INCS="${includedir}"
270                 fi
271                 echo $INCS
272                 ;;
273         --libdir)
274                 echo "${libdir}"
275                 ;;
276         --mandir)
277                 echo "${mandir}"
278                 ;;
279         --terminfo)
280                 echo "@TERMINFO@"
281                 ;;
282         --terminfo-dirs)
283                 echo "@TERMINFO_DIRS@"
284                 ;;
285         --termpath)
286                 echo "@TERMPATH@"
287                 ;;
288         # general info
289         --help)
290                 cat <<ENDHELP
291 Usage: `basename $0` [options]
292
293 Options:
294   --prefix           echos the package-prefix of ${THIS}
295   --exec-prefix      echos the executable-prefix of ${THIS}
296
297   --cflags           echos the C compiler flags needed to compile with ${THIS}
298   --libs             echos the libraries needed to link with ${THIS}
299
300   --libs-only-L      echos -L linker options (search path) for ${THIS}
301   --libs-only-l      echos -l linker options (libraries) for ${THIS}
302   --libs-only-other  echos linker options other than -L/-l
303
304   --version          echos the release+patchdate version of ${THIS}
305   --abi-version      echos the ABI version of ${THIS}
306   --mouse-version    echos the mouse-interface version of ${THIS}
307
308   --bindir           echos the directory containing ${THIS} programs
309   --datadir          echos the directory containing ${THIS} data
310   --includedir       echos the directory containing ${THIS} header files
311   --libdir           echos the directory containing ${THIS} libraries
312   --mandir           echos the directory containing ${THIS} manpages
313   --terminfo         echos the \$TERMINFO terminfo database path
314   --terminfo-dirs    echos the \$TERMINFO_DIRS directory list
315   --termpath         echos the \$TERMPATH termcap list
316
317   --help             prints this message
318 ENDHELP
319                 ;;
320         --error|*)
321                 @SHELL@ $0 --help 1>&2
322                 exit 1
323                 ;;
324         esac
325         shift
326 done
327 # vi:ts=4 sw=4
328 # vile:shmode