Add autotools build system (static-only, C17)
configure.ac enforces C17 and Linux/x86_64, refuses in-tree configure; Makefile.am builds libc.a plus crt0.o; the driver Makefile dispatches out-of-tree builds into bin/release (-O2) and bin/debug (-O0 -g). Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <[email protected]>
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
dnl configure.ac — nulsl-libc, a very lightweight C17 libc for Linux.
|
||||
dnl
|
||||
dnl Static-only on purpose: the dynamic linker is a memory tax we refuse to
|
||||
dnl pay (see docs/architecture.md). libc.a is a plain archive, so no libtool.
|
||||
dnl
|
||||
dnl IMPORTANT: never run ./configure at the repository root. The root holds a
|
||||
dnl hand-written driver Makefile that builds into bin/{release,debug}; the
|
||||
dnl guard below refuses to overwrite it.
|
||||
|
||||
AC_PREREQ([2.71])
|
||||
AC_INIT([nulsl-libc], [0.1.0], [], [nulsl-libc],
|
||||
[https://git.spectoria.dev/The-Null-Linux-Project/nulsl-libc])
|
||||
AC_CONFIG_SRCDIR([include/stdio.h])
|
||||
AC_CONFIG_AUX_DIR([build-aux])
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
AM_INIT_AUTOMAKE([foreign subdir-objects])
|
||||
|
||||
dnl C17, and only C17 (project guideline #1). Modern autoconf ships no
|
||||
dnl AC_PROG_CC_C17 macro, so prove it with a compile test instead.
|
||||
AC_PROG_CC
|
||||
saved_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -std=c17"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#if __STDC_VERSION__ < 201710L
|
||||
#error "not C17"
|
||||
#endif
|
||||
], [])],
|
||||
[],
|
||||
[AC_MSG_ERROR([nulsl-libc requires a C17 compiler (GCC >= 8 or Clang >= 6); -std=c17 was rejected])])
|
||||
CFLAGS="$saved_CFLAGS"
|
||||
|
||||
dnl Target validation: Linux on x86_64, for now.
|
||||
AS_CASE([$host_os],
|
||||
[linux*], [],
|
||||
[AC_MSG_ERROR([nulsl-libc currently targets Linux only (configured for $host_os)])])
|
||||
AS_CASE([$host_cpu],
|
||||
[x86_64], [],
|
||||
[AC_MSG_ERROR([nulsl-libc currently targets x86_64 only (configured for $host_cpu); src/arch/ is where new ports go])])
|
||||
|
||||
dnl Plain archives need ar/ranlib; no libtool, no shared objects.
|
||||
AC_CHECK_TOOL([AR], [ar])
|
||||
AC_PROG_RANLIB
|
||||
|
||||
dnl Refuse in-tree configuration: it would clobber the committed driver
|
||||
dnl Makefile that dispatches into bin/{release,debug}.
|
||||
AS_IF([test "x$srcdir" = "x." && test -f Makefile],
|
||||
[AC_MSG_ERROR([in-tree builds are disabled — run 'make release' or 'make debug' from the repository root instead])])
|
||||
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
AC_OUTPUT
|
||||
Reference in New Issue
Block a user