Files
RetroArch/samples/sample_objdir.mk
T
libretroadmin afbad7a104 samples: shared sources build into each sample's own obj/
Samples compiled shared tree sources in place, so whichever sample ran
next linked those objects with the flags they were built with, as
unity_identity did with mic_handshake's ASan objects. Every sample that
builds a source from outside its directory now includes
sample_objdir.mk and maps those objects under its own obj/; its own
objects stay where they were. The rule for the mapped objects has a
slash in its target, so make 3.81 does not strip the directory.

tools/sample_objdir_check.py dry-runs every sample Makefile and fails
on an object written outside the sample; the Samples-Objdir-Check
workflow runs it.
2026-10-10 19:43:34 +02:00

13 lines
481 B
Makefile

# Objects of sources outside the sample go under its own obj/, so no
# sample links another's leftovers built with other flags. ../ is kept
# as __/ there; sample_src maps it back:
# OBJS := $(call sample_objs,$(SOURCES:.c=.o))
# %.o: $$(call sample_src,$$*).c
SAMPLE_OBJDIR ?= obj
sample_objs = $(foreach o,$(1),$(if $(filter ../% /%,$(o)),$(SAMPLE_OBJDIR)/$(subst ../,__/,$(o)),$(o)))
sample_src = $(subst __/,../,$(patsubst $(SAMPLE_OBJDIR)/%,%,$(1)))
.SECONDEXPANSION: