Add files from parent branch HEAD:
[pkgsrc.git] / mk / configure / gnu-configure.mk
1 # $NetBSD: gnu-configure.mk,v 1.7 2008/02/07 21:36:13 rillig Exp $
2
3 _VARGROUPS+=                    gnu-configure
4 _USER_VARS.gnu-configure=       # none
5 _PKG_VARS.gnu-configure=        GNU_CONFIGURE GNU_CONFIGURE_PREFIX \
6         GNU_CONFIGURE_INFODIR GNU_CONFIGURE_MANDIR \
7         CONFIGURE_HAS_MANDIR CONFIGURE_HAS_INFODIR \
8         OVERRIDE_DIRDEPTH.configure \
9         USE_GNU_CONFIGURE_HOST
10
11 HAS_CONFIGURE=                  defined
12 OVERRIDE_GNU_CONFIG_SCRIPTS=    defined
13 INSTALL_SH_OVERRIDE?=           # empty
14
15 CONFIGURE_ENV+= CONFIG_SHELL=${CONFIG_SHELL:Q}
16 CONFIGURE_ENV+= LIBS=${LIBS:M*:Q}
17 CONFIGURE_ENV+= ac_given_INSTALL=${INSTALL:Q}\ -c\ -o\ ${BINOWN}\ -g\ ${BINGRP}
18
19 .if (defined(USE_LIBTOOL) || !empty(PKGPATH:Mdevel/libtool-base)) && \
20     defined(_OPSYS_MAX_CMDLEN_CMD)
21 CONFIGURE_ENV+= lt_cv_sys_max_cmd_len=${_OPSYS_MAX_CMDLEN_CMD:sh}
22 .endif
23
24 GNU_CONFIGURE_PREFIX?=  ${PREFIX}
25 CONFIGURE_ARGS+=        --prefix=${GNU_CONFIGURE_PREFIX:Q}
26
27 USE_GNU_CONFIGURE_HOST?=        yes
28 .if !empty(USE_GNU_CONFIGURE_HOST:M[yY][eE][sS])
29 .  if !empty(USE_CROSS_COMPILE:M[yY][eE][sS])
30 CONFIGURE_ARGS+=        --build=${NATIVE_MACHINE_GNU_PLATFORM:Q}
31 .  endif
32 CONFIGURE_ARGS+=        --host=${MACHINE_GNU_PLATFORM:Q}
33 .endif
34
35 # PKGINFODIR is the subdirectory of ${PREFIX} into which the info
36 # files are installed unless the software was configured with an
37 # installation prefix other than ${PREFIX}.
38 #
39 CONFIGURE_HAS_INFODIR?= yes
40 .if ${GNU_CONFIGURE_PREFIX} == ${PREFIX}
41 GNU_CONFIGURE_INFODIR?= ${GNU_CONFIGURE_PREFIX}/${PKGINFODIR}
42 .else
43 GNU_CONFIGURE_INFODIR?= ${GNU_CONFIGURE_PREFIX}/info
44 .endif
45 .if defined(INFO_FILES) && !empty(CONFIGURE_HAS_INFODIR:M[yY][eE][sS])
46 CONFIGURE_ARGS+=        --infodir=${GNU_CONFIGURE_INFODIR:Q}
47 .endif
48
49 # PKGMANDIR is the subdirectory of ${PREFIX} into which the man and
50 # catman pages are installed unless the software was configured with
51 # an installation prefix other than ${PREFIX}.
52 #
53 CONFIGURE_HAS_MANDIR?=   yes
54 .if ${GNU_CONFIGURE_PREFIX} == ${PREFIX}
55 GNU_CONFIGURE_MANDIR?=  ${GNU_CONFIGURE_PREFIX}/${PKGMANDIR}
56 .else
57 GNU_CONFIGURE_MANDIR?=  ${GNU_CONFIGURE_PREFIX}/man
58 .endif
59 .if !empty(CONFIGURE_HAS_MANDIR:M[yY][eE][sS])
60 CONFIGURE_ARGS+=        --mandir=${GNU_CONFIGURE_MANDIR:Q}
61 .endif
62
63 ######################################################################
64 ### configure-scripts-override (PRIVATE)
65 ######################################################################
66 ### configure-scripts-override modifies the GNU configure scripts in
67 ### ${WRKSRC} so that the generated config.status scripts never do
68 ### anything on "--recheck".  This is important in pkgsrc because we
69 ### only ever want to run the configure checks during the configure
70 ### phase, and "recheck" is often run during the build and install
71 ### phases.
72 ###
73 do-configure-pre-hook: configure-scripts-override
74
75 _SCRIPT.configure-scripts-override=                                     \
76         ${AWK} '/ *-recheck *\| *--recheck.*\)/ {                       \
77                         print;                                          \
78                         print " : Avoid regenerating within pkgsrc";    \
79                         print " exit 0";                                \
80                         next;                                           \
81                 }                                                       \
82                 { print }' $$file > $$file.override;                    \
83         ${CHMOD} +x $$file.override;                                    \
84         ${MV} -f $$file.override $$file
85
86 OVERRIDE_DIRDEPTH.configure?=   ${OVERRIDE_DIRDEPTH}
87
88 .PHONY: configure-scripts-override
89 configure-scripts-override:
90         @${STEP_MSG} "Modifying GNU configure scripts to avoid --recheck"
91 .if defined(CONFIGURE_SCRIPTS_OVERRIDE) && !empty(CONFIGURE_SCRIPTS_OVERRIDE)
92         @echo HERE
93         ${RUN} \
94         cd ${WRKSRC};                                                   \
95         for file in ${CONFIGURE_SCRIPTS_OVERRIDE}; do                   \
96                 ${TEST} -f "$$file" || continue;                        \
97                 ${_SCRIPT.${.TARGET}};                                  \
98         done
99 .else
100         ${RUN} \
101         cd ${WRKSRC};                                                   \
102         depth=0; pattern=${CONFIGURE_SCRIPT:T};                         \
103         while ${TEST} $$depth -le ${OVERRIDE_DIRDEPTH.configure}; do    \
104                 for file in $$pattern; do                               \
105                         ${TEST} -f "$$file" || continue;                \
106                         ${_SCRIPT.${.TARGET}};                          \
107                 done;                                                   \
108                 depth=`${EXPR} $$depth + 1`; pattern="*/$$pattern";     \
109         done
110 .endif