merge common functionality into AROS_TOOL
[AROS.git] / acinclude.m4
blob8d07522eaa2b19613ba09ebb67843e9237001279
1 dnl Some autoconf macros for AROS
2 dnl
3 dnl Search for a file, and place the result into the cache.
5 dnl AROS_REQUIRED(name,var)
6 dnl Checks if var is defined, and aborts otherwise. name is just for
7 dnl presentation to the user.
8 dnl
9 AC_DEFUN([AROS_REQUIRED],
10 [req_avail=yes
11 if test "$2" = ""; then
12     req_avail=no
14 if test "$2" = "no"; then
15     req_avail=no
17 if test "$req_avail" = "no"; then
18     AC_MSG_ERROR([$1 is required to build AROS. Please install and run configure again.])
19 fi])
21 dnl AROS_PROG(var,prog,args)
22 dnl Checks if prog is on the path. If it is, sets var to "prog args".
23 dnl args is optional.
24 dnl
25 AC_DEFUN([AROS_PROG],
26 [AC_CHECK_PROG([$1],[$2],[$2 $3])])
28 dnl AROS_BUILDCMD(var,prog,ext)
29 dnl appends the cmd part of prog with ext
30 dnl
31 AC_DEFUN([AROS_BUILDCMD],
32 [if test "$3" != ""; then
33     if test "$2" != ""; then
34         ac_prog_args=`expr "X$2" : '[[^ ]]* \(.*\)'`
35         ac_prog_cmd=`expr "X$2" : '^\S*'`
36         $1="$ac_prog_cmd[$]$3 $ac_prog_args"
37     fi
38 fi])
40 dnl AROS_TOOL_CCPATH(var,prog)
41 dnl This will first look for the tool in the CC path and then in the
42 dnl normal path (CC path only supported for gcc at the moment)
43 AC_DEFUN([AROS_TOOL_CCPATH],
44 [if test "$GCC" = "yes"; then
45     aros_gcc_[$2]=`$CC -print-prog-name=[$2]`
46     AC_PATH_PROG([$1], [`basename $aros_gcc_[$2]`], , [`dirname $aros_gcc_[$2]`])
48 if test "$[$1]" = ""; then
49     AC_PATH_PROG([$1],[$2])
50 fi])
52 dnl AROS_TOOL(var,prog,prefix,override)
53 dnl This is common code for AROS_PROG and AROS_KERNEL
54 dnl
55 AC_DEFUN([AROS_TOOL],
56 [if test "$4" = ""; then
57     if test "$cross_compiling" = "yes" ; then
58         AC_PATH_PROG([$1],[$3][$2])
59     else
60         AROS_TOOL_CCPATH($1, $2)
61     fi
62 else
63     ac_tool_optarg=`expr "X$4" : '[[^ ]]* \(.*\)'`
64     AC_PATH_PROG($1, $4)
65     $1="[$]$1 $ac_tool_optarg"
66 fi])
68 dnl AROS_KERNEL_TARGET(var,prog,override)
69 dnl This is effectively the same as AROS_PROG, but adds the appropriate
70 dnl arch prefix when cross compiling. 
71 dnl
72 AC_DEFUN([AROS_TOOL_KERNEL],
74     AROS_TOOL([$1],[$2].[${kernel_tool_prefix}],[$3])
78 dnl AROS_TOOL_TARGET(var,prog,override)
79 dnl This is effectively the same as AROS_PROG, but adds the appropriate
80 dnl arch prefix when cross compiling. 
81 dnl
82 AC_DEFUN([AROS_TOOL_TARGET],
84     AROS_TOOL([$1],[$2].[${target_tool_prefix}],[$3])
87 dnl AROS_KERNEL_TARGET(var,prog,override)
88 dnl This is effectively the same as AROS_PROG, but adds the appropriate
89 dnl arch prefix when cross compiling. 
90 dnl
91 AC_DEFUN([AROS_TOOL_KERNEL],
93 if test "$3" = ""; then
94     if test "$cross_compiling" = "yes" ; then
95         AC_PATH_PROG([$1],${kernel_tool_prefix}[$2])
96     else
97         AROS_TOOL_CCPATH($1, $2)
98     fi
99 else
100     ac_tool_optarg=`expr "X$3" : '[[^ ]]* \(.*\)'`
101     AC_PATH_PROG($1, $3)
102     $1="[$]$1 $ac_tool_optarg"
106 dnl AROS_CACHE_CHECK(message, var, check)
107 dnl This is similar to the AC_CACHE_CHECK macro, but it hides the
108 dnl prefix and stuff from the coders. We will get aros_$2 on the
109 dnl variable, and aros_cv_$2 on the cache variable.
110 AC_DEFUN([AROS_CACHE_CHECK],
111 [AC_MSG_CHECKING([$1])
112 AC_CACHE_VAL(aros_cv_[$2],
114 aros_cv_[$2]="[$]aros_[$2]"
116 aros_[$2]="[$]aros_cv_[$2]"
117 AC_MSG_RESULT([$]aros_$2)])