many things, cosmo build!

This commit is contained in:
veclavtlica
2026-10-12 21:12:47 +03:00
parent ba4131abbf
commit 8d2bb5575e
29 changed files with 699 additions and 312 deletions
+28 -21
View File
@@ -4,7 +4,15 @@ DEBUG ?= 1 # Emit debug info.
SQUEEZE ?= 0 # Nuclear option to save space.
BITS ?= 64
RUN ?= 0
CFLAGS = -Wall -std=gnu99 -flto=thin -ffast-math -fno-ident -fvisibility=hidden -fuse-ld=lld
ISCLANG = 1
ifeq ($(MAKECMDGOALS),cosmo)
ISCLANG = 0
endif
CFLAGS = -Wall -std=gnu99 -ffast-math -fno-ident -fvisibility=hidden
ifeq ($(ISCLANG), 1)
CFLAGS = -flto=thin -fuse-ld=lld
endif
ifeq ($(MAKECMDGOALS),linux)
CFLAGS += -fno-pic -fno-pie
ifeq ($(RELEASE), 1)
@@ -12,7 +20,10 @@ ifeq ($(MAKECMDGOALS),linux)
-Wl,--optimize-bb-jumps
endif
ifeq ($(SQUEEZE), 1)
CFLAGS += -Wl,-T,tiny.ld -Wl,--icf=all -Wl,--bp-compression-sort=both \
ifeq ($(DEBUG), 0)
CFLAGS += -Wl,-T,tiny.ld
endif
CFLAGS += -Wl,--icf=all -Wl,--bp-compression-sort=both \
-Wl,--nmagic
endif
ifeq ($(BITS), 64)
@@ -37,32 +48,27 @@ ifeq ($(RELEASE), 1)
-Wl,-mllvm,--vectorize-slp=true \
-Wl,-mllvm,--enable-gvn-hoist=true
endif
# TODO: Just use amalgam build for all?
DEPS = ../Common/lzw.h ../Common/mat.h ../Common/vec.h ../Common/fix.h ../Common/def.h ../Common/bits.h \
../Common/gem.h \
../Common/Timer/time.h \
./Display/display.h \
./draw.h
SRC = ../Common/lzw.c ../Common/fix.c ../Common/mat.c ./draw.c
LINUX = ./amalgam.c
WASM = ./amalgam.c
DOS = maindos.c Display/dos.c
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
%.o: %.s $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
# TODO: Make it work with no stdlib.
linux: CFLAGS += -static -mbmi2 -nostdlib
linux: $(LINUX) | $(SRC)
linux: ./amalgam.c
$(CC) -o player $^ $(CFLAGS)
# Note: lld package might need to be downloaded.
wasm: CFLAGS += --target=wasm32 -nostdlib -Wl,--no-entry -msimd128 -mbulk-memory
wasm:
$(CC) -o player.wasm $(WASM) $(CFLAGS)
$(CC) -o player.wasm ./amalgam.c $(CFLAGS)
# todo: Add -mtiny for release without debug
cosmo: CC = ./Cosmo/bin/cosmocc -I /usr/include/X11 -mdbg
cosmo: ./amalgam.c
$(CC) -o ./Out/Cosmo/player $^
ifeq ($(RUN), 1)
ifeq ($(DEBUG), 1)
gdb ./Out/Cosmo/player.com.dbg
else
./Out/Cosmo/player
endif
endif
# https://tippach.hier-im-netz.de/wdosx
dos: CFLAGS += -ffreestanding -m32 -fno-PIC -fno-PIE -nostdlib -nodefaultlibs
@@ -79,5 +85,6 @@ else
dosbox -c "mount c $(PWD)" -c "c:" -c "DOS.EXE"
endif
endif
clean:
rm -r *.o ../*.o