Add the ability to link in drivers by just enabling them in the root Makefile

This commit is contained in:
Jeremy Rand 2018-06-14 23:51:01 -04:00
parent 0d9c1a6333
commit 2990c4cb53
3 changed files with 216 additions and 7 deletions

112
Makefile
View File

@ -81,6 +81,118 @@ SRCDIRS+=
# this variable: # this variable:
# LDFLAGS += -v # LDFLAGS += -v
# If you want to link the lores graphics driver with your executable,
# uncomment the next line.
# DRIVERS += loresgr
#
# To use the lores driver, add code which looks like this to your
# project:
#
# #include "drivers/a2_lores_drv.h"
# int main(void)
# {
# tgi_install(&a2_lores_drv);
# tgi_init();
# // Use the graphics driver
# tgi_uninstall();
# }
#
# Read the /usr/local/lib/cc65/include/tgi.h file to see what the
# driver interface provides. Also check out
# /usr/local/lib/cc65/include/apple2.h to see the colour definitions.
# If you want to link the hires graphics driver with your executable,
# uncomment the next line.
# DRIVERS += hiresgr
#
# To use the hires driver, add code which looks like this to your
# project:
#
# #include "drivers/a2_hires_drv.h"
# int main(void)
# {
# tgi_install(&a2_hires_drv);
# tgi_init();
# // Use the graphics driver
# tgi_uninstall();
# }
#
# Read the /usr/local/lib/cc65/include/tgi.h file to see what the
# driver interface provides. Also check out
# /usr/local/lib/cc65/include/apple2.h to see the colour definitions.
# If you want to link the extended memory driver with your executable,
# uncomment the next line.
# DRIVERS += auxmem
#
# To use the auxmem driver, add code which looks like this to your
# project:
#
# #include "drivers/a2_auxmem_drv.h"
# int main(void)
# {
# em_install(&a2_auxmem_drv);
# // Use the auxmem driver
# em_uninstall();
# }
#
# Read the /usr/local/lib/cc65/include/em.h file to see what the
# driver interface provides.
# If you want to link the joystick driver with your executable,
# uncomment the next line.
# DRIVERS += joystick
#
# To use the joystick driver, add code which looks like this to your
# project:
#
# #include "drivers/a2_joystick_drv.h"
# int main(void)
# {
# joy_install(&a2_joystick_drv);
# // Use the joystick driver
# joy_uninstall();
# }
#
# Read the /usr/local/lib/cc65/include/joystick.h file to see what the
# driver interface provides.
# If you want to link the mouse driver with your executable,
# uncomment the next line.
# DRIVERS += mouse
#
# To use the mouse driver, add code which looks like this to your
# project:
#
# #include "drivers/a2_mouse_drv.h"
# int main(void)
# {
# mouse_install(&mouse_def_callbacks, &a2_mouse_drv);
# // Use the mouse driver
# mouse_uninstall();
# }
#
# Read the /usr/local/lib/cc65/include/mouse.h file to see what the
# driver interface provides.
# If you want to link the serial driver with your executable,
# uncomment the next line.
# DRIVERS += serial
#
# To use the serial driver, add code which looks like this to your
# project:
#
# #include "drivers/a2_serial_drv.h"
# int main(void)
# {
# ser_install(&a2_serial_drv);
# // Use the serial driver
# ser_uninstall();
# }
#
# Read the /usr/local/lib/cc65/include/serial.h file to see what the
# driver interface provides.
# If you have java installed in a non-standard location, you can set # If you have java installed in a non-standard location, you can set
# the path to it by uncommenting the following line: # the path to it by uncommenting the following line:
# export JAVA=/usr/bin/java # export JAVA=/usr/bin/java

View File

