mirror of
https://github.com/cc65/cc65.git
synced 2025-01-10 19:29:45 +00:00
Fixed typos and line endings.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4292 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
811ef2f04c
commit
7608ec3c63
338
doc/make.sgml
338
doc/make.sgml
@ -1,169 +1,169 @@
|
|||||||
<!doctype linuxdoc system>
|
<!doctype linuxdoc system>
|
||||||
|
|
||||||
<article>
|
<article>
|
||||||
|
|
||||||
<title>Using GNU Make with cc65
|
<title>Using GNU Make with cc65
|
||||||
<author>Oliver Schmidt, <htmlurl url="mailto:ol.sc@web.de" name="ol.sc@web.de">
|
<author>Oliver Schmidt, <htmlurl url="mailto:ol.sc@web.de" name="ol.sc@web.de">
|
||||||
<date>26.06.2009
|
<date>2009-06-26
|
||||||
|
|
||||||
<abstract>
|
<abstract>
|
||||||
How to build your program using the GNU Make utility.
|
How to build your program using the GNU Make utility.
|
||||||
</abstract>
|
</abstract>
|
||||||
|
|
||||||
<!-- Table of contents -->
|
<!-- Table of contents -->
|
||||||
<toc>
|
<toc>
|
||||||
|
|
||||||
<!-- Begin the document -->
|
<!-- Begin the document -->
|
||||||
|
|
||||||
<sect>Overview<p>
|
<sect>Overview<p>
|
||||||
|
|
||||||
This document describes how to build your programs using the cc65 development
|
This document describes how to build your programs using the cc65 development
|
||||||
tools and the GNU Make utility.
|
tools and the GNU Make utility.
|
||||||
|
|
||||||
The cc65 development package doesn't come with a make utility. However this is
|
The cc65 development package doesn't come with a make utility. However this is
|
||||||
no issue because GNU Make works very nicely with cc65.
|
no issue because GNU Make works very nicely with cc65.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<sect>What is GNU Make?<p>
|
<sect>What is GNU Make?<p>
|
||||||
|
|
||||||
GNU Make is a both very powerful and very popular make utility. It might even
|
GNU Make is a both very powerful and very popular make utility. It might even
|
||||||
be called the de facto standard for make utilities. For more information see
|
be called the de facto standard for make utilities. For more information see
|
||||||
the GNU Make home page:
|
the GNU Make home page:
|
||||||
|
|
||||||
<url url="http://www.gnu.org/software/make/">
|
<url url="http://www.gnu.org/software/make/">
|
||||||
|
|
||||||
The cc65 development package is available as binaries for several host systems
|
The cc65 development package is available as binaries for several host systems
|
||||||
and can easily built for quite some additional systems. The very same is true
|
and can easily built for quite some additional systems. The very same is true
|
||||||
for GNU Make so a cc65-based project coming with a GNU Make Makefile can easily
|
for GNU Make so a cc65-based project coming with a GNU Make Makefile can easily
|
||||||
be built by any cc65 developer no matter what host system is used.
|
be built by any cc65 developer no matter what host system is used.
|
||||||
|
|
||||||
Because of the strong alignment of the cc65 compiler with the ISO C standard it
|
Because of the strong alignment of the cc65 compiler with the ISO C standard it
|
||||||
is very well feasable to compile a single C code base both with the cc65
|
is very well feasible to compile a single C code base both with the cc65
|
||||||
compiler and other C compilers like for example GCC. GNU Make turns out to be
|
compiler and other C compilers like for example GCC. GNU Make turns out to be
|
||||||
very well suited to build projects for several target systems using multiple
|
very well suited to build projects for several target systems using multiple
|
||||||
compilers as it isn't tied to any C compiler.
|
compilers as it isn't tied to any C compiler.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<sect>A sample Makefile<p>
|
<sect>A sample Makefile<p>
|
||||||
|
|
||||||
This Makefile is a fully functional sample for compiling several C sources
|
This Makefile is a fully functional sample for compiling several C sources
|
||||||
(here <tt/foo.c/ and <tt/bar.c/) and link the resulting object files into an
|
(here <tt/foo.c/ and <tt/bar.c/) and link the resulting object files into an
|
||||||
executable program (here <tt/foobar/):
|
executable program (here <tt/foobar/):
|
||||||
|
|
||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
SOURCES = foo.c bar.c
|
SOURCES = foo.c bar.c
|
||||||
|
|
||||||
PROGRAM = foobar
|
PROGRAM = foobar
|
||||||
|
|
||||||
ifdef CC65_TARGET
|
ifdef CC65_TARGET
|
||||||
CC = $(CC65_HOME)/bin/cl65
|
CC = $(CC65_HOME)/bin/cl65
|
||||||
CFLAGS = -t $(CC65_TARGET) --create-dep -O
|
CFLAGS = -t $(CC65_TARGET) --create-dep -O
|
||||||
LDFLAGS = -t $(CC65_TARGET) -m $(PROGRAM).map
|
LDFLAGS = -t $(CC65_TARGET) -m $(PROGRAM).map
|
||||||
else
|
else
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -MMD -MP -O
|
CFLAGS = -MMD -MP -O
|
||||||
LDFLAGS = -Wl,-Map,$(PROGRAM).map
|
LDFLAGS = -Wl,-Map,$(PROGRAM).map
|
||||||
endif
|
endif
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
|
|
||||||
ifdef CC65_TARGET
|
ifdef CC65_TARGET
|
||||||
define MAKEDEPEND
|
define MAKEDEPEND
|
||||||
sed -e"s!.s:!.o:!p" -e"s![^\t]*\t\(.*\)!\1:!" < $(<:.c=.u) > $(@:.o=.d)
|
sed -e"s!.s:!.o:!p" -e"s![^\t]*\t\(.*\)!\1:!" < $(<:.c=.u) > $(@:.o=.d)
|
||||||
rm -f $(<:.c=.u)
|
rm -f $(<:.c=.u)
|
||||||
endef
|
endef
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: $(PROGRAM)
|
all: $(PROGRAM)
|
||||||
|
|
||||||
ifneq ($(MAKECMDGOALS),clean)
|
ifneq ($(MAKECMDGOALS),clean)
|
||||||
-include $(SOURCES:.c=.d)
|
-include $(SOURCES:.c=.d)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(SOURCES:.c=.o) $(SOURCES:.c=.d) $(PROGRAM) $(PROGRAM).map
|
rm -f $(SOURCES:.c=.o) $(SOURCES:.c=.d) $(PROGRAM) $(PROGRAM).map
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(CC) -c $(CFLAGS) $< -o $@
|
$(CC) -c $(CFLAGS) $< -o $@
|
||||||
@$(MAKEDEPEND)
|
@$(MAKEDEPEND)
|
||||||
|
|
||||||
$(PROGRAM): $(SOURCES:.c=.o)
|
$(PROGRAM): $(SOURCES:.c=.o)
|
||||||
$(CC) $(LDFLAGS) $^ -o $@
|
$(CC) $(LDFLAGS) $^ -o $@
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
|
|
||||||
|
|
||||||
<sect1>Invoking the sample Makefile<p>
|
<sect1>Invoking the sample Makefile<p>
|
||||||
|
|
||||||
Without any specific configuration the sample Makefile will compile and link
|
Without any specific configuration the sample Makefile will compile and link
|
||||||
using GCC. In order to rather use cc65 the variable <tt/CC65_TARGET/ needs to be
|
using GCC. In order to rather use cc65 the variable <tt/CC65_TARGET/ needs to be
|
||||||
defined. This may by done as an environment variable or simply as part of the
|
defined. This may by done as an environment variable or simply as part of the
|
||||||
Makefile. However to quickly switch between compilers and/or cc65 targets it is
|
Makefile. However to quickly switch between compilers and/or cc65 targets it is
|
||||||
best done on the GNU Make command line like this:
|
best done on the GNU Make command line like this:
|
||||||
|
|
||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
make CC65_TARGET=c64
|
make CC65_TARGET=c64
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
|
|
||||||
The sample Makefile doesn't require cc65 to be "installed" in any way. Rather it
|
The sample Makefile doesn't require cc65 to be "installed" in any way. Rather it
|
||||||
only presumes the single variable <tt/CC65_HOME/ to point to the directory the
|
only presumes the single variable <tt/CC65_HOME/ to point to the directory the
|
||||||
cc65 packages were unpacked into. Again there are several ways to define this
|
cc65 packages were unpacked into. Again there are several ways to define this
|
||||||
variable but as its value typically won't change often it is best done as an
|
variable but as its value typically won't change often it is best done as an
|
||||||
environment variable.
|
environment variable.
|
||||||
|
|
||||||
|
|
||||||
<sect1>Understanding the sample Makefile<p>
|
<sect1>Understanding the sample Makefile<p>
|
||||||
|
|
||||||
Most parts of the sample Makefile follow the guidlines in the
|
Most parts of the sample Makefile follow the guidelines in the
|
||||||
<htmlurl url="http://www.gnu.org/software/make/manual/make.html" name="GNU Make Manual">
|
<htmlurl url="http://www.gnu.org/software/make/manual/make.html" name="GNU Make Manual">
|
||||||
that can be searched online for background information. The automatic generation of
|
that can be searched online for background information. The automatic generation of
|
||||||
dependency however rather works as described by the GNU Make maintainer Paul D. Smith in
|
dependency however rather works as described by the GNU Make maintainer Paul D. Smith in
|
||||||
<htmlurl url="http://make.paulandlesley.org/autodep.html#advanced" name="Advanced Auto-Dependencies">.
|
<htmlurl url="http://make.paulandlesley.org/autodep.html#advanced" name="Advanced Auto-Dependencies">.
|
||||||
|
|
||||||
In the meantime GCC supports this method directly with the preprocessor option
|
In the meantime GCC supports this method directly with the preprocessor option
|
||||||
<tt/-MP/ while cc65 requires some post-processing of the dependency file with
|
<tt/-MP/ while cc65 requires some post-processing of the dependency file with
|
||||||
<tt/sed/ adding a second line like in this example:
|
<tt/sed/ adding a second line like in this example:
|
||||||
|
|
||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
foo.o: foo.c foo.h bar.h
|
foo.o: foo.c foo.h bar.h
|
||||||
foo.c foo.h bar.h:
|
foo.c foo.h bar.h:
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
|
|
||||||
|
|
||||||
<sect1>Invoking the sample Makefile on Windows<p>
|
<sect1>Invoking the sample Makefile on Windows<p>
|
||||||
|
|
||||||
The recommended way to use GNU Make on Windows is to install it as part of a
|
The recommended way to use GNU Make on Windows is to install it as part of a
|
||||||
Cygwin environment. For more information see the Cygwin home page:
|
Cygwin environment. For more information see the Cygwin home page:
|
||||||
|
|
||||||
<url url="http://www.cygwin.com/">
|
<url url="http://www.cygwin.com/">
|
||||||
|
|
||||||
If however installing Cygwin shouldn't be an option for one or the other reason
|
If however installing Cygwin shouldn't be an option for one or the other reason
|
||||||
then the sample Makefile may be invoked from the Windows Command Prompt (cmd.exe)
|
then the sample Makefile may be invoked from the Windows Command Prompt (cmd.exe)
|
||||||
by downloading the following programs:
|
by downloading the following programs:
|
||||||
|
|
||||||
<itemize>
|
<itemize>
|
||||||
<item>make.exe: <url url="http://gnuwin32.sourceforge.net/packages/make.htm">
|
<item>make.exe: <url url="http://gnuwin32.sourceforge.net/packages/make.htm">
|
||||||
<item>sed.exe: <url url="http://gnuwin32.sourceforge.net/packages/sed.htm">
|
<item>sed.exe: <url url="http://gnuwin32.sourceforge.net/packages/sed.htm">
|
||||||
<item>rm.exe: <url url="http://gnuwin32.sourceforge.net/packages/coreutils.htm">
|
<item>rm.exe: <url url="http://gnuwin32.sourceforge.net/packages/coreutils.htm">
|
||||||
</itemize>
|
</itemize>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<sect>Target-specific Variable Values<p>
|
<sect>Target-specific Variable Values<p>
|
||||||
|
|
||||||
The very limited resources of the cc65 target machines now and then require
|
The very limited resources of the cc65 target machines now and then require
|
||||||
manual optimization of the build process by compiling individual source files
|
manual optimization of the build process by compiling individual source files
|
||||||
with different compiler options. GNU Make offers
|
with different compiler options. GNU Make offers
|
||||||
<htmlurl url="http://www.gnu.org/software/make/manual/html_node/Target_002dspecific.html" name="Target-specific Variable Values">
|
<htmlurl url="http://www.gnu.org/software/make/manual/html_node/Target_002dspecific.html" name="Target-specific Variable Values">
|
||||||
perfectly suited for doing so. For example placing the code of the two modules
|
perfectly suited for doing so. For example placing the code of the two modules
|
||||||
<tt/foo/ and <tt/bar/ in the segment <tt/FOOBAR/ can be archived with this
|
<tt/foo/ and <tt/bar/ in the segment <tt/FOOBAR/ can be archived with this
|
||||||
target-specific variable definition:
|
target-specific variable definition:
|
||||||
|
|
||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
foo.o bar.o: CFLAGS += --code-name FOOBAR
|
foo.o bar.o: CFLAGS += --code-name FOOBAR
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
|
|
||||||
</article>
|
</article>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user