Re: [cc65] --create-dep for ca65?

From: Oliver Schmidt <ol.sc1web.de>
Date: 2010-05-02 18:01:43
Hi,

> With the exception of the (AFAIR recently discussed but don't remember the conclusion) paths
> for the included files, which seem to be relative to the directory of compiler/assembler invocation
> rather than the location of the source file - everything seems to work perfectly OK!

- The conclusion was that there's no spec saying that what the cc65
compiler/assembler is doing is wrong. It's just not what the user
expects - simply because most other C compilers (i.e. all I personally
know of) do it differently.

- The -I $(SOURCEDIR) options in the Makefile are supposed to
workaround that successfully. Don't they?

> http://zennon.internetdsl.pl/cc65projtest.tar.bz2

Some remarks:

- As the set of .d files is now identical to the set of .o files I
don't see a reason for a DEPENDS variable anymore. In case you don't
agree with me I'd set DEPENDS := $(OBJECTS:.o=.d)

- 'test' is a phony target too.

- The .d files don't need to be parsed for 'love' too, but I don't
think that optimization is worth the complication...

- '--create-full-deps' isn't necessary and turns the Makefile most
certainly useless for Windows users. Uz explicitly added the
capability to omit the system headers using --create-deps for this
reason.

- The use of $* (the stem) is sort of deprecated - the GNU Make
Manual: "You should generally avoid using `$*' except in implicit
rules or static pattern rules."

- Refering to $(OBJECTDIR)/ unnecessarily reduces the reusability of
the cl65 commands. Beside that $(@:.o=.d) just describes the idea
better.

Regards,
Oliver

PROGRAM :=
CC65_TARGET :=

SOURCEDIR :=
OBJECTDIR :=

CFLAGS  =
ASFLAGS =
LDFLAGS =
#LDFLAGS = -m $@.map

EMULATOR := x64
EMUFLAGS = -kernal kernal -VICIIdsize -keymap 1 +autostart-warp
-soundsync 2 -autoload $(PROGRAM)

### DO NOT EDIT BELOW THIS LINE, UNLESS YOU REALLY KNOW WHAT YOU ARE DOING! ###
###############################################################################
# Defaults to be used if nothing defined above                                #
###############################################################################
ifeq ($(PROGRAM),)
PROGRAM := $(notdir $(CURDIR))
endif

ifeq ($(CC65_TARGET),)
CC65_TARGET := c64
endif

ifeq ($(SOURCEDIR),)
SOURCEDIR := src
endif

ifeq ($(OBJECTDIR),)
OBJECTDIR := obj
endif

ifdef $(CC65_HOME)
CC := $(CC65_HOME)/bin/cl65
else
CC := cl65
endif

###############################################################################
### The magic begins                                                        ###
###############################################################################
SOURCES := $(wildcard $(SOURCEDIR)/*.c)
SOURCES += $(wildcard $(SOURCEDIR)/*.s)
OBJECTS := $(addsuffix .o,$(basename $(addprefix
$(OBJECTDIR)/,$(notdir $(SOURCES)))))

.SUFFIXES:
.PHONY: all clean test love
all: $(PROGRAM)

ifneq ($(MAKECMDGOALS),clean)
-include $(OBJECTS:.o=.d)
endif

$(OBJECTDIR):
	mkdir $@

$(OBJECTDIR)/%.o: $(SOURCEDIR)/%.c | $(OBJECTDIR)
	$(CC) -t $(CC65_TARGET) -I $(SOURCEDIR) $(CFLAGS) --create-dep
$(@:.o=.d) -c -o $@ $<

$(OBJECTDIR)/%.o: $(SOURCEDIR)/%.s | $(OBJECTDIR)
	$(CC) -t $(CC65_TARGET) -I $(SOURCEDIR) $(ASFLAGS) --create-dep
$(@:.o=.d) -c -o $@ $<

$(PROGRAM): $(OBJECTS)
	$(CC) -t $(CC65_TARGET) $(LDFLAGS) -o $@ $^

clean:
	rm -f $(OBJECTS) $(OBJECTS:.o=.d) $(PROGRAM) $(PROGRAM).map
	rmdir $(OBJECTDIR)

test: $(PROGRAM)
	$(EMULATOR) $(EMUFLAGS)

love:
	@echo "Not war, eh?"
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sun May 2 18:01:53 2010

This archive was generated by hypermail 2.1.8 : 2010-05-02 18:01:55 CEST