@ -17,6 +17,7 @@ CC65_BIN = /usr/local/bin
CL65=$(CC65_BIN)/cl65 CL65=$(CC65_BIN)/cl65
CA65=$(CC65_BIN)/ca65 CA65=$(CC65_BIN)/ca65
CC65=$(CC65_BIN)/cc65 CC65=$(CC65_BIN)/cc65
CO65=$(CC65_BIN)/co65
AC=make/AppleCommander.jar AC=make/AppleCommander.jar
@ -27,6 +28,8 @@ CPU=6502
CFLAGS= CFLAGS=
ASMFLAGS= ASMFLAGS=
LDFLAGS= LDFLAGS=
DRIVERS=
DRVDIR=drivers
XCODE_PATH=/Applications/Xcode.app XCODE_PATH=/Applications/Xcode.app
XCODE_INFO=$(XCODE_PATH)/Contents/Info.plist XCODE_INFO=$(XCODE_PATH)/Contents/Info.plist
@ -37,13 +40,9 @@ CC65_PLUGIN_INFO=$(CC65_PLUGIN_PATH)/Contents/Info.plist
XCODE_PLUGIN_COMPATIBILITY=DVTPlugInCompatibilityUUID XCODE_PLUGIN_COMPATIBILITY=DVTPlugInCompatibilityUUID
.PHONY: all gen genclean xcodefix .PHONY: all gen genclean
all: all:
@make xcodefix
@make gen @make gen
@make build @make build
xcodefix:
defaults write "$(CC65_PLUGIN_INFO)" $(XCODE_PLUGIN_COMPATIBILITY)s -array `defaults read "$(XCODE_INFO)" $(XCODE_PLUGIN_COMPATIBILITY)`

View File

