summaryrefslogtreecommitdiff
path: root/configure.ac
blob: d523239d3e080dbdb99e54247f07fa5197c0b8cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
AC_PREREQ([2.71])

AC_LIBMPU_HEADLINE([libmpu], [MPU Emulation Library],dnl
[LIBMPU_VERSION], [configure.ac],dnl
[Copyright (c) 1999-2024 Andrey V.Kosteltsev])dnl


AC_INIT([MPU Library],[1.0.15],[Andrey V.Kosteltsev <support@radix-linux.su>],[libmpu],[https://radix-linux.su])

AC_MSG_CFG_PART(Getting the canonical system type)
dnl
dnl NOTE: Следующие вызовы должны осуществляться строго до
dnl       вызова AM_INIT_AUTOMAKE .
dnl
dnl Для библиотеки достаточно вызвать AC_CANONICAL_HOST и при этом
dnl будут определены build_alias и host_alias. Однако опция --target
dnl будет запрещена.
dnl
dnl Для программ достаточно задать AC_CANONICAL_TARGET и при этом
dnl будут определены build_alias, host_alias и target_alias. Естественно
dnl будут доступны все три опции: --build, --host, и --target .
dnl

AC_CANONICAL_HOST
AC_CANONICAL_TARGET
AC_USE_SYSTEM_EXTENSIONS

dnl Должна вызываться строго после AC_CANONICAL_TARGET .
AC_ARG_PROGRAM

AC_MSG_CFG_PART(Init Automake environment)
AM_INIT_AUTOMAKE([dist-xz no-dist-gzip])

AC_CONFIG_SRCDIR(acsite.m4)
AC_CONFIG_HEADERS(config.h)
AC_CONFIG_MACRO_DIRS([m4])

AC_MSG_CFG_PART(Test for GNU Compiler Colection)
AC_PROG_CC
if test $ac_cv_c_compiler_gnu != yes; then
   AC_MSG_ERROR([
********   ${TB}The MPU Library should be compiled using the GNU compiler only.${TN}])
fi
AC_SUBST(cross_compiling)
AC_PROG_CPP

AC_MSG_CFG_PART(Test for alias attribute)
LIBMPU_ALIAS_ATTRIBUTE

AC_MSG_CFG_PART(Test for hidden visibility attribute)
LIBMPU_HIDDEN_VISIBILITY_ATTRIBUTE

AC_MSG_CFG_PART(Test for Target Machine Data Types)
AC_GCC_TYPES
AC_MSG_CFG_PART(Test for Target Machine Size of Data Types)
AC_GCC_SIZEOF_TYPES
AC_GCC_WIDTH_OF_TYPES
AC_MSG_CFG_PART(Test for Target Machine Byte Order)
AC_GCC_BYTE_ORDER
AC_GCC_FLOAT_WORD_ORDER
AC_MSG_CFG_PART(Test for Target Machine Programming Model)
AC_GCC_PROGRAMMING_MODEL
AC_MSG_CFG_PART(Test for Target Machine Register Width)
AC_GCC_REGISTER_WIDTH

AC_MSG_CFG_PART(Test for GNU Binutils)
LIBMPU_PROG_BINUTILS

AC_MSG_CFG_PART(Test how to build C programs using POSIX threads)
AX_PTHREAD([
   LIBS="$PTHREAD_LIBS $LIBS"
   CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
   CC="$PTHREAD_CC"])

AC_MSG_CFG_PART(Test for GNU Source)
AC_USE_SYSTEM_EXTENSIONS

if test $host != $build; then
  AC_MSG_CFG_PART(Test for Build Machile Compiler)
  AC_PROG_BUILD_CC
  AC_PATH_PROG_BUILD_STRIP_S
fi

AC_SUBST(BUILD_CFLAGS)
AC_SUBST(BUILD_LDFLAGS)
AC_ARG_VAR([BUILD_CC],[Build C compiler command])
AC_ARG_VAR([BUILD_CFLAGS],[Build C compiler flags])
AC_ARG_VAR([BUILD_LDFLAGS],[Build linker flags, e.g. -L<lib dir> if you have libraries in a
                            nonstandard directory <lib dir>])

AC_MSG_CFG_PART(Test for GCC builtin functions)
AX_GCC_BUILTIN([__builtin_popcount])
AX_GCC_BUILTIN([__builtin_parity])

AC_MSG_CFG_PART(Test for GNU Gettext)
AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_VERSION

AC_MSG_CFG_PART(Test for GNU libtool)
LT_PREREQ([2.4.6])
LT_INIT
AC_SUBST([LIBTOOL_DEPS])

AC_MSG_CFG_PART(Test for libtool VERSION Information)
AC_LIBMPU_LT_VERSION_INFO

AC_MSG_CFG_PART(Test for LD_LIBRARY_PATH Environment Variable)
AC_LD_LIBRARY_PATH

dnl ============================================================
dnl Arguments to specify presence of other packages/features:
dnl ============================================================
AC_MSG_CFG_PART(Setting a limit of the real number's size)
AC_ARG_WITH([headers],
  AS_HELP_STRING([--with-headers=PATH],[location of system headers to use
                 (for example /usr/src/linux/include)
                 @<:@default=compiler default@:>@]),
  [sysheaders=$withval],
  [sysheaders=''])
AC_SUBST(sysheaders)

AC_ARG_WITH([real-io-limit],
AS_HELP_STRING([],[])
AS_HELP_STRING([--with-real-io-limit=SIZE_OF_REAL_NUMBER_IN_BITS],[maximum size of real numbers in bits for input/output(IO) operations.
                  Only the following values of argument are admissible:])
dnl AS_HELP_STRING([],[])
  AS_HELP_STRING([],[1024, 2048, 4096, 8192, 16384, 32768, 65536.])
dnl AS_HELP_STRING([],[])
AS_HELP_STRING([],[Maximum value is 65536. @<:@default=65536@:>@]),
  [real_io_limit=$withval],
  [real_io_limit=65536])
case $real_io_limit in
   1024) ;;
   2048) ;;
   4096) ;;
   8192) ;;
  16384) ;;
  32768) ;;
  65536) ;;
      *)
