# Makefile.am — nulsl-libc # # This is the AUTOTOOLS makefile. It is only ever instantiated by a configure # run inside bin/release/ or bin/debug/ (never at the repository root). # # Everything is a static library. No libtool, no shared objects, no dynamic # linker. See docs/architecture.md. # # Benchmarks and tests live in one Makefile on purpose: automake orders # targets by dependency, so libc.a (and crt0.o) are guaranteed to exist # before any -nostdlib binary links against them. With SUBDIRS, recursion # builds the subdirectories first and linking breaks. AUTOMAKE_OPTIONS = foreign AM_CPPFLAGS = -I$(top_srcdir)/include AM_CFLAGS = -std=c17 -ffreestanding -fno-builtin -fno-stack-protector \ -Wall -Wextra -Wshadow -Wpointer-arith lib_LIBRARIES = libc.a libc_a_SOURCES = \ src/errno.c \ src/stdio.c \ src/stdlib.c \ src/string.c \ src/syscall.c \ src/unistd.c # The C runtime entry point is deliberately NOT a member of libc.a: nothing # references _start, so the linker would never extract it from an archive. # It is built as a standalone object and linked explicitly by everything # that wants a runnable binary. noinst_DATA = crt0.o crt0.o: $(top_srcdir)/src/crt/crt0.S $(CC) $(AM_CPPFLAGS) $(CFLAGS) -c -o $@ $< CLEANFILES = crt0.o EXTRA_DIST = autogen.sh # --- benchmarks ------------------------------------------------------------ # Fully static, -nostdlib: the numbers reflect exactly what ships. noinst_PROGRAMS = benchmarks/bench_strlen benchmarks/bench_syscall benchmarks_bench_strlen_SOURCES = benchmarks/bench_strlen.c benchmarks_bench_strlen_LDADD = crt0.o libc.a -lgcc benchmarks_bench_strlen_LDFLAGS = -nostdlib -static -no-pie -Wno-unused-command-line-argument benchmarks_bench_syscall_SOURCES = benchmarks/bench_syscall.c benchmarks_bench_syscall_LDADD = crt0.o libc.a -lgcc benchmarks_bench_syscall_LDFLAGS = -nostdlib -static -no-pie -Wno-unused-command-line-argument .PHONY: bench bench: all ./benchmarks/bench_strlen ./benchmarks/bench_syscall # --- tests ------------------------------------------------------------------ check_PROGRAMS = tests/smoke TESTS = tests/smoke tests_smoke_SOURCES = tests/smoke.c tests_smoke_LDADD = crt0.o libc.a -lgcc tests_smoke_LDFLAGS = -nostdlib -static -no-pie -Wno-unused-command-line-argument