Created
February 6, 2025 06:41
-
-
Save jimbob88/47caeff093cb49859f5f70919c62375c to your computer and use it in GitHub Desktop.
CC65 Makefile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SOURCES = example.c | |
PROGRAM = example | |
ifdef CC65_TARGET | |
CC = cl65 | |
CFLAGS = -t $(CC65_TARGET) -O --create-dep $(<:.c=.d) | |
LDFLAGS = -t $(CC65_TARGET) -m $(PROGRAM).map | |
else | |
CC = gcc | |
CFLAGS = -MMD -MP -O | |
LDFLAGS = -Wl,-Map,$(PROGRAM).map | |
endif | |
OBJECTS := $(SOURCES:.c=.o) | |
DEPS := $(OBJECTS:.o=.d) | |
.SUFFIXES: | |
.PHONY: all clean | |
all: $(PROGRAM) | |
ifneq ($(MAKECMDGOALS),clean) | |
-include $(DEPS) | |
endif | |
%.o: %.c | |
$(CC) -c $(CFLAGS) -o $@ $< | |
$(PROGRAM): $(OBJECTS) | |
$(CC) $(LDFLAGS) -o $@ $^ | |
clean: | |
$(RM) $(OBJECTS) $(DEPS) $(PROGRAM) $(PROGRAM).map |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment