]> git.sur5r.net Git - cc65/blob - make/gcc.mak
Fixed typo.
[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} grc65${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 installed the files into non-default 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         @if [ -x $(bindir)/grc${EXT} ]; then \
116           echo 'grc was renamed to grc65; but, a grc command is in your binaries directory.'; \
117           echo "If that command is an old copy of CC65's program,"; \
118           echo 'then you should use a "${MAKE} erase-grc" command to remove it.'; \
119           fi
120
121 .PHONY: install-test
122 install-test:
123         @if [ `id -u` != 0 ]; then \
124           echo; \
125           echo 'If you are denied permission to install or uninstall this package,'; \
126           echo 'then you will need to do "make/gcc.mak install" or "make/gcc.mak uninstall"'; \
127           echo 'as either the root user or an administrator.'; \
128           echo; \
129           fi 2>/dev/null
130
131 .PHONY: install-dirs
132 install-dirs:   $(bindir) $(datadir) $(docdir) $(libdir) \
133                 $(CC65_DOC) $(CC65_HOME) \
134                 $(CA65_INC) $(CC65_INC) \
135                 $(CC65_INC)/em $(CC65_INC)/geos $(CC65_INC)/joystick \
136                 $(CC65_INC)/mouse $(CC65_INC)/sys $(CC65_INC)/tgi \
137                 $(LD65_CFG) $(LD65_LIB) $(LD65_OBJ) \
138                 $(CC65_HOME)/emd $(CC65_HOME)/joy $(CC65_HOME)/mou \
139                 $(CC65_HOME)/ser $(CC65_HOME)/tgi
140
141 $(bindir) $(datadir) $(docdir) $(libdir) \
142 $(CC65_DOC) $(CC65_HOME) \
143 $(CA65_INC) $(CC65_INC) \
144 $(LD65_CFG) $(LD65_LIB) $(LD65_OBJ):
145         $(MKDIR) -p $@ || $(MKDIR) $@
146
147 $(CC65_HOME)/% $(CC65_INC)/% $(CC65_DOC)/%:
148         $(MKDIR) $@
149
150 install-bins:
151         for f in ar65 ca65 cc65 cl65 co65 da65 ld65 od65 grc65; \
152           do $(INSTALL_STRIP) src/$$f/$$f${EXT} $(bindir) || exit $$?; \
153           done
154         $(INSTALL_PROG) src/ca65html/ca65html $(bindir)
155
156 install-libs:
157         for f in asminc/*.inc; \
158           do $(INSTALL_DATA) $$f $(CA65_INC) || exit $$?; \
159           done
160         for f in include/*.h; \
161           do $(INSTALL_DATA) $$f $(CC65_INC) || exit $$?; \
162           done
163         for d in em geos joystick mouse sys tgi; \
164           do for f in include/$$d/*.h; \
165             do $(INSTALL_DATA) $$f $(CC65_INC)/$$d || exit $$?; \
166             done || exit $$?; \
167           done
168         for f in libsrc/*.lib; \
169           do $(INSTALL_DATA) $$f $(LD65_LIB) || exit $$?; \
170           done
171         for f in libsrc/*-*.o; \
172           do $(INSTALL_DATA) $$f $(LD65_OBJ) || exit $$?; \
173           done
174         for f in src/ld65/cfg/[!g]*-*.cfg; \
175           do $(INSTALL_DATA) $$f $(LD65_CFG) || exit $$?; \
176           done
177         for d in emd joy mou ser tgi; \
178           do for f in libsrc/*.$$d; \
179             do $(INSTALL_DATA) $$f $(CC65_HOME)/$$d || exit $$?; \
180             done || exit $$?; \
181           done
182
183 install-docs:
184         for f in src/ca65/macpack/*.mac; \
185           do $(INSTALL_DATA) $$f $(CC65_DOC) || exit $$?; \
186           done
187         for f in readme.1st compile.txt CREDITS BUGS internal.txt newvers.txt; \
188           do $(INSTALL_DATA) doc/$$f $(CC65_DOC) || exit $$?; \
189           done
190         if [ -f doc/index.htm* ]; \
191           then for f in doc/*.htm*; \
192             do $(INSTALL_DATA) $$f $(CC65_DOC) || exit $$?; \
193             done; \
194           fi
195
196 install-samps:  ${addprefix $(CC65_DOC)/, $(shell find samples -type d)}
197         @$(MAKE) -C samples zap
198         for d in `find samples -type d`; \
199           do for f in $$d/*; \
200             do if [ -f $$f ]; \
201               then $(INSTALL_DATA) $$f $(CC65_DOC)/$$d || exit $$?; \
202               fi; \
203             done || exit $$?; \
204           done
205
206 erase-grc:
207         $(RM) $(bindir)/grc${EXT}