2
votes

I am creating an android.m4 file to easily look up path to programs in the android SDK/NDK.

The android.m4 file contains an helper function called _android_path_found_notfound:

# _android_path_found_notfound(variable, program, path, found, notfound)
#
# search for a program in path. If found, 'variable' is set to the absolute path,
# then executes 'found', otherwise, 'variable' is set to '' and 'notfound' is run
m4_define([_android_path_found_notfound],
    [AC_PATH_PROG([_android_temp_],[$2],[_android_notfound],[$3])
     AS_IF( [test x"$_android_temp_" = x"_android_notfound"],
        [$1=""
        AC_SUBST([$1],[])
        $5],
        [$1="$_android_temp_"
        AC_SUBST([$1],[$_android_temp_])
        $4] )])

and many functions which use that helper function:

AC_DEFUN([AC_PROG_ANDROID],
     [_android_path_found_notfound([ANDROID],[android],[$ANDROID_HOME:$PATH],[$1],[$2])]
)

AC_DEFUN([AC_PROG_DX],
     [_android_path_found_notfound([DX],[dx],[$ANDROID_HOME:$PATH],[$1],[$2])]
)

...

However, when I run a configure script that calls AC_PROG_ANDROID then AC_PROG_DX, I obtain this:

checking for android... /opt/android-sdk-update-manager/tools/android
checking for dx... (cached) /opt/android-sdk-update-manager/tools/android

The second line points to the same program as the first one, and reads (cached). Why is the result cached?

1
As a side note for future readers, commands starting with AC_ are reserved, so it was a bad choice.qdii

1 Answers

4
votes

AC_PATH_PROG saves its result in an autoconf-specific variable which it links to the variable given in AC_PATH_PROG. So if you said AC_PATH_PROG([something],..., then it will remember the answer for "something". Since your AC_PROG_ANDROID and AC_PROG_DX both set the value _android_temp_, the result for that is cached and used later.

The easiest way to fix it is probably to use different variables for AC_PROG_ANDROID and AC_PROG_DX