]>
Commit | Line | Data |
---|---|---|
6a161fa9 | 1 | # Process this file with autoconf to produce a configure script. |
2 | ||
3 | # Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org> | |
4 | # | |
5 | # This configure.ac is free software; the author | |
6 | # gives unlimited permission to copy and/or distribute it, | |
7 | # with or without modifications, as long as this notice is preserved. | |
8 | # | |
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without | |
11 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A | |
12 | # PARTICULAR PURPOSE. | |
13 | ||
14 | AC_INIT(PUPA, 0.6, [okuji@enbug.org]) | |
15 | AC_PREREQ(2.53) | |
16 | AC_CONFIG_SRCDIR([include/pupa/dl.h]) | |
17 | AC_CONFIG_HEADER([config.h]) | |
18 | ||
19 | # Checks for build and host systems. | |
20 | AC_CANONICAL_BUILD | |
21 | AC_CANONICAL_HOST | |
22 | ||
23 | case "$host_cpu" in | |
24 | i[[3456]]86) host_cpu=i386 ;; | |
25 | *) AC_MSG_ERROR([unsupported CPU type]) ;; | |
26 | esac | |
27 | ||
28 | case "$host_cpu"-"$host_vendor" in | |
29 | i386-*) host_vendor=pc ;; | |
30 | *) AC_MSG_ERROR([unsupported machine type]) ;; | |
31 | esac | |
32 | ||
33 | AC_SUBST(host_cpu) | |
34 | AC_SUBST(host_vendor) | |
35 | ||
36 | # Checks for programs. | |
37 | if test "x$CFLAGS" = x; then | |
38 | default_CFLAGS=yes | |
39 | fi | |
40 | ||
41 | AC_PROG_CC | |
42 | ||
43 | # Must be GCC. | |
44 | test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required]) | |
45 | ||
46 | if test "x$default_CFLAGS" = xyes; then | |
47 | # debug flags. | |
48 | tmp_CFLAGS="-Wall -W -g" | |
49 | ||
50 | # optimization flags. | |
51 | AC_CACHE_CHECK([whether optimization for size works], size_flag, [ | |
52 | CFLAGS=-Os | |
53 | AC_TRY_COMPILE(, , size_flag=yes, size_flag=no) | |
54 | ]) | |
55 | if test "x$size_flag" = xyes; then | |
56 | tmp_CFLAGS="$tmp_CFLAGS -Os" | |
57 | else | |
58 | tmp_CFLAGS="$tmp_CFLAGS -O2 -fno-strength-reduce -fno-unroll-loops" | |
59 | fi | |
60 | ||
61 | # Force no alignment to save space on i386. | |
62 | if test "x$host_cpu" = xi386; then | |
63 | AC_CACHE_CHECK([whether -falign-loops works], [falign_loop_flag], [ | |
64 | CFLAGS="-falign-loops=1" | |
65 | AC_TRY_COMPILE(, , [falign_loop_flag=yes], [falign_loop_flag=no]) | |
66 | ]) | |
67 | ||
68 | if test "x$falign_loop_flag" = xyes; then | |
69 | tmp_CFLAGS="$tmp_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1" | |
70 | else | |
71 | tmp_CFLAGS="$tmp_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1" | |
72 | fi | |
73 | fi | |
74 | ||
75 | CFLAGS="$tmp_CFLAGS" | |
76 | fi | |
77 | AC_SUBST(CFLAGS) | |
78 | ||
79 | # Defined in aclocal.m4. | |
80 | pupa_ASM_USCORE | |
81 | pupa_CHECK_START_SYMBOL | |
82 | pupa_CHECK_BSS_START_SYMBOL | |
83 | pupa_CHECK_END_SYMBOL | |
84 | ||
85 | if test "x$host_cpu" = xi386; then | |
86 | pupa_I386_ASM_PREFIX_REQUIREMENT | |
87 | pupa_I386_ASM_ADDR32 | |
88 | pupa_I386_ASM_ABSOLUTE_WITHOUT_ASTERISK | |
89 | fi | |
90 | ||
91 | ||
92 | AC_PROG_INSTALL | |
93 | AC_PROG_MAKE_SET | |
94 | AC_CHECK_TOOL(OBJCOPY, objcopy) | |
95 | pupa_PROG_OBJCOPY_ABSOLUTE | |
96 | AC_CHECK_TOOL(STRIP, strip) | |
97 | AC_CHECK_TOOL(NM, nm) | |
98 | ||
99 | # This is not a "must". | |
100 | AC_PATH_PROG(RUBY, ruby) | |
101 | ||
102 | # For cross-compiling. | |
103 | if test "x$build" = "x$host"; then | |
104 | BUILD_CC="$CC" | |
105 | AC_SUBST(BUILD_CC) | |
106 | else | |
107 | AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc], | |
108 | [AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])]) | |
109 | fi | |
110 | ||
111 | # Test the C compiler for the build environment. | |
112 | pupa_tmp_CC="$CC" | |
113 | CC="$BUILD_CC" | |
114 | AC_C_BIGENDIAN | |
115 | AC_CHECK_SIZEOF(void *) | |
116 | AC_CHECK_SIZEOF(long) | |
117 | CC="$pupa_tmp_CC" | |
118 | ||
119 | # Output files. | |
120 | AC_CONFIG_LINKS([include/pupa/cpu:include/pupa/$host_cpu | |
121 | include/pupa/machine:include/pupa/$host_cpu/$host_vendor]) | |
122 | AC_CONFIG_FILES([Makefile]) | |
123 | AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h]) | |
124 | AC_OUTPUT |