@ -14,6 +14,10 @@ export PATH := $(PATH):$(CC65_BIN)
CWD=$(shell pwd) CWD=$(shell pwd)
ifneq ($(DRIVERS),)
SRCDIRS+=$(DRVDIR)
endif
C_SRCS=$(patsubst ./%, %, $(wildcard $(addsuffix /*.c, $(SRCDIRS)))) C_SRCS=$(patsubst ./%, %, $(wildcard $(addsuffix /*.c, $(SRCDIRS))))
C_OBJS=$(C_SRCS:.c=.o) C_OBJS=$(C_SRCS:.c=.o)
C_DEPS=$(C_SRCS:.c=.u) C_DEPS=$(C_SRCS:.c=.u)
@ -57,6 +61,13 @@ ifneq ($(filter $(MACHINE), apple2 apple2enh apple2-dos33 apple2enh-dos33),)
EXECCMD=$(shell echo brun $(PGM) | tr '[a-z]' '[A-Z]') EXECCMD=$(shell echo brun $(PGM) | tr '[a-z]' '[A-Z]')
endif endif
# By default, use the a2 drivers. If the machine is one of the enhanced
# targets though, use the a2e drivers.
DRV_BASE_MACHINE=a2
ifneq ($(filter $(MACHINE), apple2enh apple2enh-dos33 apple2enh-system apple2enh-loader apple2enh-reboot),)
DRV_BASE_MACHINE=a2e
endif
MACHCONFIG= -t apple2 MACHCONFIG= -t apple2
ifneq ($(filter $(MACHINE), apple2enh apple2apple2enh-dos33 apple2enh-system apple2enh-loader apple2enh-reboot),) ifneq ($(filter $(MACHINE), apple2enh apple2apple2enh-dos33 apple2enh-system apple2enh-loader apple2enh-reboot),)
@ -67,17 +78,18 @@ ifeq ($(filter $(MACHINE), apple2 apple2enh),)
MACHCONFIG += -C $(MACHINE).cfg MACHCONFIG += -C $(MACHINE).cfg
endif endif
.PHONY: build execute clean .PHONY: build execute clean xcodefix loresgr hiresgr auxmem joystick mouse serial
build: $(ALLTARGET) build: $(ALLTARGET)
clean: clean: genclean
rm -f "$(PGM)" rm -f "$(PGM)"
rm -f $(OBJS) rm -f $(OBJS)
rm -f $(C_DEPS) rm -f $(C_DEPS)
rm -f $(MAPFILE) rm -f $(MAPFILE)
rm -f $(ASM_LSTS) rm -f $(ASM_LSTS)
rm -f "$(DISKIMAGE)" rm -f "$(DISKIMAGE)"
rm -Rf "$(DRVDIR)"
cleanMacCruft: cleanMacCruft:
rm -rf pkg rm -rf pkg
@ -101,4 +113,90 @@ execute: $(DISKIMAGE)
$(OBJS): Makefile $(OBJS): Makefile
# Some gen phase stuff...
gen: xcodefix $(DRIVERS)
xcodefix:
defaults write "$(CC65_PLUGIN_INFO)" $(XCODE_PLUGIN_COMPATIBILITY)s -array `defaults read "$(XCODE_INFO)" $(XCODE_PLUGIN_COMPATIBILITY)`
# Lores driver codegen
loresgr: $(DRVDIR)/a2_lores_drv.s $(DRVDIR)/a2_lores_drv.h
$(DRVDIR)/a2_lores_drv.s: $(CC65_HOME)/tgi/$(DRV_BASE_MACHINE).lo.tgi
mkdir -p $(DRVDIR)
$(CO65) --code-label _a2_lores_drv -o $@ $(CC65_HOME)/tgi/$(DRV_BASE_MACHINE).lo.tgi
$(DRVDIR)/a2_lores_drv.h:
mkdir -p $(DRVDIR)
echo '#include <tgi.h>' > $@
echo 'extern char a2_lores_drv;' >> $@
# Hires driver codegen
hiresgr: $(DRVDIR)/a2_hires_drv.s $(DRVDIR)/a2_hires_drv.h
$(DRVDIR)/a2_hires_drv.s: $(CC65_HOME)/tgi/$(DRV_BASE_MACHINE).hi.tgi
mkdir -p $(DRVDIR)
$(CO65) --code-label _a2_hires_drv -o $@ $(CC65_HOME)/tgi/$(DRV_BASE_MACHINE).hi.tgi
$(DRVDIR)/a2_hires_drv.h:
mkdir -p $(DRVDIR)
echo '#include <tgi.h>' > $@
echo 'extern char a2_hires_drv;' >> $@
# Auxmem driver codegen
auxmem: $(DRVDIR)/a2_auxmem_drv.s $(DRVDIR)/a2_auxmem_drv.h
$(DRVDIR)/a2_auxmem_drv.s: $(CC65_HOME)/emd/$(DRV_BASE_MACHINE).auxmem.emd
mkdir -p $(DRVDIR)
$(CO65) --code-label _a2_auxmem_drv -o $@ $(CC65_HOME)/emd/$(DRV_BASE_MACHINE).auxmem.emd
$(DRVDIR)/a2_auxmem_drv.h:
mkdir -p $(DRVDIR)
echo '#include <em.h>' > $@
echo 'extern char a2_auxmem_drv;' >> $@
# Joystick driver codegen
joystick: $(DRVDIR)/a2_joystick_drv.s $(DRVDIR)/a2_joystick_drv.h
$(DRVDIR)/a2_joystick_drv.s: $(CC65_HOME)/joy/$(DRV_BASE_MACHINE).stdjoy.joy
mkdir -p $(DRVDIR)
$(CO65) --code-label _a2_joystick_drv -o $@ $(CC65_HOME)/joy/$(DRV_BASE_MACHINE).stdjoy.joy
$(DRVDIR)/a2_joystick_drv.h:
mkdir -p $(DRVDIR)
echo '#include <joystick.h>' > $@
echo 'extern char a2_joystick_drv;' >> $@
# Mouse driver codegen
mouse: $(DRVDIR)/a2_mouse_drv.s $(DRVDIR)/a2_mouse_drv.h
$(DRVDIR)/a2_mouse_drv.s: $(CC65_HOME)/mou/$(DRV_BASE_MACHINE).stdmou.mou
mkdir -p $(DRVDIR)
$(CO65) --code-label _a2_mouse_drv -o $@ $(CC65_HOME)/mou/$(DRV_BASE_MACHINE).stdmou.mou
$(DRVDIR)/a2_mouse_drv.h:
mkdir -p $(DRVDIR)
echo '#include <mouse.h>' > $@
echo 'extern char a2_mouse_drv;' >> $@
# Serial driver codegen
serial: $(DRVDIR)/a2_serial_drv.s $(DRVDIR)/a2_serial_drv.h
$(DRVDIR)/a2_serial_drv.s: $(CC65_HOME)/ser/$(DRV_BASE_MACHINE).ssc.ser
mkdir -p $(DRVDIR)
$(CO65) --code-label _a2_serial_drv -o $@ $(CC65_HOME)/ser/$(DRV_BASE_MACHINE).ssc.ser
$(DRVDIR)/a2_serial_drv.h:
mkdir -p $(DRVDIR)
echo '#include <serial.h>' > $@
echo 'extern char a2_serial_drv;' >> $@
-include $(C_DEPS) -include $(C_DEPS)