AC_MSG_WARN([
********   ${TB}Invalid value of real_io_limit: $real_io_limit${TN}
********   ${TB}for real number IO operations.${TN}
********   ${TB}The value of real_io_limit is set to 65536.${TN}])
    real_io_limit=65536
         ;;
esac

AC_ARG_WITH([real-math-f-limit],
AS_HELP_STRING([],[])
AS_HELP_STRING([--with-real-math-f-limit=SIZE_OF_REAL_NUMBER_IN_BITS],[maximum size of real numbers in bits for mathematic functions.
                This value has a higher priority than the value REAL_IO_LIMIT,
                so])
dnl AS_HELP_STRING([],[])
  AS_HELP_STRING([],[if real_io_limit < real_math_f_limit ; then])
    AS_HELP_STRING([],[real_io_limit = real_math_f_limit])
  AS_HELP_STRING([],[fi])
dnl AS_HELP_STRING([],[])
AS_HELP_STRING([],[Only the following values of argument are admissible:])
dnl AS_HELP_STRING([],[])
  AS_HELP_STRING([],[1024, 2048, 4096, 8192, 16384.])
dnl AS_HELP_STRING([],[])
AS_HELP_STRING([],[Maximum value is 16384. @<:@default=16384@:>@])
AS_HELP_STRING([],[]),
  [real_math_f_limit=$withval],
  [real_math_f_limit=16384])
case $real_math_f_limit in
   1024) ;;
   2048) ;;
   4096) ;;
   8192) ;;
  16384) ;;
      *)
AC_MSG_WARN([
********   ${TB}Invalid value of real_math_f_limit: $real_math_f_limit${TN}
********   ${TB}for mathematic operations.${TN}
********   ${TB}The value of real_math_f_limit is set to 16384.${TN}])
    real_math_f_limit=16384
         ;;
esac

test $real_io_limit -lt $real_math_f_limit && real_io_limit=$real_math_f_limit

