]> git.sur5r.net Git - cc65/blob - make/gcc.mak
An assignment for the ZPSAVE segment was missing in the linker config for the
[cc65] / make / gcc.mak
1 #! /usr/bin/make -f
2 # -*- make -*-
3 #
4 # Main gcc Makefile.
5 # This makefile is maintained by Greg King <greg.king4@verizon.net>.
6
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
10
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.
14 #MAKEOVERRIDES=
15 # (That trick has been disabled.)
16
17 # To compile with custom make-options, set them here; for example:
18 #MAKEOPTS = -j 2 CFLAGS=-O4 CC=clang
19 MAKEOPTS =
20
21 # The install prefix and directories
22 prefix          = /usr/local
23 exec_prefix     = $(prefix)
24
25 bindir          = $(exec_prefix)/bin
26 datadir         = $(prefix)/share
27 docdir          = $(datadir)/doc
28 libdir          = $(exec_prefix)/lib
29
30 CC65_DOC        = $(docdir)/cc65
31 CC65_HOME       = $(libdir)/cc65
32
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
38
39 # Programs
40
41 MKDIR           = mkdir -m 755
42
43 # BSD-like install-script/-program
44 INSTALL         = make/install-sh
45
46 INSTALL_DATA    = $(INSTALL) -c -m 644
47 INSTALL_PROG    = $(INSTALL) -c -m 755
48 INSTALL_STRIP   = $(INSTALL_PROG) -s
49
50 # This file-name extension is needed on DOS/Windows systems.
51 ifdef COMSPEC
52 EXT     = .exe
53 endif
54
55 # Rules
56
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.)
61 #
62 all:    bins libs docs $(SYS:%=samples tests)
63
64 bins:
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}/\\\"
69
70 libs:
71         @$(MAKE) -C libsrc
72
73 # This rule won't try to generate HTML files
74 # if a host system doesn't have LinuxDoc Tools.
75 docs:
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.'; \
79           fi
80
81 # Some platforms cannot compile all of the sample and library-test programs.
82 # So, these rules ignore errors.
83
84 samples:
85         -@$(MAKE) -k -C samples prefix=$(prefix) $(SYS:%=SYS=%)
86
87 tests:
88         -@$(MAKE) -k -C testcode/lib prefix=$(prefix) $(SYS:%=SYS=%)
89
90 clean zap:
91         @$(MAKE) -C src -f make/gcc.mak $@
92         @$(MAKE) -C libsrc $@
93         @$(MAKE) -C doc $@
94         @$(MAKE) -C samples $@
95 #       @$(MAKE) -C testcode/lib $@ $(SYS:%=SYS=%)
96
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} grc${EXT} ca65html
100         $(RM) -R $(CC65_HOME) $(CC65_DOC)
101
102 install:        install-test install-dirs install-bins install-libs install-docs
103         @echo
104         @echo 'If you put the files into non-standard directories, then'
105         @echo 'you might need to export some shell environment variables:'
106         @echo
107         @echo 'CC65_HOME=$(CC65_HOME)'
108         @echo ' or'
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)'
114         @echo
115
116 .PHONY: install-test
117 install-test:
118         @if [ `id -u` != 0 ]; then \
119           echo; \
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.'; \
123           echo; \
124           fi 2>/dev/null
125
126 .PHONY: install-dirs
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
135
136 $(bindir) $(datadir) $(docdir) $(libdir) \
137 $(CC65_DOC) $(CC65_HOME) \
138 $(CA65_INC) $(CC65_INC) \
139 $(LD65_CFG) $(LD65_LIB) $(LD65_OBJ):
140         $(MKDIR) $@
141
142 $(CC65_HOME)/% $(CC65_INC)/% $(CC65_DOC)/%:
143         $(MKDIR) $@
144
145 install-bins:
146         for f in ar65 ca65 cc65 cl65 co65 da65 ld65 od65 grc; \
147           do $(INSTALL_STRIP) src/$$f/$$f${EXT} $(bindir) || exit $$?; \
148           done
149         $(INSTALL_PROG) src/ca65html/ca65html $(bindir)
150
151 install-libs:
152         for f in asminc/*.inc; \
153           do $(INSTALL_DATA) $$f $(CA65_INC) || exit $$?; \
154           done
155         for f in include/*.h; \
156           do $(INSTALL_DATA) $$f $(CC65_INC) || exit $$?; \
157           done
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 $$?; \
161             done || exit $$?; \
162           done
163         for f in libsrc/*.lib; \
164           do $(INSTALL_DATA) $$f $(LD65_LIB) || exit $$?; \
165           done
166         for f in libsrc/*-*.o; \
167           do $(INSTALL_DATA) $$f $(LD65_OBJ) || exit $$?; \
168           done
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 $$?; \
172             done || exit $$?; \
173           done
174         for f in src/ld65/cfg/*-*.cfg; \
175           do $(INSTALL_DATA) $$f $(LD65_CFG) || exit $$?; \
176           done
177
178 install-docs:
179         for f in src/ca65/macpack/*.mac; \
180           do $(INSTALL_DATA) $$f $(CC65_DOC) || exit $$?; \
181           done
182         for f in readme.1st compile.txt CREDITS BUGS internal.txt newvers.txt; \
183           do $(INSTALL_DATA) doc/$$f $(CC65_DOC) || exit $$?; \
184           done
185         if [ -f doc/index.htm* ]; \
186           then for f in doc/*.htm*; \
187             do $(INSTALL_DATA) $$f $(CC65_DOC) || exit $$?; \
188             done; \
189           fi
190
191 install-samps:  ${addprefix $(CC65_DOC)/, $(shell find samples -type d)}
192         @$(MAKE) -C samples zap
193         for d in `find samples -type d`; \
194           do for f in $$d/*; \
195             do if [ -f $$f ]; \
196               then $(INSTALL_DATA) $$f $(CC65_DOC)/$$d || exit $$?; \
197               fi; \
198             done || exit $$?; \
199           done