summaryrefslogtreecommitdiff
path: root/exec/configure.ac
blob: 9008c84f6a69c8a02734d1175c736206b994eaf7 (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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
dnl  Autoconf script for GNU Emacs's exec library.
dnl To rebuild the 'configure' script from this, execute the command
dnl	autoconf
dnl in the directory containing this script.
dnl If you changed any AC_DEFINES, also run autoheader.
dnl
dnl Copyright (C) 2023-2024 Free Software Foundation, Inc.
dnl
dnl  This file is part of GNU Emacs.
dnl
dnl  GNU Emacs is free software: you can redistribute it and/or modify
dnl  it under the terms of the GNU General Public License as published by
dnl  the Free Software Foundation, either version 3 of the License, or
dnl  (at your option) any later version.
dnl
dnl  GNU Emacs is distributed in the hope that it will be useful,
dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
dnl  GNU General Public License for more details.
dnl
dnl  You should have received a copy of the GNU General Public License
dnl  along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.

AC_PREREQ([2.65])
AC_INIT([libexec], [30.0.50], [bug-gnu-emacs@gnu.org], [],
  [https://www.gnu.org/software/emacs/])

AH_TOP([/* Copyright (C) 2024 Free Software Foundation, Inc.

This file is part of GNU Emacs.

GNU Emacs is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.

GNU Emacs is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>. */])

AC_ARG_WITH([reentrancy],
  [AS_HELP_STRING([--with-reentrancy],
    [Generate library which can be used within a signal handler.])],
  [AC_DEFINE([REENTRANT], [1])])

AC_USE_SYSTEM_EXTENSIONS
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL

AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_UINTPTR_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_PID_T

AC_HEADER_STDBOOL
AC_CHECK_FUNCS([getpagesize stpcpy])
AC_CHECK_DECLS([stpcpy])
AC_CHECK_FUNC([process_vm_readv],
  [AC_CHECK_FUNC([process_vm_writev],
    [AC_CHECK_DECL([process_vm_readv],
      [AC_DEFINE([HAVE_PROCESS_VM], [1],
        [Define to 1 if process_vm_readv is available.])],
      [], [[
#include <sys/uio.h>
      ]])])])
AC_CHECK_HEADERS([sys/param.h sys/uio.h])
AC_CHECK_MEMBERS([siginfo_t.si_syscall], [], [],
  [[
#include <signal.h>
  ]])

AH_BOTTOM([
#ifdef HAVE_STDBOOL_H
# include <stdbool.h>
#else
# ifndef HAVE__BOOL
#  ifdef __cplusplus
typedef bool _Bool;
#  else
#   define _Bool signed char
#  endif
# endif
# define bool _Bool
# define false 0
# define true 1
# define __bool_true_false_are_defined 1
#endif

#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif /* HAVE_SYS_PARAM_H */

#ifndef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif /* MAX */

#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif /* MIN */
])

AC_C_BIGENDIAN

AH_TEMPLATE([SYSCALL_HEADER], [Define to header holding system call numbers.])
AH_TEMPLATE([USER_HEADER], [Define to header holding USER_REGS_STRUCT.])
AH_TEMPLATE([USER_REGS_STRUCT], [Define to structure holding user registers.])
AH_TEMPLATE([SYSCALL_NUM_REG], [Define to register holding the system call number.])
AH_TEMPLATE([SYSCALL_ARG_REG], [Define to register holding arg0 to system calls.])
AH_TEMPLATE([SYSCALL_ARG1_REG], [Define to register holding arg1 to system calls.])
AH_TEMPLATE([SYSCALL_ARG2_REG], [Define to register holding arg2 to system calls.])
AH_TEMPLATE([SYSCALL_ARG3_REG], [Define to register holding arg3 to system calls.])
AH_TEMPLATE([SYSCALL_RET_REG], [Define to register holding value of system calls.])
AH_TEMPLATE([STACK_POINTER], [Define to register holding the stack pointer.])
AH_TEMPLATE([EXEC_SYSCALL], [Define to number of the `exec' system call.])
AH_TEMPLATE([USER_WORD], [Define to word type used by tracees.])
AH_TEMPLATE([EXEC_64], [Define to 1 if the system utilizes 64-bit ELF.])
AH_TEMPLATE([STACK_GROWS_DOWNWARDS], [Define to 1 if the stack grows downwards.])
AH_TEMPLATE([ABI_RED_ZONE], [Define to number of reserved bytes past the stack frame.])
AH_TEMPLATE([EXECUTABLE_BASE], [Virtual address for loading PIC executables])
AH_TEMPLATE([INTERPRETER_BASE], [Virtual address for loading PIC interpreters])
AH_TEMPLATE([CLONE_SYSCALL], [Define to number of the `clone' system call.])
AH_TEMPLATE([CLONE3_SYSCALL], [Define to number of the `clone3' system call.])
AH_TEMPLATE([READLINK_SYSCALL], [Define to number of the `readlink' system call.])
AH_TEMPLATE([READLINKAT_SYSCALL], [Define to number of the `readlinkat' system call.])
AH_TEMPLATE([REENTRANT], [Define to 1 if the library is used within a signal handler.])

AC_CANONICAL_HOST

# Check whether or not sys/user exists.  If it doesn't, try
# asm/user.h, and croak if that doesn't exist either.
AS_CASE([$host], [*mips*], [], [*],
  [AC_CHECK_HEADER([sys/user.h], [user_h="<sys/user.h>"],
    [AC_CHECK_HEADER([asm/user.h], [user_h="<asm/user.h>"],
      [AC_MSG_ERROR([Can not find working user.h])])])])

# Look for required tools.

AC_ARG_VAR([M4], [`m4' preprocessor command.])
AC_ARG_VAR([AS], [`as' assembler command.])
AC_ARG_VAR([LD], [`ld' linker command.])

# Check for a working m4.
AC_CHECK_PROGS([M4], [gm4 m4],
  [AC_MSG_ERROR([Cannot find m4])])

# Check for a working assembler.
AC_CHECK_TOOL([AS], [as],
  [AC_MSG_ERROR([Cannot find a working assembler])])

# And ar.
AC_CHECK_TOOL([AR], [ar],
  [AC_MSG_ERROR([Cannot find a working ar])])

# And ld.
AC_CHECK_TOOL([LD], [ld],
  [AC_MSG_ERROR([Cannot find a working linker])])

# Now check if ld is a C compiler.
LDPREFIX=
AC_CACHE_CHECK([whether ld is a C compiler],
  [exec_cv_ld_is_cc],
  [cat <<_ACEOF > conftest.c
AC_LANG_PROGRAM(,)
_ACEOF
   exec_cv_ld_is_cc=yes
   $LD -c conftest.c -o conftest.$OBJEXT >&AS_MESSAGE_LOG_FD 2>&1 \
   || exec_cv_ld_is_cc=no
   rm -f conftest.c conftest.$OBJEXT])

# And if as is a C compiler.
AC_CACHE_CHECK([whether as is a C compiler],
  [exec_cv_as_is_cc],
  [cat <<_ACEOF > conftest.c
AC_LANG_PROGRAM(,)
_ACEOF
   exec_cv_as_is_cc=yes
   $AS -c conftest.c -o conftest.$OBJEXT >&AS_MESSAGE_LOG_FD 2>&1 \
   || exec_cv_as_is_cc=no
   rm -f conftest.c conftest.$OBJEXT])

# If ld is a C compiler, pass `-nostdlib', `-nostartfiles', and
# `-static'.  Also, set LDPREFIX to -Wl,
AS_IF([test "x$exec_cv_ld_is_cc" = "xyes"],
  [LOADERFLAGS="$LOADERFLAGS -nostdlib -nostartfiles -static"
   LDPREFIX=-Wl,])

# If as is a C compiler, add `-c' to ASFLAGS.
AS_IF([test "x$exec_cv_as_is_cc" = "xyes"],
  [ASFLAGS="$ASFLAGS -c"])

AC_DEFUN([exec_CHECK_LINUX_CLONE3],
[
AC_CHECK_DECL([__NR_clone3],
  [AC_DEFINE([CLONE3_SYSCALL], [__NR_clone3])],
  [], [[
#include <asm/unistd.h>
]])
])

AC_DEFUN([exec_CHECK_MIPS_NABI],
[
AC_CACHE_CHECK([whether MIPS NABI calling convention is used],
  [exec_cv_mips_nabi],
  [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <sgidefs.h>
]], [[
#ifndef  __mips64__
#if _MIPS_SIM == _ABIO32
OABI in use.
#endif /* _MIPS_SIM == _ABIO32 */
#endif /* !__mips64__ */
]])], [exec_cv_mips_nabi=yes],
  [exec_cv_mips_nabi=no])])

dnl mips64 systems use N64 calling convention, a variant of nabi
dnl calling convention.
AS_IF([test "x$exec_cv_mips_nabi" != "xno"],
  [AC_DEFINE([MIPS_NABI], [1],
    [Define to 1 if MIPS NABI calling convention is being used.])],
   [OBJS="$OBJS mipsfpu.o"])
])

# Determine the system type and define appropriate macros.
exec_loader=
is_mips=
OBJS="exec.o trace.o"
DADDI_BROKEN=no

AS_CASE([$host], [x86_64-*linux*],
  [AC_CHECK_MEMBER([struct user_regs_struct.rdi],
    [AC_DEFINE([SYSCALL_HEADER], [<asm/unistd.h>])
     AC_DEFINE_UNQUOTED([USER_HEADER], [$user_h])
     AC_DEFINE([USER_REGS_STRUCT], [struct user_regs_struct])
     AC_DEFINE([SYSCALL_NUM_REG], [orig_rax])
     AC_DEFINE([SYSCALL_RET_REG], [rax])
     AC_DEFINE([SYSCALL_ARG_REG], [rdi])
     AC_DEFINE([SYSCALL_ARG1_REG], [rsi])
     AC_DEFINE([SYSCALL_ARG2_REG], [rdx])
     AC_DEFINE([SYSCALL_ARG3_REG], [r10])
     AC_DEFINE([STACK_POINTER], [rsp])
     AC_DEFINE([EXEC_SYSCALL], [__NR_execve])
     AC_DEFINE([USER_WORD], [uintptr_t])
     AC_DEFINE([EXEC_64], [1])
     AC_DEFINE([ABI_RED_ZONE], [128])
     AC_DEFINE([EXECUTABLE_BASE], [0x555555554000])
     AC_DEFINE([INTERPRETER_BASE], [0x600000000000])
     AC_DEFINE([STACK_GROWS_DOWNWARDS], [1])
     AC_DEFINE([CLONE_SYSCALL], [__NR_clone])
     AC_DEFINE([READLINK_SYSCALL], [__NR_readlink])
     AC_DEFINE([READLINKAT_SYSCALL], [__NR_readlinkat])
     exec_CHECK_LINUX_CLONE3
     # Make sure the loader doesn't conflict with other position
     # dependent code.
     LOADERFLAGS="$LOADERFLAGS $LDPREFIX-Ttext=0x200000000000"
     exec_loader=loader-x86_64.s],
    [AC_MSG_ERROR([Missing `rdi' in user_regs_struct])],
    [[
#include $user_h
    ]])], [i[[34567]]86-*linux*],
  [AC_CHECK_MEMBER([struct user_regs_struct.edi],
    [AC_DEFINE([SYSCALL_HEADER], [<asm/unistd.h>])
     AC_DEFINE_UNQUOTED([USER_HEADER], [$user_h])
     AC_DEFINE([USER_REGS_STRUCT], [struct user_regs_struct])
     AC_DEFINE([SYSCALL_NUM_REG], [orig_eax])
     AC_DEFINE([SYSCALL_RET_REG], [eax])
     AC_DEFINE([SYSCALL_ARG_REG], [ebx])
     AC_DEFINE([SYSCALL_ARG1_REG], [ecx])
     AC_DEFINE([SYSCALL_ARG2_REG], [edx])
     AC_DEFINE([SYSCALL_ARG3_REG], [esi])
     AC_DEFINE([STACK_POINTER], [esp])
     AC_DEFINE([EXEC_SYSCALL], [__NR_execve])
     AC_DEFINE([USER_WORD], [uintptr_t])
     AC_DEFINE([EXECUTABLE_BASE], [0x0f000000])
     AC_DEFINE([INTERPRETER_BASE], [0xaf000000])
     AC_DEFINE([STACK_GROWS_DOWNWARDS], [1])
     AC_DEFINE([CLONE_SYSCALL], [__NR_clone])
     AC_DEFINE([READLINK_SYSCALL], [__NR_readlink])
     AC_DEFINE([READLINKAT_SYSCALL], [__NR_readlinkat])
     exec_CHECK_LINUX_CLONE3
     # Make sure the loader doesn't conflict with other position
     # dependent code.
     LOADERFLAGS="$LOADERFLAGS $LDPREFIX-Ttext=0xa0000000"
     exec_loader=loader-x86.s],
    [AC_MSG_ERROR([Missing `edi' in user_regs_struct])],
    [[
#include $user_h
    ]])], [aarch64-*linux*],
  [AC_CHECK_MEMBER([struct user_regs_struct.sp],
    [AC_DEFINE([SYSCALL_HEADER], [<asm/unistd.h>])
     AC_DEFINE_UNQUOTED([USER_HEADER], [$user_h])
     AC_DEFINE([USER_REGS_STRUCT], [struct user_regs_struct])
     AC_DEFINE([SYSCALL_NUM_REG], [[regs[8]]])
     AC_DEFINE([SYSCALL_RET_REG], [[regs[0]]])
     AC_DEFINE([SYSCALL_ARG_REG], [[regs[0]]])
     AC_DEFINE([SYSCALL_ARG1_REG], [[regs[1]]])
     AC_DEFINE([SYSCALL_ARG2_REG], [[regs[2]]])
     AC_DEFINE([SYSCALL_ARG3_REG], [[regs[3]]])
     AC_DEFINE([STACK_POINTER], [sp])
     AC_DEFINE([EXEC_SYSCALL], [__NR_execve])
     AC_DEFINE([USER_WORD], [uintptr_t])
     AC_DEFINE([EXEC_64], [1])
     AC_DEFINE([EXECUTABLE_BASE], [0x3000000000])
     AC_DEFINE([INTERPRETER_BASE], [0x3f00000000])
     AC_DEFINE([STACK_GROWS_DOWNWARDS], [1])
     AC_DEFINE([CLONE_SYSCALL], [__NR_clone])
     # Note that aarch64 has no `readlink'.
     AC_DEFINE([READLINKAT_SYSCALL], [__NR_readlinkat])
     exec_CHECK_LINUX_CLONE3
     # Make sure the loader doesn't conflict with other position
     # dependent code.  ARM places rather significant restrictions on
     # virtual addresses for a 64 bit architecture.
     LOADERFLAGS="$LOADERFLAGS $LDPREFIX-Ttext=0x2000000000"
     exec_loader=loader-aarch64.s],
    [AC_MSG_ERROR([Missing `sp' in user_regs_struct])],
    [[
#include $user_h
    ]])], [arm*linux*eabi* | armv7*linux*],
  [AC_CHECK_MEMBER([struct user_regs.uregs],
    [AC_DEFINE([SYSCALL_HEADER], [<asm/unistd.h>])
     AC_DEFINE_UNQUOTED([USER_HEADER], [$user_h])
     AC_DEFINE([USER_REGS_STRUCT], [struct user_regs])
     AC_DEFINE([SYSCALL_NUM_REG], [[uregs[7]]])
     AC_DEFINE([SYSCALL_RET_REG], [[uregs[0]]])
     AC_DEFINE([SYSCALL_ARG_REG], [[uregs[0]]])
     AC_DEFINE([SYSCALL_ARG1_REG], [[uregs[1]]])
     AC_DEFINE([SYSCALL_ARG2_REG], [[uregs[2]]])
     AC_DEFINE([SYSCALL_ARG3_REG], [[uregs[3]]])
     AC_DEFINE([STACK_POINTER], [[uregs[13]]])
     AC_DEFINE([EXEC_SYSCALL], [__NR_execve])
     AC_DEFINE([USER_WORD], [uintptr_t])
     AC_DEFINE([EXECUTABLE_BASE], [0x0f000000])
     AC_DEFINE([INTERPRETER_BASE], [0x1f000000])
     AC_DEFINE([STACK_GROWS_DOWNWARDS], [1])
     AC_DEFINE([CLONE_SYSCALL], [__NR_clone])
     AC_DEFINE([READLINK_SYSCALL], [__NR_readlink])
     AC_DEFINE([READLINKAT_SYSCALL], [__NR_readlinkat])
     exec_CHECK_LINUX_CLONE3
     LOADERFLAGS="$LOADERFLAGS $LDPREFIX-Ttext=0x20000000"
     exec_loader=loader-armeabi.s],
    [AC_CHECK_MEMBER([struct pt_regs.uregs],
      [AC_DEFINE([SYSCALL_HEADER], [<asm/unistd.h>])
       AC_DEFINE_UNQUOTED([USER_HEADER], [<asm/ptrace.h>])
       AC_DEFINE([USER_REGS_STRUCT], [struct pt_regs])
       AC_DEFINE([SYSCALL_NUM_REG], [[uregs[7]]])
       AC_DEFINE([SYSCALL_RET_REG], [[uregs[0]]])
       AC_DEFINE([SYSCALL_ARG_REG], [[uregs[0]]])
       AC_DEFINE([SYSCALL_ARG1_REG], [[uregs[1]]])
       AC_DEFINE([SYSCALL_ARG2_REG], [[uregs[2]]])
       AC_DEFINE([SYSCALL_ARG3_REG], [[uregs[3]]])
       AC_DEFINE([STACK_POINTER], [[uregs[13]]])
       AC_DEFINE([EXEC_SYSCALL], [__NR_execve])
       AC_DEFINE([USER_WORD], [uintptr_t])
       AC_DEFINE([EXECUTABLE_BASE], [0x0f000000])
       AC_DEFINE([INTERPRETER_BASE], [0x1f000000])
       AC_DEFINE([STACK_GROWS_DOWNWARDS], [1])
       AC_DEFINE([CLONE_SYSCALL], [__NR_clone])
       AC_DEFINE([READLINK_SYSCALL], [__NR_readlink])
       AC_DEFINE([READLINKAT_SYSCALL], [__NR_readlinkat])
       exec_CHECK_LINUX_CLONE3
       LOADERFLAGS="$LOADERFLAGS $LDPREFIX-Ttext=0x20000000"
       exec_loader=loader-armeabi.s],
      [AC_MSG_ERROR([Missing `uregs' in user_regs_struct or pt_regs])],
      [[
#include <asm/ptrace.h>
      ]])],
    [[
#include $user_h
    ]])], [mipsel*linux*],
  [AC_DEFINE([SYSCALL_HEADER], [<asm/unistd.h>])
   AC_DEFINE([USER_HEADER], ["mipsel-user.h"])
   AC_DEFINE([USER_REGS_STRUCT], [struct mipsel_regs])
   AC_DEFINE([SYSCALL_NUM_REG], [[gregs[2]]]) # v0
   AC_DEFINE([SYSCALL_RET_REG], [[gregs[4]]]) # a0
   AC_DEFINE([SYSCALL_ARG_REG], [[gregs[4]]]) # a0
   AC_DEFINE([SYSCALL_ARG1_REG], [[gregs[5]]]) # a1
   AC_DEFINE([SYSCALL_ARG2_REG], [[gregs[4]]]) # a2
   AC_DEFINE([SYSCALL_ARG3_REG], [[gregs[5]]]) # a3
   AC_DEFINE([STACK_POINTER], [[gregs[29]]]) # sp
   AC_DEFINE([EXEC_SYSCALL], [__NR_execve])
   AC_DEFINE([USER_WORD], [uintptr_t])
   AC_DEFINE([EXECUTABLE_BASE], [0x0f000000])
   AC_DEFINE([INTERPRETER_BASE], [0x1f000000])
   AC_DEFINE([STACK_GROWS_DOWNWARDS], [1])
   AC_DEFINE([CLONE_SYSCALL], [__NR_clone])
   AC_DEFINE([READLINK_SYSCALL], [__NR_readlink])
   AC_DEFINE([READLINKAT_SYSCALL], [__NR_readlinkat])
   AC_CHECK_DECL([_MIPS_SIM], [exec_CHECK_MIPS_NABI],
     [AC_MSG_ERROR([_MIPS_SIM could not be determined]),
     [[
#include <sgidefs.h>
]]])
   exec_CHECK_LINUX_CLONE3
   LOADERFLAGS="$LOADERFLAGS $LDPREFIX-Ttext=0x20000000"
   is_mips=yes
   exec_loader=loader-mipsel.s], [mips64el*linux*],
  [AC_DEFINE([SYSCALL_HEADER], [<asm/unistd.h>])
   AC_DEFINE([USER_HEADER], ["mipsel-user.h"])
   AC_DEFINE([USER_REGS_STRUCT], [struct mipsel_regs])
   AC_DEFINE([SYSCALL_NUM_REG], [[gregs[2]]]) # v0
   AC_DEFINE([SYSCALL_RET_REG], [[gregs[4]]]) # a0
   AC_DEFINE([SYSCALL_ARG_REG], [[gregs[4]]]) # a0
   AC_DEFINE([SYSCALL_ARG1_REG], [[gregs[5]]]) # a1
   AC_DEFINE([SYSCALL_ARG2_REG], [[gregs[4]]]) # a2
   AC_DEFINE([SYSCALL_ARG3_REG], [[gregs[5]]]) # a3
   AC_DEFINE([STACK_POINTER], [[gregs[29]]]) # sp
   AC_DEFINE([EXEC_SYSCALL], [__NR_execve])
   AC_DEFINE([USER_WORD], [uintptr_t])
   AC_DEFINE([EXEC_64], [1])
   AC_DEFINE([EXECUTABLE_BASE], [0x400000])
   AC_DEFINE([INTERPRETER_BASE], [0x3f00000000])
   AC_DEFINE([STACK_GROWS_DOWNWARDS], [1])
   AC_DEFINE([CLONE_SYSCALL], [__NR_clone])
   AC_DEFINE([READLINK_SYSCALL], [__NR_readlink])
   AC_DEFINE([READLINKAT_SYSCALL], [__NR_readlinkat])
   AC_CACHE_CHECK([whether as understands `daddi'],
     [exec_cv_as_daddi],
     [exec_cv_as_daddi=no
      cat <<_ACEOF >conftest.s
      .section text
      .global __start
__start:
	li	$t0, 0
	li	$t1, 0
	daddi	$t0, $t1, 1
	daddi	$t0, $t1, -1
	daddi	$t0, -1
	daddi	$t0, 1

_ACEOF
      $AS $ASFLAGS conftest.s -o conftest.$OBJEXT \
	>&AS_MESSAGE_LOG_FD 2>&1		  \
	&& exec_cv_as_daddi=yes
      rm -f conftest.s conftest.$OBJEXT])
   AS_IF([test "x$exec_cv_as_daddi" != "xyes"],
     [DADDI_BROKEN=yes])
   exec_CHECK_LINUX_CLONE3
   exec_CHECK_MIPS_NABI
   LOADERFLAGS="$LOADERFLAGS $LDPREFIX-Ttext=0x3e00000000"
   is_mips=yes
   exec_loader=loader-mips64el.s], [*],
  [AC_MSG_ERROR([Please port libexec to $host])])

AC_SUBST([DADDI_BROKEN])

MIPS_N32=$exec_cv_mips_nabi

AC_ARG_VAR([LOADERFLAGS], [Flags used to link the loader.])
AC_ARG_VAR([ARFLAGS], [Flags for the archiver.])
AC_ARG_VAR([ASFLAGS], [Flags for the assembler.])

# Make the assembler optimize for code size.  Don't do this on MIPS,
# as the assembler code manages branch delays manually.

AC_CACHE_CHECK([whether as understands -O],
  [exec_cv_as_O],
  [exec_cv_as_O=no
   cat <<_ACEOF >conftest.s
   .section text
   .global _start
_start:

_ACEOF
   $AS $ASFLAGS -O conftest.s -o conftest.$OBJEXT \
     >&AS_MESSAGE_LOG_FD 2>&1			  \
     && exec_cv_as_O=yes
   rm -f conftest.s conftest.$OBJEXT])

AS_IF([test "$exec_cv_as_O" = "yes" \
       && test "$is_mips" != "yes"],
  [ASFLAGS="$ASFLAGS -O"])

# Make the assembler generate debug information.

AC_CACHE_CHECK([whether as understands -g],
  [exec_cv_as_g],
  [exec_cv_as_g=no
   cat <<_ACEOF >conftest.s
   .section text
   .global _start
_start:

_ACEOF
   $AS $ASFLAGS -g conftest.s -o conftest.$OBJEXT \
     >&AS_MESSAGE_LOG_FD 2>&1			  \
     && exec_cv_as_g=yes
   rm -f conftest.s conftest.$OBJEXT])
AS_IF([test "$exec_cv_as_g" = "yes"], [ASFLAGS="$ASFLAGS -g"])

# Check for the ability to automatically generate dependencies for C
# source files.
AUTO_DEPEND=no
AS_IF([test "x$GCC" = xyes],
  [AC_CACHE_CHECK([whether gcc understands -MMD -MF],
     [exec_cv_autodepend],
     [SAVE_CFLAGS="$CFLAGS"
      CFLAGS="$CFLAGS -MMD -MF deps.d -MP"
      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
	[exec_cv_autodepend=yes],
	[exec_cv_autodepend=no])
     CFLAGS="$SAVE_CFLAGS"
     test -f deps.d || emacs_cv_autodepend=no
     rm -rf deps.d])
   AS_IF([test "x$exec_cv_autodepend" = xyes],
     [AUTO_DEPEND=yes
      AS_MKDIR_P([deps])])])

# Now check for some other stuff.

AC_CACHE_CHECK([for 'find' args to delete a file],
  [exec_cv_find_delete],
  [AS_IF([touch conftest.tmp && find conftest.tmp -delete 2>/dev/null &&
      test ! -f conftest.tmp], [exec_cv_find_delete="-delete"],
   [exec_cv_find_delete="-exec rm -f {} ';'"])])
FIND_DELETE=$exec_cv_find_delete
AC_SUBST([FIND_DELETE])

AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile config-mips.m4])

AC_SUBST([AUTO_DEPEND])
AC_SUBST([LOADERFLAGS])
AC_SUBST([ARFLAGS])
AC_SUBST([ASFLAGS])
AC_SUBST([exec_loader])
AC_SUBST([MIPS_N32])
AC_SUBST([OBJS])

AC_OUTPUT