Skip to content

Commit

Permalink
add static library creation for cc65
Browse files Browse the repository at this point in the history
  • Loading branch information
lydon42 committed May 8, 2023
1 parent 36a61ac commit de3d756
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ dkms.conf

# VIM backup files
*~

# subdir work paths
*/work
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

SUBDIRS= \
cc65

.PHONY: all clean cleanall

all:
@for path in $(SUBDIRS); do \
make -C $$path all; \
done

clean:
@for path in $(SUBDIRS); do \
make -C $$path clean; \
done

cleanall:
@for path in $(SUBDIRS); do \
make -C $$path cleanall; \
done

56 changes: 56 additions & 0 deletions cc65/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

SHELL:=/bin/bash

ifdef USE_LOCAL_CC65
# use locally installed binary (requires 'cc65,ld65,etc' to be in the $PATH)
CC65_PREFIX=
else
# use the binary built from the submodule
CC65_PREFIX=$(PWD)/cc65/bin/
endif

CC65=$(CC65_PREFIX)cc65
CA65=$(CC65_PREFIX)ca65 --cpu 4510
AR65=$(CC65_PREFIX)ar65

CFLAGS=-t c64 -I include/

LIB_OBJECTS = \
src/dirent.o \
src/fileio.o \
src/conio.o \
src/debug.o \
src/fat32.o \
src/fcio.o \
src/hal.o \
src/memory.o \
src/mouse.o \
src/random.o \
src/sdcard.o \
src/targets.o \
src/tests.o \
src/time.o

.PHONY: all clean cleanall

all: libmega65.a

clean:
rm -f src/*.o
rm -rf build

cleanall: clean
rm -f libmega65.a

libmega65.a: $(LIB_OBJECTS)
$(AR65) a $@ $^

src/%.o: src/%.s
$(CA65) -o $@ $<

src/%.o: src/%.c
@if [[ ! -d work ]]; then \
mkdir work; \
fi
$(CC65) $(CFLAGS) -o work/$*.s $<
$(CA65) -o $@ work/$*.s

0 comments on commit de3d756

Please sign in to comment.