refactor: libc - share printf, split the float path, fix relink deps
This commit is contained in:
+29
-9
@@ -105,8 +105,24 @@ lib/bearssl/build/libbearssl.a:
|
||||
bearssl: lib/bearssl/build/libbearssl.a
|
||||
|
||||
# Build shared libc static library.
|
||||
libc:
|
||||
$(MAKE) -C lib/libc
|
||||
#
|
||||
# The archives and CRT objects get a real file rule, not just the `libc`
|
||||
# phony, so that programs can list them as prerequisites and actually relink
|
||||
# when libc changes. A phony prerequisite would instead make every program
|
||||
# permanently out of date; no prerequisite at all (the old state) both races
|
||||
# under -j and silently leaves programs linked against a stale libc.
|
||||
# Grouped target (&:, GNU make 4.3+): one sub-make produces all of them.
|
||||
LIBC_DIR := lib/libc
|
||||
LIBC_LIB := $(LIBC_DIR)/liblibc.a
|
||||
LIBC_SRCS := $(wildcard $(LIBC_DIR)/*.c $(LIBC_DIR)/*.h $(LIBC_DIR)/*.S \
|
||||
$(LIBC_DIR)/crt/*.c) $(LIBC_DIR)/Makefile
|
||||
LIBC_OUTPUTS := $(LIBC_LIB) $(LIBC_DIR)/liblibc-full.a \
|
||||
$(LIBC_DIR)/crt1.o $(LIBC_DIR)/crti.o $(LIBC_DIR)/crtn.o
|
||||
|
||||
$(LIBC_OUTPUTS) &: $(LIBC_SRCS)
|
||||
$(MAKE) -C $(LIBC_DIR)
|
||||
|
||||
libc: $(LIBC_OUTPUTS)
|
||||
|
||||
# Build shared TLS helper library.
|
||||
tls: bearssl libc
|
||||
@@ -144,8 +160,8 @@ libjpegwrite: libc
|
||||
imageviewer: libc libjpeg
|
||||
$(MAKE) -C src/imageviewer
|
||||
|
||||
# Build fontpreview standalone GUI client (no library deps).
|
||||
fontpreview:
|
||||
# Build fontpreview standalone GUI client (links libc).
|
||||
fontpreview: libc
|
||||
$(MAKE) -C src/fontpreview
|
||||
|
||||
# Build spreadsheet standalone GUI client (depends on libc and libdialogs).
|
||||
@@ -271,8 +287,9 @@ mandelbrot: libc
|
||||
rpgdemo: libc
|
||||
$(MAKE) -C src/rpgdemo
|
||||
|
||||
# Build doom via its own Makefile (depends on libc).
|
||||
doom: libc
|
||||
# Build doom via its own Makefile (depends on libc and the shared-lib loader,
|
||||
# both of which it links).
|
||||
doom: libc libloader
|
||||
$(MAKE) -C src/doom
|
||||
|
||||
# Build screenshot tool (depends on libc, libjpegwrite, libloader, and libdialogs).
|
||||
@@ -369,10 +386,10 @@ $(BINDIR)/os/wallpapers/%: $(WPDIR)/%
|
||||
cp $< $@
|
||||
|
||||
# Build each system program from its source files.
|
||||
$(BINDIR)/os/%.elf: src/%/main.cpp link.ld GNUmakefile
|
||||
$(BINDIR)/os/%.elf: src/%/main.cpp link.ld GNUmakefile $(LIBC_LIB)
|
||||
mkdir -p $(BINDIR)/os obj/$*
|
||||
$(CXX) $(CXXFLAGS) -c src/$*/main.cpp -o obj/$*/main.o
|
||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) obj/$*/main.o lib/libc/liblibc.a -o $@
|
||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) obj/$*/main.o $(LIBC_LIB) -o $@
|
||||
|
||||
# ============================================================================
|
||||
# Native development kit (Montauk SDK): binutils built for MontaukOS
|
||||
@@ -399,7 +416,10 @@ ifneq ($(wildcard $(NATIVE_BIN)/as),)
|
||||
cp -r include/montauk $(BINDIR)/sdk/include/montauk
|
||||
cp -r include/Api $(BINDIR)/sdk/include/Api
|
||||
cp -r ../kernel/freestnd-cxx-hdrs/x86_64/include/. $(BINDIR)/sdk/include/
|
||||
cp lib/libc/liblibc.a $(BINDIR)/sdk/lib/libc.a
|
||||
# liblibc-full.a, not liblibc.a: on-OS builds cannot pass
|
||||
# -Wl,-u,_pf_putfloat, so the sysroot ships the variant with the printf
|
||||
# float path already bound in. See lib/libc/Makefile.
|
||||
cp lib/libc/liblibc-full.a $(BINDIR)/sdk/lib/libc.a
|
||||
cp lib/libc/crt1.o lib/libc/crti.o lib/libc/crtn.o $(BINDIR)/sdk/lib/
|
||||
ar rcs $(BINDIR)/sdk/lib/libm.a
|
||||
cp ../toolchain/local/x86_64-montauk/lib/libstdc++.a $(BINDIR)/sdk/lib/libstdc++.a
|
||||
|
||||
Reference in New Issue
Block a user