Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux build improvements #23

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 33 additions & 13 deletions common/src/MakefileCommon
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
ZGB_PATH_UNIX := $(subst ',,$(subst \,/,'$(ZGB_PATH)'))
GBDK_HOME := $(ZGB_PATH_UNIX)/../env/gbdk

# default to no extension for all OSes
EXEEXTENSION =

# Only set GBDK_HOME if not already set
# This allows override with local version
ifeq ($(GBDK_HOME),)
GBDK_HOME := $(ZGB_PATH_UNIX)/../env/gbdk
# If GBDK_HOME is not defined and the OS is not Windows
# then the ENV binaries will get used, which mean they
# need a .exe extension to work with WINE on Linux/etc.
ifneq ($(OS),Windows_NT)
EXEEXTENSION=.exe
endif
endif

PATH := $(ZGB_PATH_UNIX)/../env/make-3.81-bin/bin;$(ZGB_PATH_UNIX)/../env/gbdk/bin;$(ZGB_PATH_UNIX)/../env/msys/bin;$(PATH)

#--- Default build will be release. Can be overiden passing BUILD_TYPE = debug as a parameter
Expand All @@ -11,18 +26,18 @@ OBJDIR_RES = ../$(BUILD_TYPE)/res
OBJDIR_ZGB = ../$(BUILD_TYPE)/zgb
BINDIR = ../bin

SDCC = sdcc
SDASGB = sdasgb
SDLDGB = sdldgb
MAKEBIN = makebin
IHXCHECK = ihxcheck
SDCC = $(GBDK_HOME)/bin/sdcc$(EXEEXTENSION)
SDASGB = $(GBDK_HOME)/bin/sdasgb$(EXEEXTENSION)
SDLDGB = $(GBDK_HOME)/bin/sdldgb$(EXEEXTENSION)
MAKEBIN = $(GBDK_HOME)/bin/makebin$(EXEEXTENSION)
IHXCHECK = $(GBDK_HOME)/bin/ihxcheck$(EXEEXTENSION)

GBR2C = $(ZGB_PATH_UNIX)/../tools/gbr2c/gbr2c
GBM2C = $(ZGB_PATH_UNIX)/../tools/gbm2c/gbm2c
PNGB = $(ZGB_PATH_UNIX)/../env/pngb
MOD2GBT = $(ZGB_PATH_UNIX)/../env/mod2gbt
BGB = $(ZGB_PATH_UNIX)/../env/bgb/bgb
ROMVIEW = $(ZGB_PATH_UNIX)/../env/romview/romview.exe
GBR2C = $(ZGB_PATH_UNIX)/../tools/gbr2c/gbr2c$(EXEEXTENSION)
GBM2C = $(ZGB_PATH_UNIX)/../tools/gbm2c/gbm2c$(EXEEXTENSION)
PNGB = $(ZGB_PATH_UNIX)/../env/pngb$(EXEEXTENSION)
MOD2GBT = $(ZGB_PATH_UNIX)/../env/mod2gbt$(EXEEXTENSION)
BGB = $(ZGB_PATH_UNIX)/../env/bgb/bgb$(EXEEXTENSION)
ROMVIEW = $(ZGB_PATH_UNIX)/../env/romview/romview$(EXEEXTENSION)

CFLAGS = -mgbz80 --no-std-crt0 --fsigned-char --use-stdout -Dnonbanked= -I$(GBDK_HOME)/include -I$(GBDK_HOME)/include/asm $(BUILD_DEFS) -I../include -I$(ZGB_PATH_UNIX)/include
CFLAGS += -DFILE_NAME=$(basename $(<F))
Expand Down Expand Up @@ -64,7 +79,7 @@ PNGS = $(foreach dir,../res,$(notdir $(wildcard $(dir)/*.png)))
MUSICS = $(foreach dir,../res/music,$(notdir $(wildcard $(dir)/*.mod)))
OBJS = $(GBMS:%.gbm=$(OBJDIR_RES)/%.gbm.o) $(GBRS:%.gbr=$(OBJDIR_RES)/%.gbr.o) $(PNGS:%.png=$(OBJDIR_RES)/%.png.o) $(MUSICS:%.mod=$(OBJDIR_RES)/%.mod.o) $(ASMS:%.s=$(OBJDIR)/%.o) $(CLASSES:%.c=$(OBJDIR)/%.o)
OBJS_ZGB = $(ASMS_ZGB:%.s=$(OBJDIR_ZGB)/%.o) $(CLASSES_ZGB:%.c=$(OBJDIR_ZGB)/%.o)
OBJS_ZGB_LIB = $(ASMS_ZGB:%.s=\n%.o) $(CLASSES_ZGB:%.c=\n%.o)
OBJS_ZGB_LIB = $(ASMS_ZGB:%.s=%.o) $(CLASSES_ZGB:%.c=%.o)

#prevent gbr2c and gbm2c intermediate files from being deleted
.SECONDARY: $(GBMS:%.gbm=$(OBJDIR_RES_SRC)/%.gbm.c) $(GBRS:%.gbr=$(OBJDIR_RES_SRC)/%.gbr.c) $(PNGS:%.png=$(OBJDIR_RES_SRC)/%.png.c)
Expand Down Expand Up @@ -141,7 +156,12 @@ $(OBJDIR)/zgb/%.o: $(ZGB_PATH_UNIX)/src/%.c
$(OBJDIR_ZGB)/zgb.lib: $(OBJDIR_ZGB) $(OBJS_ZGB)
@echo creating zgb.lib
@rm -f $(OBJDIR_ZGB)/zgb.lib
ifeq ($(OS),Windows_NT)
@echo -e "$(OBJS_ZGB_LIB)" >> $(OBJDIR_ZGB)/zgb.lib
else
@echo "$(OBJS_ZGB_LIB)" >> $(OBJDIR_ZGB)/zgb.lib
endif
@sed -i -e 's/ /\n/g' $(OBJDIR_ZGB)/zgb.lib

#Project files------------------------------------
$(OBJDIR)/%.o: %.s
Expand Down