Bump version to 0.36.9
[cygport.git] / cygclass / autotools.cygclass
blob55be670909b8fc2862509e5d144b0f2b898cda33
1 ################################################################################
3 # autotools.cygclass - functions for building autotool-based packages
5 # Part of cygport - Cygwin packaging application
6 # Copyright (C) 2006-2020 Cygport authors
7 # Provided by the Cygwin project <https://cygwin.com/>
9 # cygport is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
14 # cygport is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with cygport.  If not, see <https://www.gnu.org/licenses/>.
22 ################################################################################
24 #****h* Cygclasses/autotools.cygclass
25 #  DESCRIPTION
26 #  GNU Autotools (comprising of Gettext, Autoconf, Automake, and Libtool)
27 #  comprise the build system of many source packages of all types.
29 #  This Cygclass provides the functions necessary to configure and build
30 #  autotool-based packages.  Since these are so widespread, this is the
31 #  assumed build system if no other is specified, and provides the default
32 #  src_compile accordingly.
33 #  EXAMPLES
34 #  A basic autotool-based program package can be as simple as:
36 #    NAME="grep"
37 #    VERSION=2.14
38 #    RELEASE=1
39 #    CATEGORY="Base"
40 #    SUMMARY="Searches files for text patterns"
41 #    DESCRIPTION="The grep command searches one or more input files for lines
42 #    containing a match to a specified pattern. By default, grep prints the
43 #    matching lines."
44 #    HOMEPAGE="https://www.gnu.org/software/grep/"
45 #    LICENSE="GPL-2.0-or-later"
46 #    SRC_URI="mirror://gnu/grep/grep-${VERSION}.tar.xz"
48 #  If the only customization needed is to add configure flags, use CYGCONF_ARGS:
50 #    NAME="nano"
51 #    VERSION=2.2.6
52 #    RELEASE=1
53 #    CATEGORY="Editors"
54 #    SUMMARY="Enhanced clone of Pico editor"
55 #    DESCRIPTION="GNU nano is a small and friendly console-mode text editor, based
56 #    on and mostly compatible with UW Pico. Besides basic text editing, nano offers
57 #    many extra features like an interactive search and replace, go to line and
58 #    column number, auto-indentation, feature toggles, internationalization support,
59 #    and filename tab completion."
60 #    HOMEPAGE="https://www.nano-editor.org/"
61 #    LICENSE="GPL-3.0-or-later"
62 #    SRC_URI="https://www.nano-editor.org/dist/v${VERSION%.*}/nano-${VERSION}.tar.gz"
63 #    PATCH_URI="2.2.4-wchar.patch"
64 #    
65 #    DIFF_EXCLUDES="nano.spec"
66 #    
67 #    CYGCONF_ARGS="--without-slang"
69 #  Packages providing libraries need a bit more to handle split lib/devel
70 #  packaging:
72 #    NAME="libdatrie"
73 #    VERSION=0.2.6
74 #    RELEASE=1
75 #    CATEGORY="Libs"
76 #    SUMMARY="Double-array digital search tree library"
77 #    DESCRIPTION="This is an implementation of double-array structure for
78 #    representing trie, as proposed by Junichi Aoe."
79 #    HOMEPAGE="https://linux.thai.net/~thep/datrie/datrie.html"
80 #    LICENSE="LGPL"
81 #    
82 #    PKG_NAMES="${NAME}1 ${NAME}-devel ${NAME}-doc"
83 #    # see PKG_CONTENTS
84 #    libdatrie1_CONTENTS="usr/bin/cygdatrie-1.dll"
85 #    # trietool is a dev-util
86 #    libdatrie_devel_CONTENTS="usr/bin/trietool* usr/include/ usr/lib/ usr/share/man/"
87 #    libdatrie_doc_CONTENTS="usr/share/doc/"
89 #  Sometimes a package uses its own aclocal macros but does not ship them,
90 #  or uses an older autoconf which is incompatible with the current version,
91 #  making cygautoreconf impossible.  In that case, as long as the package does
92 #  not use libtool, you may be able to skip cygautoreconf:
94 #    src_compile() {
95 #      # cannot autoreconf: undefined macro: AC_ACVERSION
96 #      cd ${B}
97 #      cygconf --enable-iconv
98 #      cygmake
99 #    }
101 #  For more complicated packages, additional compile and/or install steps
102 #  may be necessary, in which case you should override the default src_compile
103 #  and/or src_install:
105 #    src_compile() {
106 #      # the configure script is not distributed, and VPATH builds aren't supported
107 #      cd ${S}
108 #      cygmake configure
109 #      lndirs
110 #      cd ${B}
111 #      cygconf --htmldir=/usr/share/doc/${NAME}/html --mandir=/usr/share/man
112 #      cygmake all
113 #      # these can't be built in parallel
114 #      cygmake html
115 #      cygmake man
116 #      cygmake info
117 #      cygmake pdf
118 #    }
119 #    
120 #    src_install() {
121 #      cd ${B}
122 #      cyginstall install-html install-man install-info install-pdf pdfdir=/usr/share/doc/${NAME}
123 #    
124 #      # ship bash completion
125 #      insinto /etc/bash_completion.d
126 #      doins ${S}/contrib/completion/*.bash
127 #    }
129 #  As noted below, cygconf is only intended for autoconf-compatible configure
130 #  scripts.  Some packages use a custom configure script which is not compatible,
131 #  in which case you need to call configure yourself:
133 #    src_compile() {
134 #      # package is not VPATH aware
135 #      lndirs
136 #      cd ${B}
137 #      # custom configure incompatible with autoconf
138 #      ./configure --prefix=/usr || error "configure failed"
139 #      cygmake
140 #   }
142 #  NOTES
143 #  These functions were previously part of cygport itself, but were moved
144 #  out for easier maintainability.  For backwards compatibility, this
145 #  cygclass is automatically inherit()ed, so these functions are always
146 #  available as before.
148 #  Normally, a cygclass can only be inherited once.  Even though this
149 #  is auto-inherit()ed, it can still be manually inherit()ed once more if desired.
150 #  In most cases this is unnecessary, but it can be useful if you inherit
151 #  other cygclasses but still want the default src_compile().  For example:
152 #    inherit perl autotools
153 #  provides all the PERL_* definitions and perl_*() functions, but will build
154 #  with cygconf/cygmake by default instead of with perl's ExtUtils::MakeMaker
155 #  or Module::Build.
156 #  INHERITED BY
157 #  No Cygclass actually inherit()s autotools.cygclass for the reasons stated above,
158 #  but the functions defined herein are used by a number of Cygclasses:
160 #  gnome2.cygclass, gst-plugins.cygclass, gtkmm.cygclass, httpd.cygclass,
161 #  kde3.cygclass, mate.cygclass, php.cygclass, pygtk.cygclass, toolchain.cygclass,
162 #  xfce4.cygclass, xorg.cygclass
163 #****
165 # utility function used in cygautoreconf, gnome2_autoreconf, mate_autoreconf
166 __parse_aclocal_amflags() {
167         local arg;
169         for arg in $@
170         do
171                 case $1 in
172                 -I) echo $2 ;;
173                 esac
174                 shift
175         done
179 #****C* autotools.cygclass/gnuconfigize
180 #  SYNOPSIS
181 #  gnuconfigize DIRECTORY [DIRECTORY ...]
182 #  DESCRIPTION
183 #  Updates the config.guess and config.sub files in the given directory(ies).
184 #  This may be necessary when building packages natively for x86_64-cygwin,
185 #  which is not recognized by older versions of this file.
186 #  NOTE
187 #  This function is called automatically during cygautoreconf; it need only
188 #  be called directly for packages which install their copies of this file
189 #  (e.g. the autotools themselves) or in the unusual case where cygautoreconf
190 #  absolutely cannot be used.
191 #****
193 gnuconfigize() {
194         (( $# >= 1 )) || error "gnuconfigize: no destinations specified"
196         for d in $@
197         do
198                 [ -f $d/config.guess ] || error "gnuconfigize: $d: not a gnuconfig directory"
199                 cp -f ${_privgnuconfigdir}/config.{guess,sub} $d/
200         done
203 #****C* autotools.cygclass/cygautoreconf
204 #  SYNOPSIS
205 #  cygautoreconf
206 #  DESCRIPTION
207 #  Updates the autotool build system with autoreconf, which runs the tools
208 #  from autoconf, automake, gettext-devel, and libtool to update their
209 #  respective components.  Must be run in the directory containing the top-level
210 #  configure.ac or configure.in (usually $S).
211 #  NOTE
212 #  If, during cygautoreconf, you get a warning such as:
213 #     Warning: ./configure.ac may require LT_OUTPUT macro
214 #  then the package configure script is relying on libtool 1.5 behaviour where
215 #  the libtool script is generated during AC_PROG_LIBTOOL, and can therefore
216 #  be called anytime thereafter in the configure script.  Some packages do this
217 #  either to read the libtool config, or to run compiling/linking tests with
218 #  the libtool script.
220 #  However, with the current libtool 2.2, the libtool script is generated during
221 #  the AC_OUTPUT phase at the end of configure, so these configure commands will
222 #  not work as designed.  The simplest portable solution is to add the
223 #  following line after the AC_PROG_LIBTOOL call:
224 #    m4_ifdef([LT_OUTPUT], [LT_OUTPUT])
225 #  which means: if libtool 2.2 is in use, generate a libtool script early so
226 #  that it can be used during configure; if libtool 1.5 is in use, this line has
227 #  no effect.  Such a patch is suitable to be pushed upstream.
228 #  WARNING
229 #  Skipping this step is strongly discouraged.  Patches to configure.ac, aclocal
230 #  macros, or Makefile.am files will not take effect until their tools have been
231 #  regenerated.  Also, Cygwin's libtool package often includes patches which
232 #  are not yet available in the latest upstream release, so libraries may not
233 #  be built optimally, or even correctly, without this step having been run.
234 #  REQUIRES
235 #  autoconf, automake, gettext-devel, libtool
236 #****
237 cygautoreconf() {
238         local d;
239         local f;
240         local f_in;
241         local tool;
242         local ac_config_files;
243         local ac_config_headers;
244         local ac_subdirs;
245         local ac_ver;
246         local autoreconf_args;
247         local auxdir;
248         local configure_ac;
249         local config_h;
250         local config_h_in;
251         local gettext_version;
252         local sub_configure_ac;
254         if [ -f configure.ac ]
255         then
256                 configure_ac="configure.ac";
257         elif [ -f configure.in ]
258         then
259                 configure_ac="configure.in";
260         else
261                 error "Could not find configure.ac or configure.in";
262         fi
264         __config_set with_autoconf 1
266         ac_subdirs="$(grep '^[^\#]*AC_CONFIG_SUBDIRS*' ${configure_ac} | sed -e 's!.*AC_CONFIG_SUBDIRS*(\[*\(.*\))!\1!g' -e 's!\]*!!g')"
268         for d in . ${ac_subdirs}
269         do
270                 if [ -d ${d} ]
271                 then
272                         if [ -f ${d}/configure.ac ]
273                         then
274                                 sub_configure_ac="${d}/configure.ac";
275                         elif [ -f ${d}/configure.in ]
276                         then
277                                 sub_configure_ac="${d}/configure.in";
278                         else
279                                 error "Could not find ${d}/configure.ac or ${d}/configure.in";
280                         fi
282                         # e.g. CVS checkouts
283                         if [ -f ${d}/configure ]
284                         then
285                                 # Assure that autotool files are writable (e.g. less)
286                                 eval $(grep -h '^ac_config_files=' ${d}/configure)
287                                 # eval $(grep -h '^ac_config_headers=' ${d}/configure)
289                                 chmod +wx ${d}/configure;
291                                 for f in ${ac_config_files} ${ac_config_headers}
292                                 do
293                                         case ${f} in
294                                                 *:*)    f_in=${d}/${f#*:} ;;
295                                                 *)              f_in=${d}/${f}.in ;;
296                                         esac
298                                         if [ -e ${f_in} ]
299                                         then
300                                                 chmod +w ${f_in};
301                                         fi
302                                 done
304                                 unset ac_config_files;
305                         fi
307                         # sometimes ACLOCAL_AMFLAGS is defined but the given directory
308                         # exists only in VCS (or is created by an autogen.sh) and is
309                         # not shipped in the tarball
310                         if [ -f Makefile.am ]
311                         then
312                                 __parse_aclocal_amflags $(grep '^ACLOCAL_AMFLAGS' Makefile.am | sed 's/=/ = /') | xargs -r mkdir -p
313                         fi
314                         grep '^[^\#]*AC_CONFIG_MACRO_DIRS*' ${sub_configure_ac} | sed -e "s!.*AC_CONFIG_MACRO_DIRS*(\[*\(.*\))!${d}/\1!g" -e 's!\]*!!g' | xargs -r mkdir -p
316                         if [ ! -f ${d}/aclocal.m4 ] || $(head -n 1 ${d}/aclocal.m4 | grep -q 'generated.* by aclocal')
317                         then
318                                 __config_set with_aclocal 1
319                         fi
321                         if $(grep -q 'AM_INIT_AUTOMAKE' ${sub_configure_ac})
322                         then
323                                 __config_set with_automake 1
324                         fi
326                         if $(grep -Eq '(AM_GNU_GETTEXT|AM_ICONV|AC_GGZ_INTL)' ${sub_configure_ac})
327                         then
328                                 cp -f /usr/share/gettext/config.rpath ${d}/
329                                 __config_set with_gnu_gettext 1
330                         fi
332                         if $(grep -Eq '^(AC|IT)_PROG_INTLTOOL' ${sub_configure_ac})
333                         then
334                                 intltoolize --automake --copy --force
335                                 __config_set with_intltool 1
336                         fi
338                         if $(grep -Eq '(A[CM]_PROG_LIBTOOL|LT_INIT|XCB_UTIL_COMMON)' ${sub_configure_ac})
339                         then
340                                 __config_set with_libtool 1
341                         fi
343                         if $(grep -q '\./libtool -' ${sub_configure_ac}) && ! $(grep -q 'LT_OUTPUT' ${sub_configure_ac})
344                         then
345                                 warning "${sub_configure_ac} may require LT_OUTPUT macro"
346                         fi
348                         # Automake will exit if these are not present
349                         # dodoc won't install these, however, since they will be empty
350                         touch ${d}/{AUTHORS,ChangeLog,NEWS,README};
352                         # These required files can be overwritten by automake, so we
353                         # back them up now and restore them afterwards
354                         for f in COPYING INSTALL
355                         do
356                                 if [ -f ${d}/${f} ]
357                                 then
358                                         cp ${d}/${f} ${d}/${f}.temp;
359                                         chmod +w ${d}/${f}.temp;
360                                 elif [ -d ${d}/${f} ]
361                                 then
362                                         :
363                                 else
364                                         touch ${d}/${f}
365                                 fi
366                         done
367                 fi
368         done
370         check_prog_req autoreconf autoconf
372 #****v* cygautoreconf/WANT_AUTOCONF
373 #  DESCRIPTION
374 #  This variable controls the version of autoconf to be used.  Valid settings
375 #  are "2.1" (for the 2.13 version), "2.5" (for the 2.5x/2.6x series) and "2.7"
376 #  (the default, for the 2.7x series).
377 #****
379 #****v* cygautoreconf/WANT_AUTOMAKE
380 #  DESCRIPTION
381 #  This variable controls the version of automake to be used.  Valid settings
382 #  are currently "1.4", "1.5" through to "1.16", etc.  If undefined, the version
383 #  used by the preexisting automake files will be used; if nonexistant (e.g. a
384 #  VCS checkout), the newest available automake will be used.
385 #****
386         export WANT_AUTOCONF;
387         export WANT_AUTOMAKE;
389         case "${WANT_AUTOCONF}" in
390         2.1)
391                 check_prog_req autoconf-2.13 autoconf2.1
393                 if __config_equals with_libtool 1
394                 then
395                         warning "libtool is incompatible with autoconf-2.13";
396                 fi
397                 ;;
398         2.5|2.7|'')
399                 case "${WANT_AUTOCONF}" in
400                 2.5)
401                         WANT_AUTOCONF=2.5
402                         case $(autoconf --version 2> /dev/null | head -n 1) in
403                         autoconf*2.[56]?) ;;
404                         *)      error "autoconf2.5 is required to build this package" ;;
405                         esac
406                         ;;
407                 2.7|'')
408                         WANT_AUTOCONF=2.7
409                         case $(autoconf --version 2> /dev/null | head -n 1) in
410                         autoconf*2.[7]?) ;;
411                         *)      error "autoconf2.7 is required to build this package" ;;
412                         esac
413                 esac
415                 if __config_equals with_libtool 1
416                 then
417                         case $(automake --version 2> /dev/null | head -n 1) in
418                         automake*\ 1.9.*|automake*\ 1.1[0-9]*) ;;
419                         *)  inform "libtool requires at least automake 1.9; setting WANT_AUTOMAKE"
420                             WANT_AUTOMAKE=1.9 ;;
421                         esac
422                 fi
424 #****v* cygautoreconf/NO_ACLOCAL
425 #  DESCRIPTION
426 #  Define this variable to a boolean true value to skip running aclocal
427 #  during cygautoreconf.
428 #  WARNING
429 #  This is strongly discouraged, and should only be used when a package uses
430 #  its own aclocal macros which are not provided in the tarball *and* the
431 #  package does not use libtool.
432 #****
433 #****v* cygautoreconf/NO_LIBTOOLIZE
434 #  DESCRIPTION
435 #  Define this variable to a boolean true value to skip running libtoolize
436 #  during cygautoreconf.
437 #  WARNING
438 #  This is strongly discouraged.  Cygwin's libtool usually includes patches
439 #  required for optimal results on Cygwin which are not yet available in
440 #  even the most recent upstream releases.
441 #****
442 #****v* cygautoreconf/NO_AUTOCONF
443 #  DESCRIPTION
444 #  Define this variable to a boolean true value to skip running autoconf
445 #  during cygautoreconf.
446 #  WARNING
447 #  This is strongly discouraged.  Running libtoolize, changes to aclocal macros,
448 #  or changes to configure.ac/configure.in all require autoconf to be run for
449 #  a working build.
450 #****
451 #****v* cygautoreconf/NO_AUTOHEADER
452 #  DESCRIPTION
453 #  Sometimes autoreconf thinks a package uses autoheader when in fact it does
454 #  not, in which case cygautoreconf will fail during the autoheader stage.
455 #  In such cases, provided you have not patched any AC_DEFINEs, set this
456 #  variable to a boolean true value to skip the autoheader step.
457 #****
458 #****v* cygautoreconf/NO_AUTOMAKE
459 #  DESCRIPTION
460 #  Define this variable to a boolean true value to skip running automake
461 #  during cygautoreconf.
462 #  WARNING
463 #  This is strongly discouraged.  If aclocal and/or autoconf have been run,
464 #  running automake is required for a working build.
465 #****
466 #****v* cygautoreconf/NO_AUTOPOINT
467 #  DESCRIPTION
468 #  Define this variable to a boolean true value to skip running autopoint
469 #  during cygautoreconf.
470 #  WARNING
471 #  This is strongly discouraged.  Cygwin's gettext package often has patches
472 #  which are not yet available in even the latest official release, and earlier
473 #  versions of gettext are incompatible with the current libtool.
474 #****
476                 ACLOCAL=aclocal
477                 # not all packages require gettext-devel
478                 AUTOPOINT=$(which autopoint 2>/dev/null || :)
480                 if cross_compiling || inherited toolchain
481                 then
482                         local ccsysroot=$(${CC} -print-sysroot)
483                         local sysrootgtize=${ccsysroot}$(__target_prefix)/bin/autopoint
484                         local sysrootltize=${ccsysroot}$(__target_prefix)/bin/libtoolize
485                         local sysrootaclocaldir=${ccsysroot}$(__target_prefix)/share/aclocal
486                         if [ -x ${sysrootltize} ]
487                         then
488                                 LIBTOOLIZE=${sysrootltize}
489                         fi
490                         if [ -x ${sysrootgtize} ]
491                         then
492                                 AUTOPOINT=${sysrootgtize}
493                         fi
494                 fi
496                 # libtool 2.2+ is incompatible with gettext before 0.17
497                 # config.rpath is broken wrt dynamic linkage before 0.17
498                 if defined AUTOPOINT
499                 then
500                         eval gettext_$(grep ^version= ${AUTOPOINT})
501                         if ! __version_at_least 0.17 ${gettext_version}
502                         then
503                                 error "cygautoreconf: at least gettext 0.17 required"
504                         fi
505                         case ${gettext_version} in
506                         *.*.*.*) gettext_version=${gettext_version%.*} ;;
507                         esac
508                         AUTOPOINT+=" -V ${gettext_version}"
509                 fi
511                 for tool in ACLOCAL LIBTOOLIZE AUTOCONF AUTOHEADER AUTOPOINT AUTOMAKE
512                 do
513                         if __arg_bool NO_${tool}
514                         then
515                                 declare ${tool}=true
516                                 case ${tool} in
517                                 LIBTOOLIZE) __config_set with_libtool 0 ;;
518                                 *) __config_set with_${tool,,} 0 ;;
519                                 esac
520                         fi
521                         export ${tool}
522                 done
524 #****v* cygautoreconf/ACLOCAL_FLAGS
525 #  DESCRIPTION
526 #  Set this variable when a package ships with its own aclocal macros but
527 #  their directory is not included when running aclocal during cygautoreconf.
528 #  If needed, usually in the form "-I DIR" (where DIR is the relative subdirectory
529 #  containing the aclocal macros, often m4/).
530 #****
531                 if defined ACLOCAL_FLAGS
532                 then
533                         ACLOCAL+=" ${ACLOCAL_FLAGS}"
534                 fi
535                 ;;
536         *)
537                 error "illegal WANT_AUTOCONF value: ${WANT_AUTOCONF}"
538                 ;;
539         esac
541         for d in ${sysrootaclocaldir} ${ACLOCAL_PATH//:/ }
542         do
543                 if [ -d $d ]
544                 then
545                         autoreconf_args+=" -I $d"
546                 fi
547         done
549         autoreconf --force -i --verbose ${autoreconf_args} || error "autoreconf failed"
551         for d in . ${ac_subdirs}
552         do
553                 if [ -d ${d} ]
554                 then
555                         if [ -f ${d}/configure.ac ]
556                         then
557                                 sub_configure_ac="${d}/configure.ac";
558                         else
559                                 sub_configure_ac="${d}/configure.in";
560                         fi
562                         auxdir="$(grep '^[^\#]*AC_CONFIG_AUX_DIR' ${sub_configure_ac} | sed -e 's!.*AC_CONFIG_AUX_DIR(\[*\(.*\))!\1!g' -e 's!\]*!!g')"
563                         config_h="$(grep 'A[CM]_CONFIG_HEADERS*' ${sub_configure_ac} | sed -e 's!A[CM]_CONFIG_HEADERS*(\[*\(.*\))!\1!g' -e 's!\]*!!g')";
565                         if defined config_h
566                         then
567                                 __config_set with_autoheader 1
568                         fi
570                         case "${config_h}" in
571                                 '') config_h_in= ;;
572                                 *:*) config_h_in="$(echo "${config_h//:/ }" | cut -d ' ' -f 2-)" ;;
573                                 *) config_h_in="${config_h}.in" ;;
574                         esac
576                         for f in ${config_h_in}
577                         do
578                                 if [ -e ${d}/${f} ]
579                                 then
580                                         touch ${d}/${f}
581                                 fi
582                         done
584                         if [ -f ${d}/${auxdir}/config.guess ]
585                         then
586                                 gnuconfigize ${d}/${auxdir}
587                         fi
589                         for f in COPYING INSTALL
590                         do
591                                 if [ -f ${d}/${f}.temp ]
592                                 then
593                                         mv -f ${d}/${f}.temp ${d}/${f};
594                                 fi
595                         done
596                 fi
597         done
600 #****C* autotools.cygclass/cygconf
601 #  SYNOPSIS
602 #  cygconf [CONFIGURE_FLAG] [CONFIGURE_FLAG] ...
603 #  DESCRIPTION
604 #  Runs the configure script for the package.  cygconf passes configure the flags
605 #  necessary to install the package into the /usr prefix and according to the
606 #  |html <a href="https://www.pathname.com/fhs/">Filesystem Hierarchy Standard</a> and the
607 #  |html <a href="https://cygwin.com/packaging-package-files.html#package_contents">Cygwin package guidelines</a>.
608 #  In addition, all arguments to cygconf are passed to configure, followed by
609 #  CYGCONF_ARGS, if set.
610 #  NOTES
611 #  * cygconf should be run in or under $B, as it defines the build directory of
612 #    the package and creates numerous files.
613 #  * If the configure script is not in $S, see CYGCONF_SOURCE.
614 #  * cygconf is intended for configure scripts generated by, or compatible with,
615 #    autoconf.  Packages with handwritten configure scripts may not accept all
616 #    the flags used by cygconf, in which case a direct call to the configure
617 #    script is in order.
618 #****
619 cygconf() {
620         local ac_config_files;
621         local ac_config_headers;
622         local confargs;
623         local confdir;
624         local configure;
625         local confver;
626         local confver_maj;
627         local confver_min;
628         local f;
629         local foo_config;
630         local prefix;
632 #****v* cygconf/AUTOCONF_VERSION
633 #  DESCRIPTION
634 #  In some in some rare cases, cygport cannot automatically detect the autoconf
635 #  version that was used to generate the configure script (typically when
636 #  cygautoreconf is not being used, and the autoconfigury has been heavily
637 #  customized).  This variable can be set to indicate the autoconf version the
638 #  configure script's options are compatible with e.g. "2.50", "2.60", "2.70".
639 #****
641 #****v* cygconf/CYGCONF_SOURCE
642 #  DESCRIPTION
643 #  Set this variable to the directory containing the configure script.  This
644 #  is only necessary when configure is not in $S and cygconf is not being run
645 #  in the same subdirectory of $B which under $S contains configure.  (IOW if
646 #  the configure script is in $S/unix and cygconf is run from $B/unix, setting
647 #  CYGCONF_SOURCE would not be necessary.)
648 #****
649         if defined CYGCONF_SOURCE
650         then
651                 if [ -x ${CYGCONF_SOURCE}/configure ]
652                 then
653                         confdir=${CYGCONF_SOURCE};
654                 else
655                         error "CYGCONF_SOURCE defined but no configure script found"
656                 fi
657         elif [ -x ${PWD/${B}/${S}}/configure ]
658         then
659                 confdir=${PWD/${B}/${S}};
660         elif [ -x ${S}/configure ]
661         then
662                 confdir=${S};
663         else
664                 error "no configure script found";
665         fi
667         configure="${confdir}/configure"
668         if [ -z ${AUTOCONF_VERSION} ]
669         then
670                 confver="$("$configure" --version | sed -rn 's/.*(GNU Autoconf|autoconf version) ([0-9\.]+)/\2/p')"
671         else
672                 confver=${AUTOCONF_VERSION}
673         fi
674         confver_maj=${confver%%.*}
675         confver_min=${confver##*.}
676         if [ -z $confver_maj ]
677         then
678                 error "could not determine the autoconf version used to generate ./configure; perhaps set AUTOCONF_VERSION?";
679         fi
680         if [ $confver_maj -ne 2 ]
681         then
682                 error "unexpected autoconf version";
683         fi
685         # AC_CONFIG_FILES should not be dist'ed, but it sometimes happens anyway
686         eval $(grep -h '^ac_config_files=' ${configure})
687         eval $(grep -h '^ac_config_headers=' ${configure})
689         for f in ${ac_config_files} ${ac_config_headers}
690         do
691                 if [ -f ${confdir}/${f} ]
692                 then
693                         inform "Removing ${f} to be regenerated by configure"
694                         rm -f ${confdir}/${f}
695                         ln -sf ${confdir/${S}/${PWD}}/${f} ${confdir}/${f}
696                 fi
697         done
699         prefix=$(__host_prefix)
701         # Set default configure arguments
702         confargs="--prefix=${prefix} --exec-prefix=${prefix} \
703                   --localstatedir=$(__host_localstatedir) \
704                   --sysconfdir=$(__host_sysconfdir)"
706         if inherited multilib
707         then
708                 confargs+=" --libdir=${prefix}/${MULTILIB_LIBDIR}"
709         fi
711         if [ $confver_min -ge 60 ]
712         then
713                 # Autoconf version supports --docdir and --htmldir, which will
714                 # need to be specified manually.  It also supports --infodir
715                 # and --mandir, but the defaults for those match the FHS.
716                 confargs+=" --docdir=/usr/share/doc/${PN} --htmldir=/usr/share/doc/${PN}/html"
717         else
718                 # Autoconf version does not support --docdir or --htmldir, so
719                 # don't specify those.  Set --infodir and --mandir, as those
720                 # have defaults that don't match the FHS.
721                 confargs+=" --infodir=${prefix}/share/info --mandir=${prefix}/share/man"
722         fi
725         if [ $confver_min -ge 50 ]
726         then
727                 # Always use a cache file; prior to 2.50, this was the default,
728                 # thereafter it needs to be requested explicitly.
729                 confargs+=" -C"
730         fi
732         if cross_compiling || inherited toolchain
733         then
734                 confargs+=" --build=${CBUILD} --host=${CHOST}"
735                 if inherited toolchain
736                 then
737                         # AM_GNU_GETTEXT is used in subdirectories of the
738                         # cygnus tree but not in the top-level
739                         confargs+=" --target=${CTARGET} --without-libiconv-prefix --without-libintl-prefix"
740                 fi
741         fi
743         if cross_compiling
744         then
745                 # make sure that PATH checks for foo-config scripts
746                 # do not detect the native ones in /usr/bin
747                 for foo_config in $(ls /usr/bin/*[-_]config 2>/dev/null)
748                 do
749                         case ${foo_config##*/} in pkg-config) continue ; esac
750                         export $(echo ${foo_config##*/} | tr "a-z+-\." "A-ZX__")=no
751                         export ac_cv_path_$(echo ${foo_config##*/} | tr "a-z+-\." "A-ZX__")=no
752                 done
753                 for foo_config in $(ls $(__host_prefix)/bin/*[-_]config 2>/dev/null)
754                 do
755                         export $(echo ${foo_config##*/} | tr "a-z+-\." "A-ZX__")=$foo_config
756                         export ac_cv_path_$(echo ${foo_config##*/} | tr "a-z+-\." "A-ZX__")=$foo_config
757                 done
758         fi
760         if __config_equals with_libtool 1 && ! __host_is_embedded
761         then
762                 confargs+=" --enable-shared --disable-static"
763         fi
765         # workaround lib-link.m4:AC_LIB_HAVE_LINKFLAGS's insistence on
766         # linking with rpath, and stick with -l flags instead
767         for l in $(grep '^with_lib[^ ]*_prefix$' ${configure})
768         do
769                 # make sure this is not just a custom AC_ARG_WITH;
770                 # AC_LIB_HAVE_LINKFLAGS uses LIBNAME_PREFIX= further on in
771                 if grep -q $(echo ${l#with_}= | tr '[:lower:]' '[:upper:]') ${configure}
772                 then
773                         confargs+=" --${l//_/-}=no"
774                 fi
775         done
777         # AC_HAVE_MMAP fails despite a working mmap, so we force this to yes
778         # (see https://sourceware.org/legacy-ml/cygwin/2004-09/msg00741.html
779         # and following thread for details)
780         case ${CHOST} in
781         *-*-cygwin*)
782                 export ac_cv_func_mmap_fixed_mapped=yes ;;
783         esac
785         # packages that use intltool w/o glib-gettext get this wrong
786         export DATADIRNAME="share"
788 #****v* cygconf/CYGCONF_ARGS
789 #  DESCRIPTION
790 #  Additional flags to pass to configure, as a string.
791 #  NOTE
792 #  Flags in CYGCONF_ARGS follow, and therefore override, flags passed by default
793 #  and as arguments to cygconf.
794 #****
796         verbose ${configure} \
797                 --srcdir="${confdir}" ${confargs} "${@}" ${CYGCONF_ARGS} \
798                 || error "configure failed"
801 #****o* autotools.cygclass/src_compile (autotools)
802 #  DEFINITION
803 src_compile() {
804         cd ${S}
805         cygautoreconf
806         cd ${B}
807         cygconf
808         cygmake
810 #****
812 if ! defined _autotools_CYGCLASS_stage1_
813 then
814         readonly -f cygautoreconf cygconf gnuconfigize __parse_aclocal_amflags