… | |
… | |
3 | |
3 | |
4 | AC_DEFUN([PT_FIND_FILE], |
4 | AC_DEFUN([PT_FIND_FILE], |
5 | [AC_CACHE_CHECK(where $1 is located, pt_cv_path_$1, |
5 | [AC_CACHE_CHECK(where $1 is located, pt_cv_path_$1, |
6 | [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h> |
6 | [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h> |
7 | #include <stdlib.h> |
7 | #include <stdlib.h> |
|
|
8 | #include <sys/stat.h> |
8 | $5 |
9 | $5 |
9 | #include <errno.h> |
|
|
10 | int main() |
10 | int main() |
11 | { |
11 | { |
12 | char **path, *list[] = { $4, NULL }; |
12 | char **path, *list[] = { $4, NULL }; |
13 | FILE *a, *f=fopen("conftestval", "w"); |
13 | FILE *f = fopen("conftestval", "w"); |
14 | if (!f) exit(1); |
14 | if (!f) return 1; |
15 | #ifdef $2 |
15 | #ifdef $2 |
16 | fprintf(f, "%s\n", $2); |
16 | fprintf(f, "%s\n", $2); |
17 | exit(0); |
17 | #elif defined($3) |
18 | #endif |
|
|
19 | #ifdef $3 |
|
|
20 | fprintf(f, "%s\n", $3); |
18 | fprintf(f, "%s\n", $3); |
21 | exit(0); |
19 | #else |
22 | #endif |
|
|
23 | for (path = list; *path; path++) { |
20 | for (path = list; *path; path++) { |
24 | if ((a = fopen(*path, "r")) != NULL || errno == EACCES) { |
21 | struct stat st; |
|
|
22 | if (stat(*path, &st) == 0) { |
25 | fprintf(f, "%s\n", *path); |
23 | fprintf(f, "%s\n", *path); |
26 | exit(0); |
24 | break; |
27 | } |
25 | } |
28 | } |
26 | } |
29 | exit(0); |
27 | #endif |
|
|
28 | return fclose(f) != 0; |
30 | }]])],[pt_cv_path_$1=`cat conftestval`],[pt_cv_path_$1=], |
29 | }]])],[pt_cv_path_$1=`cat conftestval`],[pt_cv_path_$1=], |
31 | [AC_MSG_WARN(Define $2 in config.h manually)])]) |
30 | [AC_MSG_WARN(Define $2 in config.h manually)])]) |
32 | if test x$pt_cv_path_$1 != x; then |
31 | if test x$pt_cv_path_$1 != x; then |
33 | AC_DEFINE_UNQUOTED($2, "$pt_cv_path_$1", Define location of $1) |
32 | AC_DEFINE_UNQUOTED($2, "$pt_cv_path_$1", Define location of $1) |
34 | fi]) |
33 | fi]) |