Files
vlibc/Makefile.am
T
huntedbytheirsandSisyphus 7d28d7cc9d build(profile): select sources per level via AM_CONDITIONAL
Gate the initial string slice per compatibility level: L1 sources compile
everywhere, strlcpy/strlcat only at level >= 2 (PROFILE_GE_2), strcasestr
only at level >= 3 (PROFILE_GE_3). Install the generated
include/vlibc/features.h under $(vlibc_includedir)/vlibc/ via a dedicated
vlibc_featuresdir primary (nodist_nobase is rejected by automake and loses
the vlibc/ subpath). Include stddef.h/string.h in vlibc_include_HEADERS.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <[email protected]>
2026-08-31 20:54:00 -04:00

71 lines
2.3 KiB
Makefile

# vlibc — top-level build (see building/C.md and layouts/C.md).
SUBDIRS = benchmarks
AM_CPPFLAGS = -I$(top_srcdir)/include
AM_CFLAGS = @VLIBC_CFLAGS@
# ---- Library -------------------------------------------------------------
vlibc_include_HEADERS = include/vlibc.h include/stddef.h include/string.h
vlibc_lib_LTLIBRARIES = libvlibc.la
libvlibc_la_SOURCES = src/vlibc.c src/string/strlen.c src/string/strcmp.c \
src/string/memcpy.c src/string/memmove.c src/string/memset.c
if PROFILE_GE_2
libvlibc_la_SOURCES += src/string/strlcpy.c src/string/strlcat.c
endif
if PROFILE_GE_3
libvlibc_la_SOURCES += src/string/strcasestr.c
endif
libvlibc_la_LDFLAGS = -version-info 0:0:0 -no-undefined
# Install location depends on the install method (see configure.ac).
if INSTALL_OVERWRITE
vlibc_includedir = $(includedir)
vlibc_libdir = $(libdir)
else
vlibc_includedir = $(prefix)/lib/vlibc/include
vlibc_libdir = $(prefix)/lib/vlibc/lib
endif
# Generated per-profile feature header (see configure.ac); installed under
# $(vlibc_includedir)/vlibc/. A dedicated primary is used because
# nodist_nobase_vlibc_include_HEADERS is rejected by automake (the "nobase"
# prefix is unsupported for this directory) and loses the vlibc/ path.
vlibc_featuresdir = $(vlibc_includedir)/vlibc
nodist_vlibc_features_HEADERS = include/vlibc/features.h
# ---- Compiler drivers ----------------------------------------------------
bin_SCRIPTS = tools/vlibc-gcc tools/vlibc-clang
# ---- Targets -------------------------------------------------------------
# layouts/C.md requires `make debug`, `make release`, `make bench` and
# `make clean`; build outputs land in bin/{release,debug}.
DEBUG_CFLAGS = -O0 -g3 -DDEBUG
RELEASE_CFLAGS = -O3 -DNDEBUG
debug:
$(MAKE) clean
$(MAKE) all AM_CFLAGS="$(AM_CFLAGS) $(DEBUG_CFLAGS)"
$(MKDIR_P) bin/debug
-cp -P .libs/libvlibc.so* bin/debug/
-cp .libs/libvlibc.a bin/debug/
release:
$(MAKE) clean
$(MAKE) all AM_CFLAGS="$(AM_CFLAGS) $(RELEASE_CFLAGS)"
$(MKDIR_P) bin/release
-cp -P .libs/libvlibc.so* bin/release/
-cp .libs/libvlibc.a bin/release/
bench: all
$(MAKE) -C benchmarks bench
# Regenerate compile_commands.json (requires `bear`). Captures both the
# library sources and the on-demand benchmark harness.
compile-commands: clean
bear -- $(MAKE) all
bear --append -- $(MAKE) -C benchmarks bench_vlibc
.PHONY: debug release bench compile-commands