Apple2GSBuildPipeline/make/tail.mk

227 lines
6.3 KiB
Makefile
Raw Normal View History

2017-05-17 02:34:15 +00:00
#
# tail.mk
#
export PATH := $(PATH):$(ORCA_BIN)
CWD=$(shell pwd)
DISKIMAGE=$(TARGETDIR)/$(PGM).2mg
2017-08-31 03:07:13 +00:00
BUILDTARGET=$(DISKIMAGE)
EXECTARGET=executeGUI
DISKIMAGEDEST=.
AUXTYPE=
CFLAGS+=-i$(GENDIR)
vpath $(GENDIR)
ifeq ($(TARGETTYPE),shell)
FILETYPE=exe
EXECTARGET=executeShell
BUILDTARGET=$(TARGETDIR)/$(PGM)
else ifeq ($(TARGETTYPE),desktop)
FILETYPE=s16
ifeq ($(MESSAGE_CENTER),1)
AUXTYPE=-a 0x0000db07
else
AUXTYPE=-a 0x0000db03
endif
CFLAGS+=-dMESSAGE_CENTER=$(MESSAGE_CENTER)
REZFLAGS+=rez='-d DESKTOP_RES_MODE=$(DESKTOP_RES_MODE)'
REZFLAGS+=rez='-d MESSAGE_CENTER=$(MESSAGE_CENTER)'
else ifeq ($(TARGETTYPE),cda)
FILETYPE=cda
DISKIMAGEDEST=System/Desk.Accs
else ifeq ($(TARGETTYPE),cdev)
BINTARGET=$(TARGETDIR)/$(PGM).bin
FILETYPE=199
DISKIMAGEDEST=System/CDevs
REZFLAGS+=rez='-d BINTARGET="$(BINTARGET)"'
else ifeq ($(TARGETTYPE),nba)
FILETYPE=exe
BUILDTARGET=$(TARGETDIR)/$(PGM)
else ifeq ($(TARGETTYPE),nda)
FILETYPE=nda
DISKIMAGEDEST=System/Desk.Accs
else ifeq ($(TARGETTYPE),xcmd)
FILETYPE=exe
BUILDTARGET=$(TARGETDIR)/$(PGM)
endif
2017-05-17 02:34:15 +00:00
ASM_SRCS=$(patsubst $(GENDIR)/%, %, $(patsubst ./%, %, $(wildcard $(addsuffix /*.s, $(SRCDIRS)))))
ifeq ($(ASSEMBLER),orcam)
ASM_MACROS=$(patsubst %.s, $(OBJDIR)/%.macros, $(ASM_SRCS))
ASM_DEPS=$(patsubst %.s, $(OBJDIR)/%.macros.d, $(ASM_SRCS))
ASM_ROOTS=$(patsubst %.s, $(OBJDIR)/%.ROOT, $(ASM_SRCS))
ASM_OBJS=$(patsubst %.s, $(OBJDIR)/%.a, $(ASM_SRCS))
ifeq ($(wildcard $(ROOTCFILE)),)
ROOTCFILE=
endif
C_ROOTS=$(patsubst %.c, $(OBJDIR)/%.root, $(ROOTCFILE))
C_SRCS+=$(filter-out $(ROOTCFILE), $(patsubst $(GENDIR)/%, %, $(patsubst ./%, %, $(wildcard $(addsuffix /*.c, $(SRCDIRS))))))
C_OBJS=$(patsubst %.c, $(OBJDIR)/%.a, $(C_SRCS))
C_DEPS=$(patsubst %.c, $(OBJDIR)/%.d, $(ROOTCFILE)) $(patsubst %.c, $(OBJDIR)/%.d, $(C_SRCS))
endif
2017-05-17 02:34:15 +00:00
REZ_SRCS=$(patsubst $(GENDIR)/%, %, $(patsubst ./%, %, $(wildcard $(addsuffix /*.rez, $(SRCDIRS)))))
REZ_DEPS=$(patsubst %.rez, $(OBJDIR)/%.rez.d, $(REZ_SRCS))
REZ_OBJS=$(patsubst %.rez, $(OBJDIR)/%.r, $(REZ_SRCS))
2017-05-17 02:34:15 +00:00
ifneq ($(firstword $(REZ_SRCS)), $(lastword $(REZ_SRCS)))
$(error Only a single resource file supported, found $(REZ_SRCS))
endif
BUILD_OBJS=$(C_ROOTS) $(C_OBJS) $(ASM_ROOTS)
ifeq ($(BINTARGET),)
BUILD_OBJS+=$(REZ_OBJS)
endif
2017-05-17 02:34:15 +00:00
BUILD_OBJS_NOSUFFIX=$(C_ROOTS:.root=) $(C_OBJS:.a=) $(ASM_ROOTS:.ROOT=)
ALL_OBJS=$(C_ROOTS:.root=.a) $(C_OBJS) $(ASM_OBJS) $(REZ_OBJS)
ALL_ROOTS=$(C_ROOTS) $(C_OBJS:.a=.root) $(ASM_ROOTS)
ALL_DEPS=$(C_DEPS) $(ASM_DEPS) $(REZ_DEPS)
2017-05-17 02:34:15 +00:00
EXECCMD=
.PHONY: build execute executeShell executeGUI clean xcodefix
2017-05-17 02:34:15 +00:00
.PRECIOUS: $(ASM_MACROS)
2017-05-17 02:34:15 +00:00
2017-08-31 03:07:13 +00:00
build: $(BUILDTARGET)
gen: xcodefix
xcodefix:
[ "`uname`" = Darwin ] && defaults write "$(ORCAM_PLUGIN_INFO)" $(XCODE_PLUGIN_COMPATIBILITY)s -array `defaults read "$(XCODE_INFO)" $(XCODE_PLUGIN_COMPATIBILITY)` || true
2017-08-31 03:07:13 +00:00
clean: genclean
$(RM) "$(TARGETDIR)/$(PGM)" $(BINTARGET)
2017-05-17 02:34:15 +00:00
$(RM) $(ALL_OBJS)
$(RM) $(ALL_ROOTS)
$(RM) $(ALL_DEPS)
$(RM) $(ASM_MACROS)
$(RM) "$(DISKIMAGE)"
2017-05-17 02:34:15 +00:00
createPackage:
pkg/createPackage
cleanMacCruft:
rm -rf pkg
ifeq ($(BINTARGET),)
ifeq ($(ASSEMBLER),orcam)
# This is a standard ORCA build where we generate the resources if any and
# then link the binary over that same file creating the resource fork first
# and the data fork second.
$(TARGETDIR)/$(PGM): $(BUILD_OBJS)
$(MKDIR) $(TARGETDIR)
2017-05-17 02:34:15 +00:00
ifneq ($(REZ_OBJS),)
$(RM) $(TARGETDIR)/$(PGM)
$(CP) $(REZ_OBJS) $(TARGETDIR)/$(PGM)
2017-05-17 02:34:15 +00:00
endif
cd $(OBJDIR); $(LINK) $(LDFLAGS) $(patsubst $(OBJDIR)/%, %, $(BUILD_OBJS_NOSUFFIX)) keep="$(abspath $(TARGETDIR)/$(PGM))"
$(CHTYP) -t $(FILETYPE) $(AUXTYPE) $(TARGETDIR)/$(PGM)
endif
ifeq ($(ASSEMBLER),merlin)
# This is a standard Merlin build where we generate the resources if any and
# then link the binary over that same file creating the resource fork first
# and the data fork second.
$(TARGETDIR)/$(PGM): $(BUILD_OBJS) $(ASM_SRCS)
$(MKDIR) $(TARGETDIR)
$(RM) $(TARGETDIR)/$(PGM)
$(MERLIN_ASM) linkscript.s $(PGM) $(TARGETDIR)/$(PGM)
ifneq ($(REZ_OBJS),)
$(CP) $(REZ_OBJS)/..namedfork/rsrc $(TARGETDIR)/$(PGM)/..namedfork/rsrc
endif
$(CHTYP) -t $(FILETYPE) $(AUXTYPE) $(TARGETDIR)/$(PGM)
endif
else
ifeq ($(ASSEMBLER),orcam)
# This is a special build for CDevs under ORCA where we build the binary into
# a $(PGM).bin file and then build the resources into the $(PGM) target. The
# resource compile will read the $(PGM).bin binary and load it into the
# resources also.
$(BINTARGET): $(BUILD_OBJS)
cd $(OBJDIR); $(LINK) $(LDFLAGS) $(patsubst $(OBJDIR)/%, %, $(BUILD_OBJS_NOSUFFIX)) keep="$(abspath $(BINTARGET))"
endif
ifeq ($(ASSEMBLER),merlin)
# This is a special build for CDevs under Merlin where we build the binary into
# a $(PGM).bin file and then build the resources into the $(PGM) target. The
# resource compile will read the $(PGM).bin binary and load it into the
# resources # also.
$(BINTARGET): $(BUILD_OBJS) $(ASM_SRCS)
$(MERLIN_ASM) linkscript.s $(PGM) $(BINTARGET)
endif
$(REZ_OBJS): $(BINTARGET)
$(TARGETDIR)/$(PGM): $(REZ_OBJS)
$(MKDIR) $(TARGETDIR)
$(RM) $(TARGETDIR)/$(PGM)
$(CP) $(REZ_OBJS) $(TARGETDIR)/$(PGM)
$(CHTYP) -t $(FILETYPE) $(AUXTYPE) $(TARGETDIR)/$(PGM)
endif
2017-05-17 02:34:15 +00:00
$(DISKIMAGE): $(TARGETDIR)/$(PGM)
make/createDiskImage "$(DISKIMAGE)" "$(TARGETDIR)/$(PGM)" "$(DISKIMAGEDEST)" $(COPYDIRS)
2017-05-17 02:34:15 +00:00
execute: $(EXECTARGET)
2017-08-31 03:07:13 +00:00
executeGUI: all
make/launchEmulator "$(DISKIMAGE)"
2017-05-17 02:34:15 +00:00
2017-08-31 03:07:13 +00:00
executeShell: all
$(ORCA) $(TARGETDIR)/$(PGM)
2017-05-17 02:34:15 +00:00
$(OBJDIR)/%.a: %.c
$(COMPILE) $< $(@:.a=) $(CFLAGS) --noroot
2017-05-17 02:34:15 +00:00
$(OBJDIR)/%.a: $(GENDIR)/%.c
$(COMPILE) $< $(@:.a=) $(CFLAGS) --noroot
$(OBJDIR)/%.root: %.c
$(COMPILE) $< $(@:.root=) $(CFLAGS)
2017-05-17 02:34:15 +00:00
$(OBJDIR)/%.root: $(GENDIR)/%.c
$(COMPILE) $< $(@:.root=) $(CFLAGS)
$(OBJDIR)/%.ROOT: %.s
MACGENFLAGS="$(MACGENFLAGS)" MACGENMACROS="$(MACGENMACROS)" $(ASSEMBLE) $< $(@:.ROOT=) $(ASMFLAGS)
2017-05-17 02:34:15 +00:00
$(OBJDIR)/%.ROOT: $(GENDIR)/%.s
MACGENFLAGS="$(MACGENFLAGS)" MACGENMACROS="$(MACGENMACROS)" $(ASSEMBLE) $< $(@:.ROOT=) $(ASMFLAGS)
$(OBJDIR)/%.r: %.rez
$(REZ) $< $(@:.r=) $(REZFLAGS)
ifneq ($(RLINT_PATH),)
$(ORCA) $(RLINT_PATH) $@
endif
2017-05-17 02:34:15 +00:00
$(OBJDIR)/%.r: $(GENDIR)/%.rez
$(REZ) $< $(@:.r=) $(REZFLAGS)
ifneq ($(RLINT_PATH),)
$(ORCA) $(RLINT_PATH) $@
endif
2017-05-17 02:34:15 +00:00
$(OBJS): Makefile
# Include the C and rez dependencies which were generated from the last build
# so we recompile correctly on .h file changes.
-include $(ALL_DEPS)