Move directory-related stuff to the unix package
[packages/base.git] / aclocal.m4
1 # FP_COMPUTE_INT(EXPRESSION, VARIABLE, INCLUDES, IF-FAILS)
2 # --------------------------------------------------------
3 # Assign VARIABLE the value of the compile-time EXPRESSION using INCLUDES for
4 # compilation. Execute IF-FAILS when unable to determine the value. Works for
5 # cross-compilation, too.
6 #
7 # Implementation note: We are lazy and use an internal autoconf macro, but it
8 # is supported in autoconf versions 2.50 up to the actual 2.57, so there is
9 # little risk.
10 AC_DEFUN([FP_COMPUTE_INT],
11 [_AC_COMPUTE_INT([$1], [$2], [$3], [$4])[]dnl
12 ])# FP_COMPUTE_INT
13
14
15 # FP_CHECK_CONST(EXPRESSION, [INCLUDES = DEFAULT-INCLUDES], [VALUE-IF-FAIL = -1])
16 # -------------------------------------------------------------------------------
17 # Defines CONST_EXPRESSION to the value of the compile-time EXPRESSION, using
18 # INCLUDES. If the value cannot be determined, use VALUE-IF-FAIL.
19 AC_DEFUN([FP_CHECK_CONST],
20 [AS_VAR_PUSHDEF([fp_Cache], [fp_cv_const_$1])[]dnl
21 AC_CACHE_CHECK([value of $1], fp_Cache,
22 [FP_COMPUTE_INT([$1], fp_check_const_result, [AC_INCLUDES_DEFAULT([$2])],
23                 [fp_check_const_result=m4_default([$3], ['-1'])])
24 AS_VAR_SET(fp_Cache, [$fp_check_const_result])])[]dnl
25 AC_DEFINE_UNQUOTED(AS_TR_CPP([CONST_$1]), AS_VAR_GET(fp_Cache), [The value of $1.])[]dnl
26 AS_VAR_POPDEF([fp_Cache])[]dnl
27 ])# FP_CHECK_CONST
28
29
30 # FP_CHECK_CONSTS_TEMPLATE(EXPRESSION...)
31 # ---------------------------------------
32 # autoheader helper for FP_CHECK_CONSTS
33 m4_define([FP_CHECK_CONSTS_TEMPLATE],
34 [AC_FOREACH([fp_Const], [$1],
35   [AH_TEMPLATE(AS_TR_CPP(CONST_[]fp_Const),
36                [The value of ]fp_Const[.])])[]dnl
37 ])# FP_CHECK_CONSTS_TEMPLATE
38
39
40 # FP_CHECK_CONSTS(EXPRESSION..., [INCLUDES = DEFAULT-INCLUDES], [VALUE-IF-FAIL = -1])
41 # -----------------------------------------------------------------------------------
42 # List version of FP_CHECK_CONST
43 AC_DEFUN([FP_CHECK_CONSTS],
44 [FP_CHECK_CONSTS_TEMPLATE([$1])dnl
45 for fp_const_name in $1
46 do
47 FP_CHECK_CONST([$fp_const_name], [$2], [$3])
48 done
49 ])# FP_CHECK_CONSTS
50
51
52 dnl ** Map an arithmetic C type to a Haskell type.
53 dnl    Based on autconf's AC_CHECK_SIZEOF.
54
55 dnl FPTOOLS_CHECK_HTYPE(TYPE [, DEFAULT_VALUE, [, VALUE-FOR-CROSS-COMPILATION])
56 AC_DEFUN([FPTOOLS_CHECK_HTYPE],
57 [changequote(<<, >>)dnl
58 dnl The name to #define.
59 define(<<AC_TYPE_NAME>>, translit(htype_$1, [a-z *], [A-Z_P]))dnl
60 dnl The cache variable name.
61 define(<<AC_CV_NAME>>, translit(fptools_cv_htype_$1, [ *], [_p]))dnl
62 define(<<AC_CV_NAME_supported>>, translit(fptools_cv_htype_sup_$1, [ *], [_p]))dnl
63 changequote([, ])dnl
64 AC_MSG_CHECKING(Haskell type for $1)
65 AC_CACHE_VAL(AC_CV_NAME,
66 [AC_CV_NAME_supported=yes
67 fp_check_htype_save_cppflags="$CPPFLAGS"
68 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
69 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
70 #include <stddef.h>
71
72 #if HAVE_SYS_TYPES_H
73 # include <sys/types.h>
74 #endif
75
76 #if HAVE_UNISTD_H
77 # include <unistd.h>
78 #endif
79
80 #if HAVE_SYS_STAT_H
81 # include <sys/stat.h>
82 #endif
83
84 #if HAVE_FCNTL_H
85 # include <fcntl.h>
86 #endif
87
88 #if HAVE_SIGNAL_H
89 # include <signal.h>
90 #endif
91
92 #if HAVE_TIME_H
93 # include <time.h>
94 #endif
95
96 #if HAVE_TERMIOS_H
97 # include <termios.h>
98 #endif
99
100 #if HAVE_STRING_H
101 # include <string.h>
102 #endif
103
104 #if HAVE_CTYPE_H
105 # include <ctype.h>
106 #endif
107
108 #if HAVE_INTTYPES_H
109 # include <inttypes.h>
110 #else
111 # if HAVE_STDINT_H
112 #  include <stdint.h>
113 # endif
114 #endif
115
116 #if defined(HAVE_GL_GL_H)
117 # include <GL/gl.h>
118 #elif defined(HAVE_OPENGL_GL_H)
119 # include <OpenGL/gl.h>
120 #endif
121
122 #if defined(HAVE_AL_AL_H)
123 # include <AL/al.h>
124 #elif defined(HAVE_OPENAL_AL_H)
125 # include <OpenAL/al.h>
126 #endif
127
128 #if defined(HAVE_AL_ALC_H)
129 # include <AL/alc.h>
130 #elif defined(HAVE_OPENAL_ALC_H)
131 # include <OpenAL/alc.h>
132 #endif
133
134 #if HAVE_SYS_RESOURCE_H
135 # include <sys/resource.h>
136 #endif
137
138 #include <stdlib.h>
139
140 typedef $1 testing;
141
142 int main(void) {
143   FILE *f=fopen("conftestval", "w");
144   if (!f) exit(1);
145   if (((testing)((int)((testing)1.4))) == ((testing)1.4)) {
146     fprintf(f, "%s%d\n",
147            ((testing)(-1) < (testing)0) ? "Int" : "Word",
148            (int)(sizeof(testing)*8));
149   } else {
150     fprintf(f,"%s\n",
151            (sizeof(testing) >  sizeof(double)) ? "LDouble" :
152            (sizeof(testing) == sizeof(double)) ? "Double"  : "Float");
153   }
154   fclose(f);
155   exit(0);
156 }]])],[AC_CV_NAME=`cat conftestval`],
157 [ifelse([$2], , [AC_CV_NAME=NotReallyAType; AC_CV_NAME_supported=no], [AC_CV_NAME=$2])],
158 [ifelse([$3], , [AC_CV_NAME=NotReallyATypeCross; AC_CV_NAME_supported=no], [AC_CV_NAME=$3])])
159 CPPFLAGS="$fp_check_htype_save_cppflags"]) dnl
160 if test "$AC_CV_NAME_supported" = yes; then
161   AC_MSG_RESULT($AC_CV_NAME)
162   AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [Define to Haskell type for $1])
163 else
164   AC_MSG_RESULT([not supported])
165 fi
166 undefine([AC_TYPE_NAME])dnl
167 undefine([AC_CV_NAME])dnl
168 undefine([AC_CV_NAME_supported])dnl
169 ])
170
171
172 # FP_SEARCH_LIBS_PROTO(WHAT, PROTOTYPE, FUNCTION, SEARCH-LIBS,
173 #                [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
174 #                [OTHER-LIBRARIES])
175 # --------------------------------------------------------
176 # Search for a library defining FUNC, if it's not already available.
177 # This is a copy of the AC_SEARCH_LIBS definition, but extended to take
178 # the name of the thing we are looking for as its first argument, and
179 # prototype text as its second argument. It also calls AC_LANG_PROGRAM
180 # instead of AC_LANG_CALL
181 AC_DEFUN([FP_SEARCH_LIBS_PROTO],
182 [AS_VAR_PUSHDEF([ac_Search], [ac_cv_search_$3])dnl
183 AC_CACHE_CHECK([for library containing $1], [ac_Search],
184 [ac_func_search_save_LIBS=$LIBS
185 AC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])])
186 for ac_lib in '' $4; do
187   if test -z "$ac_lib"; then
188     ac_res="none required"
189   else
190     ac_res=-l$ac_lib
191     LIBS="-l$ac_lib $7 $ac_func_search_save_LIBS"
192   fi
193   AC_LINK_IFELSE([], [AS_VAR_SET([ac_Search], [$ac_res])])
194   AS_VAR_SET_IF([ac_Search], [break])dnl
195 done
196 AS_VAR_SET_IF([ac_Search], , [AS_VAR_SET([ac_Search], [no])])dnl
197 rm conftest.$ac_ext
198 LIBS=$ac_func_search_save_LIBS])
199 ac_res=AS_VAR_GET([ac_Search])
200 AS_IF([test "$ac_res" != no],
201   [test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
202   $5],
203       [$6])dnl
204 AS_VAR_POPDEF([ac_Search])dnl
205 ])