1 # Autoconf M4 include file defining utility macros for complex Canadian
5 dnl # _GCC_TOPLEV_NONCANONICAL_BUILD
6 dnl # $build_alias or canonical $build if blank.
7 dnl # Used when we would use $build_alias, but empty is not OK.
8 AC_DEFUN([_GCC_TOPLEV_NONCANONICAL_BUILD],
9 [AC_REQUIRE([AC_CANONICAL_BUILD]) []dnl
10 case ${build_alias} in
11 "") build_noncanonical=${build} ;;
12 *) build_noncanonical=${build_alias} ;;
14 ]) []dnl # _GCC_TOPLEV_NONCANONICAL_BUILD
17 dnl # _GCC_TOPLEV_NONCANONICAL_HOST
18 dnl # $host_alias, or $build_noncanonical if blank.
19 dnl # Used when we would use $host_alias, but empty is not OK.
20 AC_DEFUN([_GCC_TOPLEV_NONCANONICAL_HOST],
21 [AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_BUILD]) []dnl
23 "") host_noncanonical=${build_noncanonical} ;;
24 *) host_noncanonical=${host_alias} ;;
26 ]) []dnl # _GCC_TOPLEV_NONCANONICAL_HOST
29 dnl # _GCC_TOPLEV_NONCANONICAL_TARGET
30 dnl # $target_alias or $host_noncanonical if blank.
31 dnl # Used when we would use $target_alias, but empty is not OK.
32 AC_DEFUN([_GCC_TOPLEV_NONCANONICAL_TARGET],
33 [AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_HOST]) []dnl
34 case ${target_alias} in
35 "") target_noncanonical=${host_noncanonical} ;;
36 *) target_noncanonical=${target_alias} ;;
38 ]) []dnl # _GCC_TOPLEV_NONCANONICAL_TARGET
41 dnl # GCC_TOPLEV_SUBDIRS
42 dnl # GCC & friends build 'build', 'host', and 'target' tools. These must
43 dnl # be separated into three well-known subdirectories of the build directory:
44 dnl # build_subdir, host_subdir, and target_subdir. The values are determined
45 dnl # here so that they can (theoretically) be changed in the future. They
46 dnl # were previously reproduced across many different files.
48 dnl # This logic really amounts to very little with autoconf 2.13; it will
49 dnl # amount to a lot more with autoconf 2.5x.
50 AC_DEFUN([GCC_TOPLEV_SUBDIRS],
51 [AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_TARGET]) []dnl
52 AC_REQUIRE([_GCC_TOPLEV_NONCANONICAL_BUILD]) []dnl
53 # Prefix 'build-' so this never conflicts with target_subdir.
54 build_subdir="build-${build_noncanonical}"
55 # Not really a subdirectory, but here for completeness.
58 target_subdir=${target_noncanonical}
59 AC_SUBST([build_subdir]) []dnl
60 AC_SUBST([host_subdir]) []dnl
61 AC_SUBST([target_subdir]) []dnl
62 ]) []dnl # GCC_TOPLEV_SUBDIRS
66 # _NCN_TOOL_PREFIXES: Some stuff that oughtta be done in AC_CANONICAL_SYSTEM
68 # These demand that AC_CANONICAL_SYSTEM be called beforehand.
69 AC_DEFUN([_NCN_TOOL_PREFIXES],
71 test -n "$host_alias" && ncn_tool_prefix=$host_alias-
72 ncn_target_tool_prefix=
73 test -n "$target_alias" && ncn_target_tool_prefix=$target_alias-
74 ]) []dnl # _NCN_TOOL_PREFIXES
77 # NCN_CHECK_TARGET_TOOL(variable, prog-to-check-for,[value-if-not-found],[path])
78 # Like AC_CHECK_TOOL, but tries a prefix of the target, not the host.
79 # Code is pretty much lifted from autoconf2.53.
81 AC_DEFUN([NCN_CHECK_TARGET_TOOL],
82 [AC_REQUIRE([_NCN_TOOL_PREFIXES]) []dnl
83 if test -n "$ncn_target_tool_prefix"; then
84 AC_CHECK_PROG([$1], [${ncn_target_tool_prefix}$2],
85 [${ncn_target_tool_prefix}$2], , [$4])
87 if test -z "$ac_cv_prog_$1" ; then
89 AC_CHECK_PROG([ncn_cv_$1], [$2], [$2], [$3], [$4])
94 ]) []dnl # NCN_CHECK_TARGET_TOOL
98 # NCN_STRICT_CHECK_TOOL(variable, prog-to-check-for,[value-if-not-found],[path])
99 # Like AC_CHECK_TOOL, but requires the prefix if build!=host.
101 AC_DEFUN([NCN_STRICT_CHECK_TOOL],
102 [AC_REQUIRE([_NCN_TOOL_PREFIXES]) []dnl
103 if test -n "$ncn_tool_prefix"; then
104 AC_CHECK_PROG([$1], [${ncn_tool_prefix}$2],
105 [${ncn_tool_prefix}$2], , [$4])
107 if test -z "$ac_cv_prog_$1" ; then
108 if test $build = $host ; then
110 AC_CHECK_PROG([ncn_cv_$1], [$2], [$2], [ifelse([$3],[],[$2],[$3])], [$4])
113 $1="ifelse([$3],[],[${ncn_tool_prefix}$2],[$3])"
118 ]) []dnl # NCN_STRICT_CHECK_TOOL
122 # NCN_STRICT_CHECK_TARGET_TOOL(variable, prog-to-check-for,[value-if-not-found],[path])
123 # Like NCN_CHECK_TARGET_TOOL, but requires the prefix if build!=target.
125 AC_DEFUN([NCN_STRICT_CHECK_TARGET_TOOL],
126 [AC_REQUIRE([_NCN_TOOL_PREFIXES]) []dnl
127 if test -n "$ncn_target_tool_prefix"; then
128 AC_CHECK_PROG([$1], [${ncn_target_tool_prefix}$2],
129 [${ncn_target_tool_prefix}$2], , [$4])
131 if test -z "$ac_cv_prog_$1" ; then
132 if test $build = $target ; then
134 AC_CHECK_PROG([ncn_cv_$1], [$2], [$2], [ifelse([$3],[],[$2],[$3])], [$4])
137 $1="ifelse([$3],[],[${ncn_target_tool_prefix}$2],[$3])"
142 ]) []dnl # NCN_STRICT_CHECK_TARGET_TOOL