]> ncurses.scripts.mit.edu Git - ncurses.git/blob - misc/ncurses-config.in
ncurses 6.4 - patch 20240420
[ncurses.git] / misc / ncurses-config.in
1 #!@SHELL@
2 # $Id: ncurses-config.in,v 1.52 2022/07/26 21:36:28 tom Exp $
3 ##############################################################################
4 # Copyright 2018-2021,2022 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         -Wl,--as-needed|-Wl,--build-id=*|-Wl,-dT,*|-Wl,-T,*)
117                 continue
118                 ;;
119         -L*)
120                 lib_check=`echo "x$opt" | sed -e 's/^.-L//'`
121                 [ -d "$lib_check" ] || continue
122                 case "$lib_check" in
123                 @LD_SEARCHPATH@) # skip standard libdir
124                         if [ "$lib_check" = "$libdir" ]
125                         then
126                                 lib_first=yes
127                                 IFS_save="$IFS"
128                                 IFS='|'
129                                 LIBDIRS="@LD_SEARCHPATH@"
130                                 for lib_check in $LIBDIRS
131                                 do
132                                         if [ -d "$lib_check" ]
133                                         then
134                                                 if [ "$lib_check" != "$libdir" ]
135                                                 then
136                                                         lib_first=no
137                                                 fi
138                                                 break
139                                         fi
140                                 done
141                                 IFS="$IFS_save"
142                                 [ $lib_first = yes ] && continue
143                                 found=no
144                                 for check in $lib_flags
145                                 do
146                                         if [ "x$check" = "x$opt" ]
147                                         then
148                                                 found=yes
149                                                 break
150                                         fi
151                                 done
152                                 [ $found = yes ] && continue
153                                 :
154                         else
155                                 continue
156                         fi
157                         ;;
158                 *)
159                         found=no
160                         for check in $lib_flags
161                         do
162                                 if [ "x$check" = "x$opt" ]
163                                 then
164                                         found=yes
165                                         break
166                                 fi
167                         done
168                         [ $found = yes ] && continue
169                         ;;
170                 esac
171                 ;;
172         esac
173         lib_flags="$lib_flags $opt"
174 done
175
176 [ $# = 0 ] && exec @SHELL@ "$0" --error
177
178 while [ $# -gt 0 ]; do
179         case "$1" in
180         # basic configuration
181         --prefix)
182                 echo "$prefix"
183                 ;;
184         --exec-prefix)
185                 echo "$exec_prefix"
186                 ;;
187         # compile/link
188         --cflags)
189                 INCS="@PKG_CFLAGS@"
190                 if [ "x@WITH_OVERWRITE@" = xno ]; then
191                         INCS="$INCS -I${includesubdir}"
192                 fi
193                 if [ "${includedir}" != /usr/include ]; then
194                         INCS="$INCS -I${includedir}"
195                 fi
196                 sed -e 's,^[ ]*,,' -e 's, [ ]*, ,g' -e 's,[ ]*$,,' <<-ENDECHO
197                         $INCS
198 ENDECHO
199                 ;;
200         --libs)
201                 OPTS=
202                 for opt in $lib_flags
203                 do
204                         [ -n "$OPTS" ] && OPTS="$OPTS "
205                         OPTS="${OPTS}${opt}"
206                 done
207                 printf '%s\n' "$OPTS"
208                 ;;
209         --libs-only-L)
210                 OPTS=
211                 for opt in $lib_flags
212                 do
213                         case "x$opt" in
214                         x-L*)
215                                 [ -n "$OPTS" ] && OPTS="$OPTS "
216                                 OPTS="${OPTS}${opt}"
217                                 ;;
218                         esac
219                 done
220                 printf '%s\n' "$OPTS"
221                 ;;
222         --libs-only-l)
223                 OPTS=
224                 for opt in $lib_flags
225                 do
226                         case "x$opt" in
227                         x-l*)
228                                 [ -n "$OPTS" ] && OPTS="$OPTS "
229                                 OPTS="${OPTS}${opt}"
230                                 ;;
231                         esac
232                 done
233                 printf '%s\n' "$OPTS"
234                 ;;
235         --libs-only-other)
236                 OPTS=
237                 for opt in $lib_flags
238                 do
239                         case "x$opt" in
240                         x-[lL]*)
241                                 ;;
242                         *)
243                                 [ -n "$OPTS" ] && OPTS="$OPTS "
244                                 OPTS="${OPTS}${opt}"
245                                 ;;
246                         esac
247                 done
248                 printf '%s\n' "$OPTS"
249                 ;;
250         # identification
251         --version)
252                 echo "@NCURSES_MAJOR@.@NCURSES_MINOR@.@NCURSES_PATCH@"
253                 ;;
254         --abi-version)
255                 echo "@cf_cv_abi_version@"
256                 ;;
257         --mouse-version)
258                 echo "@NCURSES_MOUSE_VERSION@"
259                 ;;
260         # locations
261         --bindir)
262                 echo "${bindir}"
263                 ;;
264         --datadir)
265                 echo "${datadir}"
266                 ;;
267         --includedir)
268                 INCS=
269                 if [ "x@WITH_OVERWRITE@" = xno ]; then
270                         INCS="${includesubdir}"
271                 elif [ "${includedir}" != /usr/include ]; then
272                         INCS="${includedir}"
273                 fi
274                 echo "$INCS"
275                 ;;
276         --libdir)
277                 echo "${libdir}"
278                 ;;
279         --mandir)
280                 echo "${mandir}"
281                 ;;
282         --terminfo)
283                 echo "@TERMINFO@"
284                 ;;
285         --terminfo-dirs)
286                 echo "@TERMINFO_DIRS@"
287                 ;;
288         --termpath)
289                 echo "@TERMPATH@"
290                 ;;
291         # general info
292         --help)
293                 cat <<ENDHELP
294 Usage: `basename "$0"` [options]
295
296 Options:
297   --prefix           echos the package-prefix of ${THIS}
298   --exec-prefix      echos the executable-prefix of ${THIS}
299
300   --cflags           echos the C compiler flags needed to compile with ${THIS}
301   --libs             echos the libraries needed to link with ${THIS}
302
303   --libs-only-L      echos -L linker options (search path) for ${THIS}
304   --libs-only-l      echos -l linker options (libraries) for ${THIS}
305   --libs-only-other  echos linker options other than -L/-l
306
307   --version          echos the release+patchdate version of ${THIS}
308   --abi-version      echos the ABI version of ${THIS}
309   --mouse-version    echos the mouse-interface version of ${THIS}
310
311   --bindir           echos the directory containing ${THIS} programs
312   --datadir          echos the directory containing ${THIS} data
313   --includedir       echos the directory containing ${THIS} header files
314   --libdir           echos the directory containing ${THIS} libraries
315   --mandir           echos the directory containing ${THIS} manpages
316   --terminfo         echos the \$TERMINFO terminfo database path
317   --terminfo-dirs    echos the \$TERMINFO_DIRS directory list
318   --termpath         echos the \$TERMPATH termcap list
319
320   --help             prints this message
321 ENDHELP
322                 ;;
323         --error|*)
324                 @SHELL@ "$0" --help 1>&2
325                 exit 1
326                 ;;
327         esac
328         shift
329 done
330 # vi:ts=4 sw=4
331 # vile:shmode