summaryrefslogtreecommitdiff
path: root/configure.ac
blob: ef4f6e9fb95a4fd486a7068bbb057294ea70e684 (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
AC_PREREQ([2.69])

m4_include([acsite.m4])

AC_INIT([mcpu-cpp], [1.0.3], [], [mcpu-cpp])

AC_MCPU_CPP_REQUIRE_BASH

AC_MCPU_CPP_HEADLINE([mcpu-cpp], [MCPU Languages Preprocessor], [MCPU_CPP_VERSION],dnl
[Copyright (c) 1998-2026 Andrey V.Kosteltsev])dnl

AC_MSG_CFG_PART(Getting the canonical system type)
AC_CANONICAL_HOST

AC_MSG_CFG_PART(Init Automake environment)
AC_CONFIG_SRCDIR([src/main.c])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([foreign dist-xz no-dist-gzip subdir-objects])

dnl With the project convention --prefix=/usr, system configuration belongs
dnl in /etc rather than /usr/etc unless the caller explicitly selects another
dnl sysconfdir.
if test "x$sysconfdir" = 'x${prefix}/etc'; then
  if test "x$prefix" = xNONE || test "x$prefix" = x/usr; then
    sysconfdir=/etc
  fi
fi

AC_MSG_CFG_PART(Test for GNU Compiler Collection)
AC_USE_SYSTEM_EXTENSIONS
AC_PROG_CC
AC_PROG_LN_S
MCPU_CPP_REQUIRE_GCC

AC_MSG_CFG_PART(Test for LibMPUIO)
#MCPU_CPP_CHECK_LIBMPUIO
dnl ============================================================
dnl Check for LibMPU
dnl ============================================================
AC_CHECK_LIBMPU(
  [1.0.25],
  [yes],
  [
    AC_DEFINE(
      [HAVE_LIBMPU],
      [1],
      [Define to 1 if LibMPU is available.]
    )
    LIBMPU_VERSION=`$LIBMPU_CONFIG --version 2>/dev/null`
    AC_SUBST([LIBMPU_VERSION])
  ],
  [
    AC_MSG_ERROR([LibMPU version 1.0.25 or later is required.])
  ]
)

dnl ============================================================
dnl Check for LibMPUIO
dnl ============================================================
AC_CHECK_LIBMPUIO(
  [1.0.4],
  [yes],
  [
    AC_DEFINE(
      [HAVE_LIBMPUIO],
      [1],
      [Define to 1 if LibMPUIO is available.]
    )
    LIBMPUIO_VERSION=`$LIBMPUIO_CONFIG --version 2>/dev/null`
    AC_SUBST([LIBMPUIO_VERSION])
  ],
  [
    AC_MSG_ERROR([LibMPUIO version 1.0.4 or later is required.])
  ]
)

AC_MSG_CFG_PART(Test for LibMPU ABI)
MCPU_CPP_CHECK_LIBMPU_ABI

AC_MSG_CFG_PART(Define MCPU installation layout)

mcpu_cpp_prefix="$prefix"
if test "x$mcpu_cpp_prefix" = xNONE; then
  mcpu_cpp_prefix="$ac_default_prefix"
fi

mcpu_cpp_exec_prefix="$exec_prefix"
if test "x$mcpu_cpp_exec_prefix" = xNONE; then
  mcpu_cpp_exec_prefix="$mcpu_cpp_prefix"
fi

mcpu_cpp_save_prefix="$prefix"
mcpu_cpp_save_exec_prefix="$exec_prefix"
prefix="$mcpu_cpp_prefix"
exec_prefix="$mcpu_cpp_exec_prefix"
eval mcpu_cpp_bindir="\"$bindir\""
eval mcpu_cpp_libdir="\"$libdir\""
eval mcpu_cpp_sysconfdir="\"$sysconfdir\""
prefix="$mcpu_cpp_save_prefix"
exec_prefix="$mcpu_cpp_save_exec_prefix"

mcpu_cpp_root="$mcpu_cpp_libdir/mcpu"
mcpu_cpp_private_bindir="$mcpu_cpp_root/bin"
mcpu_cpp_private_etcdir="$mcpu_cpp_root/etc"
mcpu_cpp_private_includedir="$mcpu_cpp_root/include"

MCPU_CPP_ROOT="$mcpu_cpp_root"
MCPU_CPP_BINDIR="$mcpu_cpp_private_bindir"
MCPU_CPP_ETCDIR="$mcpu_cpp_private_etcdir"
MCPU_CPP_INCLUDEDIR="$mcpu_cpp_private_includedir"
AC_SUBST([MCPU_CPP_ROOT])
AC_SUBST([MCPU_CPP_BINDIR])
AC_SUBST([MCPU_CPP_ETCDIR])
AC_SUBST([MCPU_CPP_INCLUDEDIR])

mcpu_cpp_public_link_target="$mcpu_cpp_private_bindir/mcpu-cpp"
case "$mcpu_cpp_bindir:$mcpu_cpp_private_bindir" in
  "$mcpu_cpp_exec_prefix"/*:"$mcpu_cpp_exec_prefix"/*)
    mcpu_cpp_bindir_rel=${mcpu_cpp_bindir#"$mcpu_cpp_exec_prefix/"}
    mcpu_cpp_target_rel=${mcpu_cpp_private_bindir#"$mcpu_cpp_exec_prefix/"}
    mcpu_cpp_up=
    mcpu_cpp_rest=$mcpu_cpp_bindir_rel
    while :; do
      mcpu_cpp_up="../$mcpu_cpp_up"
      case "$mcpu_cpp_rest" in
        */*) mcpu_cpp_rest=${mcpu_cpp_rest#*/} ;;
        *) break ;;
      esac
    done
    mcpu_cpp_public_link_target="$mcpu_cpp_up$mcpu_cpp_target_rel/mcpu-cpp"
    ;;
