ecd8523ab66aa61b17eb349306f10e0b38cd9971
[ncurses.git] / misc / gen-pkgconfig.in
1 #!@SHELL@
2 # $Id: gen-pkgconfig.in,v 1.26 2015/05/02 15:50:27 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.
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 show_prefix='@prefix@'
57 show_exec_prefix='@exec_prefix@'
58 show_includedir='@includedir@@includesubdir@'
59 show_libdir='@libdir@'
60
61 MAIN_LIBRARY="${LIB_NAME}@USE_ARG_SUFFIX@"
62 SUB_LIBRARY="${TINFO_ARG_SUFFIX}"
63 PANEL_LIBRARY="${PANEL_NAME}@USE_ARG_SUFFIX@"
64 MENU_LIBRARY="${MENU_NAME}@USE_ARG_SUFFIX@"
65 FORM_LIBRARY="${FORM_NAME}@USE_ARG_SUFFIX@"
66
67 CFLAGS="@PKG_CFLAGS@"
68 if 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" != "$includedir"
72         then
73                 CFLAGS="$CFLAGS -I${includetop}"
74         fi
75         CFLAGS="$CFLAGS -I\${includedir}"
76 fi
77
78 LDFLAGS="@LDFLAGS@"
79 if test "$libdir" != "/usr/lib" ; then
80         LDFLAGS="$LDFLAGS -L\${libdir}"
81 fi
82 if test "x@EXTRA_LDFLAGS@" != "x" ; then
83         LDFLAGS="$LDFLAGS @EXTRA_LDFLAGS@"
84 fi
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.
89 NEED_TINFO=no
90 if test "x@TINFO_LIBS@" != "x"
91 then
92         case "x$LDFLAGS" in
93         (*--as-needed*)
94                 NEED_TINFO=yes
95                 ;;
96         esac
97         case "x$LDFLAGS" in
98         (*,-rpath,*)
99                 ;;
100         (*)
101                 NEED_TINFO=yes
102                 ;;
103         esac
104 fi
105
106 for name in @PC_MODULES_TO_MAKE@
107 do
108         name="${name}"
109         LIBS="-l$name"
110
111         desc="ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@"
112         reqs=
113
114         if test $name = $MAIN_LIBRARY ; then
115                 desc="$desc library"
116                 test $NEED_TINFO = yes && LIBS="$LIBS -l$TINFO_NAME"
117         elif test $name = $SUB_LIBRARY ; then
118                 desc="$desc terminal interface library"
119         elif expr $name : ".*${CXX_NAME}.*" >/dev/null ; then
120                 reqs="$PANEL_LIBRARY${suffix}, $MENU_LIBRARY${suffix}, $FORM_LIBRARY${suffix}, $MAIN_LIBRARY${suffix}"
121                 desc="$desc add-on library"
122         else
123                 reqs="$MAIN_LIBRARY${suffix}"
124                 desc="$desc add-on library"
125         fi
126
127         if test $name != $SUB_LIBRARY && \
128            test $SUB_LIBRARY != $MAIN_LIBRARY && \
129            test $name != $TINFO_NAME && \
130            test $NEED_TINFO != yes ; then
131                 test -n "$reqs" && reqs="$reqs, "
132                 reqs="${reqs}${SUB_LIBRARY}${suffix}"
133         fi
134
135         echo "** creating ${name}${suffix}.pc"
136         cat >${name}${suffix}.pc <<EOF
137 # pkg-config file generated by `basename $0`
138 # vile:makemode
139
140 prefix=$show_prefix
141 exec_prefix=$show_exec_prefix
142 libdir=$show_libdir
143 includedir=$show_includedir
144 abi_version=@cf_cv_abi_version@
145 major_version=@NCURSES_MAJOR@
146 version=@NCURSES_MAJOR@.@NCURSES_MINOR@.@NCURSES_PATCH@
147
148 Name: ${name}${suffix}
149 Description: $desc
150 Version: \${version}
151 URL: http://invisible-island.net/ncurses
152 Requires.private: $reqs
153 Libs: $LDFLAGS $LIBS
154 Libs.private: @LIBS@
155 Cflags: $CFLAGS
156 EOF
157
158 done
159 # vile:shmode