# Build the headless C68K cycle harness.  PX68K points at a px68k checkout;
# only m68000/c68k.c and the two header dirs are used -- no SDL, no ROMs.
PX68K ?= $(HOME)/src/px68k
# -no-pie is LOAD-BEARING, not a tidy-up.  C68K is 64-bit-unsafe on purpose:
# its MOVEM macros do `src = (UINT32)(&D0)` -- they truncate the host address of
# the CPU register file to 32 bits and dereference it -- and C68k_Set_Fetch
# stores the opcode-fetch base in a UINT32 too.  Under the default PIE the
# binary loads near 0x555555550000 and the first movem segfaults.  -no-pie puts
# the image at 0x400000, and the harness mmaps its arena with MAP_32BIT, so
# every pointer C68K truncates still round-trips.
CFLAGS = -O2 -fno-strict-aliasing -no-pie -Wall -Wno-unused-result \
         -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast \
         -I$(PX68K)/m68000 -I$(PX68K)/x11 -I$(PX68K)/win32api

c68k_bench: harness.c $(PX68K)/m68000/c68k.c
	$(CC) $(CFLAGS) -no-pie -o $@ harness.c $(PX68K)/m68000/c68k.c

clean:
	rm -f c68k_bench