esac
MCPU_CPP_PUBLIC_LINK_TARGET="$mcpu_cpp_public_link_target"
AC_SUBST([MCPU_CPP_PUBLIC_LINK_TARGET])

AC_DEFINE_UNQUOTED([MCPU_CPP_SYSTEM_CONFIG_FILE],
                   ["$mcpu_cpp_sysconfdir/mcpu/mcpu-cpp.conf"],
                   [Optional system-wide mcpu-cpp configuration override.])


AC_MSG_CFG_PART(OUTPUT Substitutions)
AC_CONFIG_FILES([
  Makefile
  src/Makefile
  tests/Makefile
  doc/Makefile
  man/Makefile
  man/ru/Makefile
  etc/Makefile
  etc/mcpu-cpp.conf
])
AC_OUTPUT

AC_MSG_CFG_PART(Configuration summary)
AC_MSG_NOTICE([mcpu-cpp configuration:])
AC_MSG_NOTICE([  version               : $PACKAGE_VERSION])
AC_MSG_NOTICE([  host                  : $host])
AC_MSG_NOTICE([  prefix                : $prefix])
AC_MSG_NOTICE([  install MCPU root     : $mcpu_cpp_root])
AC_MSG_NOTICE([  runtime config        : <runtime-root>/etc/mcpu-cpp.conf])
AC_MSG_NOTICE([  system override       : $mcpu_cpp_sysconfdir/mcpu/mcpu-cpp.conf])
AC_MSG_NOTICE([  runtime MCPU include  : <runtime-root>/include])
AC_MSG_NOTICE([  public command        : $mcpu_cpp_bindir/mcpu-cpp])
AC_MSG_NOTICE([  public symlink        : $mcpu_cpp_public_link_target])
AC_MSG_NOTICE([  mpuio-config          : $LIBMPUIO_CONFIG])
AC_MSG_NOTICE([  LibMPU version        : $LIBMPU_VERSION])
AC_MSG_NOTICE([  LibMPUIO version      : $LIBMPUIO_VERSION])
AC_MSG_NOTICE([  LibMPUIO CFLAGS       : $LIBMPUIO_CFLAGS])
AC_MSG_NOTICE([  LibMPUIO LDFLAGS      : $LIBMPUIO_LDFLAGS])
AC_MSG_NOTICE([  LibMPUIO LIBS         : $LIBMPUIO_LIBS])
AC_MSG_NOTICE([  LibMPU real I/O limit : $MCPU_CPP_MPU_REAL_IO_LIMIT])
AC_MSG_NOTICE([  LibMPU math fn limit  : $MCPU_CPP_MPU_MATH_FN_LIMIT])
AC_MSG_NOTICE([  LibMPU int max width  : $MCPU_CPP_MPU_INT_MAX_WIDTH])
AC_MSG_NOTICE([  LibMPU byte order     : $MCPU_CPP_MPU_BYTE_ORDER])
AC_MSG_NOTICE([  LibMPU word order     : $MCPU_CPP_MPU_WORD_ORDER])
AC_MSG_NOTICE([  machine reg width     : $MCPU_CPP_MPU_REGISTER_WIDTH])
AC_MSG_NOTICE([  size_t width          : $MCPU_CPP_SIZE_WIDTH])
AC_MSG_NOTICE([  ssize_t width         : $MCPU_CPP_SSIZE_WIDTH])

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}mcpu-cpp${TN},"
  echo "  \`${TB}make dist${TN}'      to create distributable tarballs, or"
  echo "  \`${TB}make distclean${TN}' to clean before configure for another target."
  echo "Enjoy."
  echo ""
fi