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 # The install prefix and directories
19 exec_prefix = $(prefix)
21 bindir = $(exec_prefix)/bin
22 datadir = $(prefix)/share
23 docdir = $(datadir)/doc
24 libdir = $(exec_prefix)/lib
26 CC65_DOC = $(docdir)/cc65
27 CC65_HOME = $(libdir)/cc65
29 CA65_INC = $(CC65_HOME)/asminc
30 CC65_INC = $(CC65_HOME)/include
31 LD65_CFG = $(CC65_HOME)/cfg
32 LD65_LIB = $(CC65_HOME)/lib
33 LD65_OBJ = $(CC65_HOME)/obj
39 # BSD-like install-script/-program
40 INSTALL = make/install-sh
42 INSTALL_DATA = $(INSTALL) -c -m 644
43 INSTALL_PROG = $(INSTALL) -c -m 755
44 INSTALL_STRIP = $(INSTALL_PROG) -s
46 # This file-name extension is needed on DOS/Windows systems.
53 # The sample and library-test programs must be compiled for only one platform
54 # at a time. So, those rules are done automatically only when a user names
55 # a system on the command-line. (A user can do those rules with their
56 # defaults by putting "all samples tests" on the command-line.)
58 all: bins libs docs $(SYS:%=samples tests)
61 @$(MAKE) -C src -f make/gcc.mak CA65_INC=\\\"${CA65_INC}/\\\" \
62 CC65_INC=\\\"${CC65_INC}/\\\" LD65_CFG=\\\"${LD65_CFG}/\\\" \
63 LD65_LIB=\\\"${LD65_LIB}/\\\" LD65_OBJ=\\\"${LD65_OBJ}/\\\"
68 # This rule won't try to generate HTML files
69 # if a host system doesn't have LinuxDoc Tools.
71 @if linuxdoc -B check doc/index >/dev/null 2>&1; \
72 then $(MAKE) -C doc html; \
73 else echo '"LinuxDoc Tools" is not installed; skipping HTML documentation.'; \
76 # Some platforms cannot compile all of the sample and library-test programs.
77 # So, these rules ignore errors.
80 -@$(MAKE) -k -C samples prefix=$(prefix) $(SYS:%=SYS=%)
83 -@$(MAKE) -k -C testcode/lib prefix=$(prefix) $(SYS:%=SYS=%)
86 @$(MAKE) -C src -f make/gcc.mak $@
89 @$(MAKE) -C samples $@
90 # @$(MAKE) -C testcode/lib $@ $(SYS:%=SYS=%)
92 uninstall: install-test
93 cd $(bindir) && $(RM) ar65${EXT} ca65${EXT} cc65${EXT} cl65${EXT} \
94 co65${EXT} da65${EXT} ld65${EXT} od65${EXT} grc${EXT} ca65html
95 $(RM) -R $(CC65_HOME) $(CC65_DOC)
97 install: install-test install-dirs install-bins install-libs install-docs
99 @echo 'If you put the files into non-standard directories, then'
100 @echo 'you might need to export some shell environment variables:'
102 @echo 'CC65_HOME=$(CC65_HOME)'
104 @echo 'CA65_INC=$(CA65_INC)'
105 @echo 'CC65_INC=$(CC65_INC)'
106 @echo 'LD65_CFG=$(LD65_CFG)'
107 @echo 'LD65_LIB=$(LD65_LIB)'
108 @echo 'LD65_OBJ=$(LD65_OBJ)'
113 @if [ `id -u` != 0 ]; then \
115 echo 'If you are denied permission to install or uninstall this package,'; \
116 echo 'then you will need to do "make/gcc.mak install" or "make/gcc.mak uninstall"'; \
117 echo 'as either the root user or an administrator.'; \
122 install-dirs: $(bindir) $(datadir) $(docdir) $(libdir) \
123 $(CC65_DOC) $(CC65_HOME) \
124 $(CA65_INC) $(CC65_INC) \
125 $(CC65_INC)/em $(CC65_INC)/geos $(CC65_INC)/joystick \
126 $(CC65_INC)/mouse $(CC65_INC)/sys $(CC65_INC)/tgi \
127 $(LD65_CFG) $(LD65_LIB) $(LD65_OBJ) \
128 $(CC65_HOME)/emd $(CC65_HOME)/joy $(CC65_HOME)/mou \
129 $(CC65_HOME)/ser $(CC65_HOME)/tgi
131 $(bindir) $(datadir) $(docdir) $(libdir) \
132 $(CC65_DOC) $(CC65_HOME) \
133 $(CA65_INC) $(CC65_INC) \
134 $(LD65_CFG) $(LD65_LIB) $(LD65_OBJ):
137 $(CC65_HOME)/% $(CC65_INC)/% $(CC65_DOC)/%:
141 for f in ar65 ca65 cc65 cl65 co65 da65 ld65 od65 grc; \
142 do $(INSTALL_STRIP) src/$$f/$$f${EXT} $(bindir) || exit $$?; \
144 $(INSTALL_PROG) src/ca65html/ca65html $(bindir)
147 for f in asminc/*.inc; \
148 do $(INSTALL_DATA) $$f $(CA65_INC) || exit $$?; \
150 for f in include/*.h; \
151 do $(INSTALL_DATA) $$f $(CC65_INC) || exit $$?; \
153 for d in em geos joystick mouse sys tgi; \
154 do for f in include/$$d/*.h; \
155 do $(INSTALL_DATA) $$f $(CC65_INC)/$$d || exit $$?; \
158 for f in libsrc/*.lib; \
159 do $(INSTALL_DATA) $$f $(LD65_LIB) || exit $$?; \
161 for f in libsrc/*-*.o; \
162 do $(INSTALL_DATA) $$f $(LD65_OBJ) || exit $$?; \
164 for d in emd joy mou ser tgi; \
165 do for f in libsrc/*.$$d; \
166 do $(INSTALL_DATA) $$f $(CC65_HOME)/$$d || exit $$?; \
169 for f in src/ld65/cfg/*-*.cfg; \
170 do $(INSTALL_DATA) $$f $(LD65_CFG) || exit $$?; \
174 for f in src/ca65/macpack/*.mac; \
175 do $(INSTALL_DATA) $$f $(CC65_DOC) || exit $$?; \
177 for f in readme.1st compile.txt CREDITS BUGS internal.txt newvers.txt; \
178 do $(INSTALL_DATA) doc/$$f $(CC65_DOC) || exit $$?; \
180 if [ -f doc/index.htm* ]; \
181 then for f in doc/*.htm*; \
182 do $(INSTALL_DATA) $$f $(CC65_DOC) || exit $$?; \
186 install-samps: ${addprefix $(CC65_DOC)/, $(shell find samples -type d)}
187 @$(MAKE) -C samples zap
188 for d in `find samples -type d`; \
191 then $(INSTALL_DATA) $$f $(CC65_DOC)/$$d || exit $$?; \