boarfds
This commit is contained in:
parent
80d8141b5a
commit
eae91de89d
8 changed files with 641 additions and 280 deletions
106
Makefile
106
Makefile
|
|
@ -1,50 +1,88 @@
|
|||
# --- Détection de l'OS et Chemins ---
|
||||
ifeq ($(OS),Windows_NT)
|
||||
# Chemins Windows pour les outils (utilisés par WSL)
|
||||
WATCOM := D:/WatCom
|
||||
NASM := C:/Program Files/NASM/nasm.exe
|
||||
CC := $(WATCOM)/binnt64/wcc386.exe
|
||||
AS := $(NASM)
|
||||
LINK := $(WATCOM)/binnt64/wlink.exe
|
||||
FIX_PATH = $(subst /,\,$1)
|
||||
# --- Options de Build ---
|
||||
# Valeurs possibles : causeway (recommandé), dos4g (classique)
|
||||
EXTENDER = causeway
|
||||
STACK_SIZE = 64k
|
||||
|
||||
WATCOM_WIN = D:\WatCom
|
||||
WATCOM_WSL = /mnt/d/WatCom
|
||||
NASM_WIN = /mnt/c/Program\ Files/NASM/nasm.exe
|
||||
|
||||
# --- Configuration Dynamique du Linker ---
|
||||
ifeq ($(EXTENDER), causeway)
|
||||
# Configuration optimisée pour CauseWay
|
||||
L_SYS = system causeway
|
||||
L_OPTS = option osname='CauseWay' \
|
||||
option stub=$(WATCOM_WIN)/binw/cwstub.exe \
|
||||
option stack=$(STACK_SIZE)
|
||||
else
|
||||
# Chemins Debian (à adapter selon ton install Linux)
|
||||
WATCOM := /opt/watcom
|
||||
CC := $(WATCOM)/binl64/wcc386
|
||||
AS := nasm
|
||||
LINK := $(WATCOM)/binl64/wlink
|
||||
FIX_PATH = $1
|
||||
# Configuration classique pour DOS/4GW
|
||||
L_SYS = system dos4g
|
||||
L_OPTS = option stack=$(STACK_SIZE)
|
||||
endif
|
||||
|
||||
# --- Configuration ---
|
||||
INC_DIRS := -i="$(WATCOM)/h" -i="$(WATCOM)/CustomH"
|
||||
LIB_DIRS := libpath "$(WATCOM)/lib386" libpath "$(WATCOM)/lib386/dos" libpath "$(WATCOM)/CustomLib"
|
||||
CFLAGS := -bt=dos -6r -fp6 -ox -oh -ot -ei -zp8 $(INC_DIRS)
|
||||
LFLAGS := system dos4g $(LIB_DIRS)
|
||||
# Binaires Windows exécutés par WSL
|
||||
CC = $(WATCOM_WSL)/binnt64/wcc386.exe
|
||||
CXX = $(WATCOM_WSL)/binnt64/wpp386.exe
|
||||
AS = $(NASM_WIN)
|
||||
LINK = $(WATCOM_WSL)/binnt64/wlink.exe
|
||||
|
||||
# --- Détection AUTOMATIQUE des sources ---
|
||||
# Cherche récursivement tous les .cpp, .c et .asm dans src/
|
||||
SRC_CPP := $(shell find src -name "*.cpp")
|
||||
SRC_ASM := $(shell find src -name "*.asm")
|
||||
# --- Flags de Performance ---
|
||||
# On utilise wslpath pour que les outils Windows comprennent les chemins Linux
|
||||
INC_FLAGS = -i="$(WATCOM_WIN)\h" -i="$(WATCOM_WIN)\CustomH"
|
||||
CFLAGS = -bt=dos -6s -fp6 -ox -od -oh -ot -ei -zp8 $(INC_FLAGS)
|
||||
LFLAGS = $(L_SYS) $(L_OPTS) \
|
||||
libpath "$(WATCOM_WIN)\lib386" \
|
||||
libpath "$(WATCOM_WIN)\lib386\dos" \
|
||||
libpath "$(WATCOM_WIN)\CustomLib"
|
||||
|
||||
# Génère la liste des objets correspondants dans build/
|
||||
OBJS := $(patsubst src/%.cpp, build/%.obj, $(SRC_CPP))
|
||||
OBJS += $(patsubst src/%.asm, build/%.obj, $(SRC_ASM))
|
||||
# --- Détection des Sources ---
|
||||
# On force le shell à trouver les fichiers
|
||||
SRCS_CPP := $(shell find src -name "*.cpp")
|
||||
SRCS_C := $(shell find src -name "*.c")
|
||||
SRCS_ASM := $(shell find src -name "*.asm")
|
||||
|
||||
# Création de la liste des objets (src/main/main.cpp -> build/main.obj)
|
||||
OBJS := $(patsubst src/%.cpp, build/%.obj, $(SRCS_CPP)) \
|
||||
$(patsubst src/%.c, build/%.obj, $(SRCS_C)) \
|
||||
$(patsubst src/%.asm, build/%.obj, $(SRCS_ASM))
|
||||
|
||||
# --- Règles ---
|
||||
all: build/app.exe
|
||||
all: prepare build/app.exe
|
||||
|
||||
prepare:
|
||||
@mkdir -p build
|
||||
@# Crée les sous-dossiers dans build pour correspondre à src
|
||||
@$(foreach dir, $(sort $(dir $(SRCS_CPP) $(SRCS_C) $(SRCS_ASM))), mkdir -p $(subst src,build,$(dir));)
|
||||
|
||||
# Création du dossier build miroir de src
|
||||
build/%.obj: src/%.cpp
|
||||
@mkdir -p $(dir $@)
|
||||
$(CC) $(CFLAGS) $< -fo=$(call FIX_PATH,$@)
|
||||
$(CXX) $(CFLAGS) $< -fo='$(shell wslpath -w $@)'
|
||||
@rm -f $*.err
|
||||
|
||||
build/%.obj: src/%.c
|
||||
@mkdir -p $(dir $@)
|
||||
$(CC) $(CFLAGS) $< -fo='$(shell wslpath -w $@)'
|
||||
@rm -f $*.err
|
||||
|
||||
build/%.obj: src/%.asm
|
||||
@mkdir -p $(dir $@)
|
||||
$(AS) -f obj $< -o $(call FIX_PATH,$@)
|
||||
$(AS) -f obj $< -o '$(shell wslpath -w $@)'
|
||||
|
||||
build/app.exe: $(OBJS)
|
||||
$(LINK) $(LFLAGS) name $(call FIX_PATH,$@) file {$(foreach f,$(OBJS),$(call FIX_PATH,$f))}
|
||||
# --- PARTIE LINK CORRIGÉE ---
|
||||
build/app.exe: $(OBJS) MakeFile
|
||||
@if [ -z "$(OBJS)" ]; then echo "ERREUR: Aucun objet trouvé!"; exit 1; fi
|
||||
@echo "Generating linker file: build/link.lnk"
|
||||
@printf '%s\n' '$(LFLAGS)' > build/link.lnk
|
||||
@printf 'name %s\n' '$(shell wslpath -w $@)' >> build/link.lnk
|
||||
@$(foreach f,$(OBJS),printf 'file %s\n' '$(shell wslpath -w $f)' >> build/link.lnk;)
|
||||
@echo "Linking..."
|
||||
$(LINK) @build/link.lnk
|
||||
|
||||
clean:
|
||||
rm -rf build/*
|
||||
rm -rf build
|
||||
# Nettoyage des logs d'erreurs
|
||||
rm -f *.err src/**/*.err
|
||||
|
||||
cleanall:
|
||||
clean
|
||||
all
|
||||
Loading…
Reference in a new issue