blob: 62d09ff61905b8ccfee6443dcd37efdb354065f0 [file] [log] [blame]
Steve Kondikae271bc2015-11-15 02:50:53 +01001#!@SHELL@
2# $Id: gen-pkgconfig.in,v 1.29 2015/07/04 20:37:01 tom Exp $
3##############################################################################
4# Copyright (c) 2009-2014,2015 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.
40LIB_NAME=@LIB_NAME@
41TINFO_NAME=@TINFO_NAME@
42PANEL_NAME=@PANEL_NAME@
43MENU_NAME=@MENU_NAME@
44FORM_NAME=@FORM_NAME@
45CXX_NAME=@CXX_NAME@
46DFT_DEP_SUFFIX=@DFT_DEP_SUFFIX@
47TINFO_ARG_SUFFIX=@TINFO_ARG_SUFFIX@
48CXX_LIB_SUFFIX=@CXX_LIB_SUFFIX@
49
50suffix=@PC_MODULE_SUFFIX@
51prefix="@prefix@"
52exec_prefix="@exec_prefix@"
53includedir="@includedir@@includesubdir@"
54libdir="@libdir@"
55
56show_prefix='@prefix@'
57show_exec_prefix='@exec_prefix@'
58show_includedir='@includedir@@includesubdir@'
59show_libdir='@libdir@'
60
61MAIN_LIBRARY="${LIB_NAME}@USE_ARG_SUFFIX@"
62SUB_LIBRARY="${TINFO_ARG_SUFFIX}"
63PANEL_LIBRARY="${PANEL_NAME}@USE_ARG_SUFFIX@"
64MENU_LIBRARY="${MENU_NAME}@USE_ARG_SUFFIX@"
65FORM_LIBRARY="${FORM_NAME}@USE_ARG_SUFFIX@"
66
67CFLAGS="@PKG_CFLAGS@"
68if test "$includedir" != "/usr/include" ; then
69 includetop=`echo "$includedir" | sed -e 's,/include/[^/]*$,/include,'`
70 test "$includetop" = "/usr/include" && includetop="$includedir"
71 if test "x$includetop" != "x$includedir"
72 then
73 CFLAGS="$CFLAGS -I${includetop}"
74 fi
75 CFLAGS="$CFLAGS -I\${includedir}"
76fi
77
78LDFLAGS=
79if test "$libdir" != "/usr/lib" ; then
80 LDFLAGS="$LDFLAGS -L\${libdir}"
81fi
82if test "x@EXTRA_LDFLAGS@" != "x" ; then
83 LDFLAGS="$LDFLAGS @EXTRA_LDFLAGS@"
84fi
85
86# Check if we should specify the tinfo library explicitly so that terminfo
87# functions or curses variables (which also reside in tinfo) can be linked
88# using the -lncurses option.
89NEED_TINFO=no
90if test "x@TINFO_LIBS@" != "x" && \
91 test "x$TINFO_ARG_SUFFIX" != "x$MAIN_LIBRARY"
92then
93 case "x$LDFLAGS" in
94 (*--as-needed*)
95 NEED_TINFO=yes
96 ;;
97 esac
98 case "x$LDFLAGS" in
99 (*,-rpath,*)
100 ;;
101 (*)
102 NEED_TINFO=yes
103 ;;
104 esac
105fi
106
107for name in @PC_MODULES_TO_MAKE@
108do
109 name="${name}"
110 LIBS="-l$name"
111
112 desc="ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@"
113 reqs=
114
115 if test $name = $MAIN_LIBRARY ; then
116 desc="$desc library"
117 test $NEED_TINFO = yes && LIBS="$LIBS -l$TINFO_ARG_SUFFIX"
118 elif test $name = $SUB_LIBRARY ; then
119 desc="$desc terminal interface library"
120 elif expr $name : ".*${CXX_NAME}.*" >/dev/null ; then
121 reqs="$PANEL_LIBRARY${suffix}, $MENU_LIBRARY${suffix}, $FORM_LIBRARY${suffix}, $MAIN_LIBRARY${suffix}"
122 desc="$desc add-on library"
123 else
124 reqs="$MAIN_LIBRARY${suffix}"
125 desc="$desc add-on library"
126 fi
127
128 if test $name != $SUB_LIBRARY && \
129 test $SUB_LIBRARY != $MAIN_LIBRARY && \
130 test $name != $TINFO_NAME && \
131 test $NEED_TINFO != yes ; then
132 test -n "$reqs" && reqs="$reqs, "
133 reqs="${reqs}${SUB_LIBRARY}${suffix}"
134 fi
135
136 echo "** creating ${name}${suffix}.pc"
137 cat >${name}${suffix}.pc <<EOF
138# pkg-config file generated by `basename $0`
139# vile:makemode
140
141prefix=$show_prefix
142exec_prefix=$show_exec_prefix
143libdir=$show_libdir
144includedir=$show_includedir
145abi_version=@cf_cv_abi_version@
146major_version=@NCURSES_MAJOR@
147version=@NCURSES_MAJOR@.@NCURSES_MINOR@.@NCURSES_PATCH@
148
149Name: ${name}${suffix}
150Description: $desc
151Version: \${version}
152URL: http://invisible-island.net/ncurses
153Requires.private: $reqs
154Libs: $LDFLAGS $LIBS
155Libs.private: @LIBS@
156Cflags: $CFLAGS
157EOF
158
159done
160# vile:shmode