5 # This makefile is maintained by Greg King <greg.king4@verizon.net>.
7 # Goals that are supported by the cc65 package
8 .PHONY: all bins libs docs samples tests clean zap
9 .PHONY: uninstall install install-bins install-libs install-docs install-samps
11 # If SYS is defined on this makefile's command-line, then we want it to go
12 # to "samples" and "tests", but not to the other rules. So, we disable a
13 # feature of GNU make that would have given ${SYS} to every sub-make.
15 # (That trick has been disabled.)
17 # To compile with custom make-options, set them here; for example:
18 #MAKEOPTS = -j 2 CFLAGS=-O4 CC=clang
21 # The install prefix and directories
23 exec_prefix = $(prefix)
25 bindir = $(exec_prefix)/bin
26 datadir = $(prefix)/share
27 docdir = $(datadir)/doc
28 libdir = $(exec_prefix)/lib
30 CC65_DOC = $(docdir)/cc65
31 CC65_HOME = $(libdir)/cc65
33 CA65_INC = $(CC65_HOME)/asminc
34 CC65_INC = $(CC65_HOME)/include
35 LD65_CFG = $(CC65_HOME)/cfg
36 LD65_LIB = $(CC65_HOME)/lib
37 LD65_OBJ = $(CC65_HOME)/obj
43 # BSD-like install-script/-program
44 INSTALL = make/install-sh
46 INSTALL_DATA = $(INSTALL) -c -m 644
47 INSTALL_PROG = $(INSTALL) -c -m 755
48 INSTALL_STRIP = $(INSTALL_PROG) -s
50 # This file-name extension is needed on DOS/Windows systems.
57 # The sample and library-test programs must be compiled for only one platform
58 # at a time. So, those rules are done automatically only when a user names
59 # a system on the command-line. (A user can do those rules with their
60 # defaults by putting "all samples tests" on the command-line.)
62 all: bins libs docs $(SYS:%=samples tests)
65 @$(MAKE) -C src -f make/gcc.mak $(MAKEOPTS) \
66 CA65_INC=\\\"${CA65_INC}/\\\" CC65_INC=\\\"${CC65_INC}/\\\" \
67 LD65_CFG=\\\"${LD65_CFG}/\\\" LD65_LIB=\\\"${LD65_LIB}/\\\" \
68 LD65_OBJ=\\\"${LD65_OBJ}/\\\"
73 # This rule won't try to generate HTML files
74 # if a host system doesn't have LinuxDoc Tools.
76 @if linuxdoc -B check doc/index >/dev/null 2>&1; \
77 then $(MAKE) -C doc $(MAKEOPTS) html; \
78 else echo '"LinuxDoc Tools" is not installed; skipping HTML documentation.'; \
81 # Some platforms cannot compile all of the sample and library-test programs.
82 # So, these rules ignore errors.
85 -@$(MAKE) -k -C samples prefix=$(prefix) $(SYS:%=SYS=%)
88 -@$(MAKE) -k -C testcode/lib prefix=$(prefix) $(SYS:%=SYS=%)
91 @$(MAKE) -C src -f make/gcc.mak $@
94 @$(MAKE) -C samples $@
95 # @$(MAKE) -C testcode/lib $@ $(SYS:%=SYS=%)
97 uninstall: install-test
98 cd $(bindir) && $(RM) ar65${EXT} ca65${EXT} cc65${EXT} cl65${EXT} \
99 co65${EXT} da65${EXT} ld65${EXT} od65${EXT} grc65${EXT} ca65html
100 $(RM) -R $(CC65_HOME) $(CC65_DOC)
102 install: install-test install-dirs install-bins install-libs install-docs
104 @echo 'If you put the files into non-standard directories, then'
105 @echo 'you might need to export some shell environment variables:'
107 @echo 'CC65_HOME=$(CC65_HOME)'
109 @echo 'CA65_INC=$(CA65_INC)'
110 @echo 'CC65_INC=$(CC65_INC)'
111 @echo 'LD65_CFG=$(LD65_CFG)'
112 @echo 'LD65_LIB=$(LD65_LIB)'
113 @echo 'LD65_OBJ=$(LD65_OBJ)'
118 @if [ `id -u` != 0 ]; then \
120 echo 'If you are denied permission to install or uninstall this package,'; \
121 echo 'then you will need to do "make/gcc.mak install" or "make/gcc.mak uninstall"'; \
122 echo 'as either the root user or an administrator.'; \
127 install-dirs: $(bindir) $(datadir) $(docdir) $(libdir) \
128 $(CC65_DOC) $(CC65_HOME) \
129 $(CA65_INC) $(CC65_INC) \
130 $(CC65_INC)/em $(CC65_INC)/geos $(CC65_INC)/joystick \
131 $(CC65_INC)/mouse $(CC65_INC)/sys $(CC65_INC)/tgi \
132 $(LD65_CFG) $(LD65_LIB) $(LD65_OBJ) \
133 $(CC65_HOME)/emd $(CC65_HOME)/joy $(CC65_HOME)/mou \
134 $(CC65_HOME)/ser $(CC65_HOME)/tgi
136 $(bindir) $(datadir) $(docdir) $(libdir) \
137 $(CC65_DOC) $(CC65_HOME) \
138 $(CA65_INC) $(CC65_INC) \
139 $(LD65_CFG) $(LD65_LIB) $(LD65_OBJ):
142 $(CC65_HOME)/% $(CC65_INC)/% $(CC65_DOC)/%:
146 for f in ar65 ca65 cc65 cl65 co65 da65 ld65 od65 grc65; \
147 do $(INSTALL_STRIP) src/$$f/$$f${EXT} $(bindir) || exit $$?; \
149 $(INSTALL_PROG) src/ca65html/ca65html $(bindir)
152 for f in asminc/*.inc; \
153 do $(INSTALL_DATA) $$f $(CA65_INC) || exit $$?; \
155 for f in include/*.h; \
156 do $(INSTALL_DATA) $$f $(CC65_INC) || exit $$?; \
158 for d in em geos joystick mouse sys tgi; \
159 do for f in include/$$d/*.h; \
160 do $(INSTALL_DATA) $$f $(CC65_INC)/$$d || exit $$?; \
163 for f in libsrc/*.lib; \
164 do $(INSTALL_DATA) $$f $(LD65_LIB) || exit $$?; \
166 for f in libsrc/*-*.o; \
167 do $(INSTALL_DATA) $$f $(LD65_OBJ) || exit $$?; \
169 for d in emd joy mou ser tgi; \
170 do for f in libsrc/*.$$d; \
171 do $(INSTALL_DATA) $$f $(CC65_HOME)/$$d || exit $$?; \
174 for f in src/ld65/cfg/*-*.cfg; \
175 do $(INSTALL_DATA) $$f $(LD65_CFG) || exit $$?; \
179 for f in src/ca65/macpack/*.mac; \
180 do $(INSTALL_DATA) $$f $(CC65_DOC) || exit $$?; \
182 for f in readme.1st compile.txt CREDITS BUGS internal.txt newvers.txt; \
183 do $(INSTALL_DATA) doc/$$f $(CC65_DOC) || exit $$?; \
185 if [ -f doc/index.htm* ]; \
186 then for f in doc/*.htm*; \
187 do $(INSTALL_DATA) $$f $(CC65_DOC) || exit $$?; \
191 install-samps: ${addprefix $(CC65_DOC)/, $(shell find samples -type d)}
192 @$(MAKE) -C samples zap
193 for d in `find samples -type d`; \
196 then $(INSTALL_DATA) $$f $(CC65_DOC)/$$d || exit $$?; \