]> ncurses.scripts.mit.edu Git - ncurses.git/blob - misc/ncurses-config.in
b17f68428d5056852f7c011b0d88f9dce2ce8dde
[ncurses.git] / misc / ncurses-config.in
1 #!@SHELL@
2 # $Id: ncurses-config.in,v 1.53 2024/06/22 20:52:02 tom Exp $
3 ##############################################################################
4 # Copyright 2018-2022,2024 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                 OPTS=
190                 for opt in @PKG_CFLAGS@
191                 do
192                         case "x$opt" in
193                         x-[DIU]*)
194                                 OPTS="$OPTS $opt"
195                                 ;;
196                         x-Wl,*)
197                                 OPTS="$OPTS $opt"
198                                 ;;
199                         x-[OW]*)
200                                 ;;
201                         *)
202                                 OPTS="$OPTS $opt"
203                                 ;;
204                         esac
205                 done
206                 printf "%s\n" "$OPTS"
207                 ;;
208         --cflags-only-I)
209                 OPTS=
210                 for opt in @PKG_CFLAGS@
211                 do
212                         case "x$opt" in
213                         x-[DIU]*)
214                                 OPTS="$OPTS $opt"
215                                 ;;
216                         *)
217                                 ;;
218                         esac
219                 done
220                 printf "%s\n" "$OPTS"
221                 ;;
222         --cflags-only-other)
223                 OPTS=
224                 for opt in @PKG_CFLAGS@
225                 do
226                         case "x$opt" in
227                         x-[DIU]*)
228                                 ;;
229                         x-Wl,*)
230                                 OPTS="$OPTS $opt"
231                                 ;;
232                         x-[OW]*)
233                                 ;;
234                         *)
235                                 OPTS="$OPTS $opt"
236                                 ;;
237                         esac
238                 done
239                 printf "%s\n" "$OPTS"
240                 ;;
241         --libs)
242                 OPTS=
243                 for opt in $lib_flags
244                 do
245                         [ -n "$OPTS" ] && OPTS="$OPTS "
246                         OPTS="${OPTS}${opt}"
247                 done
248                 printf '%s\n' "$OPTS"
249                 ;;
250         --libs-only-L)
251                 OPTS=
252                 for opt in $lib_flags
253                 do
254                         case "x$opt" in
255                         x-L*)
256                                 [ -n "$OPTS" ] && OPTS="$OPTS "
257                                 OPTS="${OPTS}${opt}"
258                                 ;;
259                         esac
260                 done
261                 printf '%s\n' "$OPTS"
262                 ;;
263         --libs-only-l)
264                 OPTS=
265                 for opt in $lib_flags
266                 do
267                         case "x$opt" in
268                         x-l*)
269                                 [ -n "$OPTS" ] && OPTS="$OPTS "
270                                 OPTS="${OPTS}${opt}"
271                                 ;;
272                         esac
273                 done
274                 printf '%s\n' "$OPTS"
275                 ;;
276         --libs-only-other)
277                 OPTS=
278                 for opt in $lib_flags
279                 do
280                         case "x$opt" in
281                         x-[lL]*)
282                                 ;;
283                         *)
284                                 [ -n "$OPTS" ] && OPTS="$OPTS "
285                                 OPTS="${OPTS}${opt}"
286                                 ;;
287                         esac
288                 done
289                 printf '%s\n' "$OPTS"
290                 ;;
291         # identification
292         --version)
293                 echo "@NCURSES_MAJOR@.@NCURSES_MINOR@.@NCURSES_PATCH@"
294                 ;;
295         --abi-version)
296                 echo "@cf_cv_abi_version@"
297                 ;;
298         --mouse-version)
299                 echo "@NCURSES_MOUSE_VERSION@"
300                 ;;
301         # locations
302         --bindir)
303                 echo "${bindir}"
304                 ;;
305         --datadir)
306                 echo "${datadir}"
307                 ;;
308         --includedir)
309                 INCS=
310                 if [ "x@WITH_OVERWRITE@" = xno ]; then
311                         INCS="${includesubdir}"
312                 elif [ "${includedir}" != /usr/include ]; then
313                         INCS="${includedir}"
314                 fi
315                 echo "$INCS"
316                 ;;
317         --libdir)
318                 echo "${libdir}"
319                 ;;
320         --mandir)
321                 echo "${mandir}"
322                 ;;
323         --terminfo)
324                 echo "@TERMINFO@"
325                 ;;
326         --terminfo-dirs)
327                 echo "@TERMINFO_DIRS@"
328                 ;;
329         --termpath)
330                 echo "@TERMPATH@"
331                 ;;
332         # general info
333         --help)
334                 cat <<ENDHELP
335 Usage: `basename "$0"` [options]
336
337 Options:
338   --prefix            echos the package-prefix of ${THIS}
339   --exec-prefix       echos the executable-prefix of ${THIS}
340
341   --cflags            echos the C compiler flags needed to compile for ${THIS}
342   --cflags-only-I     echos only -I C compiler flags needed with ${THIS}
343   --cflags-only-other echos only C compiler flags other than -I for ${THIS}
344   --libs              echos the libraries needed to link with ${THIS}
345
346   --libs-only-L       echos -L linker options (search path) for ${THIS}
347   --libs-only-l       echos -l linker options (libraries) for ${THIS}
348   --libs-only-other   echos linker options other than -L/-l
349
350   --version           echos the release+patchdate version of ${THIS}
351   --abi-version       echos the ABI version of ${THIS}
352   --mouse-version     echos the mouse-interface version of ${THIS}
353
354   --bindir            echos the directory containing ${THIS} programs
355   --datadir           echos the directory containing ${THIS} data
356   --includedir        echos the directory containing ${THIS} header files
357   --libdir            echos the directory containing ${THIS} libraries
358   --mandir            echos the directory containing ${THIS} manpages
359   --terminfo          echos the \$TERMINFO terminfo database path
360   --terminfo-dirs     echos the \$TERMINFO_DIRS directory list
361   --termpath          echos the \$TERMPATH termcap list
362
363   --help              prints this message
364 ENDHELP
365                 ;;
366         --error|*)
367                 @SHELL@ "$0" --help 1>&2
368                 exit 1
369                 ;;
370         esac
371         shift
372 done
373 # vi:ts=4 sw=4
374 # vile:shmode