AC_MSG_CHECKING([the maximum size of real numbers for IO operations])
AC_MSG_RESULT([${TB}$real_io_limit${TN}])
AC_MSG_CHECKING([the maximum size of real numbers for mathematic operations])
AC_MSG_RESULT([${TB}$real_math_f_limit${TN}])

AC_SUBST(LIBMPU_REAL_IO_LIMIT, $real_io_limit)
AC_SUBST(LIBMPU_REAL_MATH_F_LIMIT, $real_math_f_limit)
AC_SUBST(LIBMPU_REAL_MAX_WIDTH, $real_io_limit)



dnl
dnl End of arguments to specify other packages/features.
dnl ============================================================



dnl ============================================================
dnl Locate tools:
dnl ============================================================

AC_MSG_CFG_PART(Test for Header files)
dnl
dnl  Check for system header files.
dnl  =============================
dnl  /* GetText частично проверил. Но мы делаем для себя. */
AC_CHECK_INCLUDES_DEFAULT
AC_PROG_EGREP

AC_CHECK_HEADERS( locale.h )
AC_CHECK_HEADERS( sys/types.h sys/stat.h stdlib.h stddef.h )
AC_CHECK_HEADERS( memory.h string.h strings.h )
AC_CHECK_HEADERS( inntypes.h stdint.h unistd.h )
AC_CHECK_HEADERS( fcntl.h errno.h )
AC_CHECK_HEADERS( sys/file.h )
AC_CHECK_HEADERS( sys/uio.h )
AC_CHECK_HEADERS( sys/wait.h )
AC_CHECK_HEADERS( stdarg.h )
AC_CHECK_HEADERS( sys/time.h )
AC_CHECK_HEADERS( limits.h )
AC_CHECK_HEADERS( endian.h )
AC_CHECK_HEADERS_ONCE([sys/time.h])


AC_MSG_CFG_PART(Test for Libc functions)
dnl
dnl  Check for glibc funcs.
dnl  =============================
dnl  /* GetText частично проверил. Но мы делаем для себя. */
AC_CHECK_FUNCS([iconv putenv setenv setlocale])


# TODO: check programs


test -n "$critic_missing" && AC_MSG_ERROR([
********   ${TB}These critical programs are missing or too old: $critic_missing${TN}
********   ${TB}Check the INSTALL file for required versions.${TN}])

test -n "$aux_missing" && AC_MSG_WARN([
********   ${TB}These auxiliary programs are missing or too old: $aux_missing${TN}
********   ${TB}some features will be disabled.${TN}
********   ${TB}Check the INSTALL file for required versions.${TN}])

dnl
dnl End of locate tools:
dnl ============================================================


dnl ============================================================
dnl Define variables accoring to arguments:
dnl ============================================================

# if using special system headers, find out the compiler's sekrit
# header directory and add that to the list.  NOTE: Only does the
# right thing on a system that doesn't need fixincludes.
# (Not presently a problem.)
if test -n "$sysheaders"; then
  SYSINCLUDES=-nostdinc
  for d in include include-fixed; do
    i=`$CC -print-file-name="$d"` && test "x$i" != x && test "x$i" != "x$d" &&
    SYSINCLUDES="$SYSINCLUDES -isystem $i"
  done
  SYSINCLUDES="$SYSINCLUDES -isystem `echo $sysheaders | sed 's/:/ -isystem /g'`"
fi
AC_SUBST(SYSINCLUDES)

dnl
dnl End of variables definition.
dnl ============================================================


AC_MSG_CFG_PART(OUTPUT Substitutions)
AC_CONFIG_FILES([ po/Makefile.in
                  Makefile
                  mpu/Makefile
                  include/libmpu.h
                  mpu-config
                  mpu.pc
                  man/Makefile
                  man/ru/Makefile])
AC_OUTPUT

if test -f "config.h"; then
  echo ""
  echo "Now you can run:"
  echo "  \`${TB}make${TN}'           to compile,"
  echo "  \`${TB}make install${TN}'   to make and install ${TB}libmpu${TN},"
  echo "  \`${TB}make dist${TN}'      to create distributable tarballs, or"
  echo "  \`${TB}make distclean${TN}' to clean before configure for another target."
  echo "Good luck."
  echo ""
fi