1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4#AC_PREREQ(2.57)
5AC_INIT(mac, 3.99-u4-b5-s7)
6AC_CONFIG_SRCDIR([src/Shared/GlobalFunctions.cpp])
7AC_PREFIX_DEFAULT("/usr")
8
9AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
10AM_CONFIG_HEADER(src/Shared/config.h)
11AM_MAINTAINER_MODE
12
13# Checks for programs.
14CXXFLAGS="$CXXFLAGS -O3 -Wall -pedantic -Wno-long-long"
15AC_PROG_CXX
16AC_PROG_CC
17AC_PROG_LIBTOOL
18AC_PROG_MAKE_SET
19
20AM_MAINTAINER_MODE
21
22CONFIGURE_STYLE=gnu
23
24# Checks for libraries.
25
26# Checks for header files.
27AC_HEADER_STDC
28AC_CHECK_HEADERS([fcntl.h memory.h stdlib.h string.h sys/ioctl.h sys/time.h unistd.h])
29
30# Checks for typedefs, structures, and compiler characteristics.
31AC_C_CONST
32AC_TYPE_SIZE_T
33AC_C_INLINE
34
35# Checks for library functions.
36AC_FUNC_MEMCMP
37AC_FUNC_STAT
38#AC_CHECK_FUNCS([ftruncate memmove memset strrchr strstr])
39
40# Checks for whether the architecture is in big endian or not.
41# will define WORDS_BIGENDIAN if the arch is in big endian.
42AC_C_BIGENDIAN
43
44AC_CHECK_FUNCS(wcscasecmp)
45
46# AC_SEARCH_LIBS (nanosleep, [rt,posix4])
47# copied from videolan
48AC_CHECK_FUNC(nanosleep,,[
49  AC_CHECK_LIB(rt,nanosleep,LIBS="${LIBS} -lrt",[
50    AC_CHECK_LIB(posix4,nanosleep,LIBS="${LIBS} -lposix4")
51  ])
52])
53
54AC_MSG_CHECKING(for assembly enabled)
55AC_ARG_ENABLE(assembly,
56  [  --enable-assembly=yes,no      enable assembly or not],
57  assembly="$enableval", assembly="yes")
58if test "$assembly" = "yes"; then
59  AC_MSG_RESULT(yes)
60else
61  AC_MSG_RESULT(no)
62fi
63
64AM_CONDITIONAL(ENABLE_ASSEMBLY, test "$assembly" = "yes")
65
66if test "$assembly" = "yes"; then
67YASM=
68AC_PATH_PROG(YASM, yasm, "not found")
69fi
70
71AC_MSG_CHECKING([for some Win32 platform])
72case "$host" in
73  *-*-mingw*|*-*-cygwin*)
74    os_win=yes
75    ;;
76  *)
77    os_win=no
78    ;;
79esac
80AC_MSG_RESULT([$os_win])
81
82if test "$os_win" != "yes"; then
83  AC_DEFINE(BUILD_CROSS_PLATFORM,,[Build cross platform])
84fi
85
86AM_CONDITIONAL(OS_WIN, test "$os_win" = "yes")
87
88case "$host_os" in
89  *bsd*|linux*|beos|irix*|solaris*)
90    YASM_FORMAT="-f elf"
91    ;;
92  [[cC]][[yY]][[gG]][[wW]][[iI]][[nN]]*|mingw32*|mks*)
93    YASM_FORMAT="-f win32"
94    ;;
95esac
96
97case "$host" in
98  i386-*-* | i486-*-* | i586-*-* | i686-*-* | i86pc-*-*)
99    arch_type=X86
100    YASM_ARCH="-m x86"
101
102    AC_DEFINE(ARCH_X86,,[Architecture is x86])
103    ;;
104  x86_64-*-*)
105    arch_type=X86_64
106    YASM_ARCH="-m amd64"
107
108    AC_DEFINE(ARCH_X86_64,,[Architecture is x86_64])
109    ;;
110  powerpc-*-* )
111    arch_type=PowerPC
112
113    AC_DEFINE(ARCH_PPC,,[Architecture is powerpc])
114    ;;
115  sparc-*-* )
116    arch_type=SPARC
117
118    AC_DEFINE(ARCH_SPARC,,[Architecture is sparc])
119    ;;
120  *)
121    arch_type=other
122    ;;
123esac
124
125AM_CONDITIONAL(HAS_YASM, test "x$YASM" != "x")
126
127AM_CONDITIONAL(ARCH_X86, test "$arch_type" = "X86")
128AM_CONDITIONAL(ARCH_X86_64, test "$arch_type" = "X86_64")
129AM_CONDITIONAL(ARCH_SPARC, test "$arch_type" = "SPARC")
130AM_CONDITIONAL(ARCH_PPC, test "$arch_type" = "PowerPC")
131
132
133if test "x$YASM" != "x"; then
134  AC_MSG_RESULT("enable_assembly = yes")
135  AC_DEFINE(ENABLE_ASSEMBLY,,[with assembly enabled])
136else
137  AC_MSG_RESULT("enable_assembly = no")
138  assembly=no;
139fi
140
141AC_SUBST(YASM_ARCH)
142AC_SUBST(YASM_FORMAT)
143
144
145AC_CHECK_SIZEOF([int *])
146case "$ac_cv_sizeof_int_p" in
147     8)
148        AC_DEFINE(IS_64BIT,,[64bit])
149	;;
150esac
151
152AC_OUTPUT([Makefile src/Makefile
153			  src/Console/Makefile
154			  src/Shared/Makefile
155			  src/MACLib/Makefile
156			  src/MACLib/Assembly/Makefile
157			  src/Examples/Makefile
158			  src/Examples/Analyze/Makefile
159			  src/Examples/Analyze/Sample1/Makefile
160			  ])
161
162AC_MSG_RESULT([
163Build options:
164  $PACKAGE			$VERSION
165  archtecture		$arch_type
166  Win			$os_win
167  enable-assembly	$assembly
168])
169if test "$assembly" = "yes"; then
170AC_MSG_RESULT([
171  Yasm			$YASM
172  YASM_ARCH		$YASM_ARCH
173  YASM_FORMAT		$YASM_FORMAT
174])
175fi
176