]> git.sur5r.net Git - cc65/blob - make/gcc.mak
Added alternative implementation for ProDOS 8 I/O buffer management. The purpose...
[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
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
16 # The install prefix and directories
17 prefix          = /usr/local
18 exec_prefix     = $(prefix)
19
20 bindir          = $(exec_prefix)/bin
21 datadir         = $(prefix)/share
22 docdir          = $(datadir)/doc
23 libdir          = $(exec_prefix)/lib
24
25 CC65DATA        = $(libdir)/cc65
26 CC65DOC         = $(docdir)/cc65
27
28 CC65ASM         = $(CC65DATA)/asminc
29 CC65INC         = $(CC65DATA)/include
30 CC65LIB         = $(CC65DATA)/lib
31
32 # Programs
33
34 MKDIR           = mkdir -m 755
35
36 # BSD-like install-script/-program
37 INSTALL         = make/install-sh
38
39 INSTALL_DATA    = $(INSTALL) -c -m 644
40 INSTALL_PROG    = $(INSTALL) -c -m 755
41 INSTALL_STRIP   = $(INSTALL_PROG) -s
42
43 # This file-name extension is needed on DOS/Windows systems.
44 ifdef COMSPEC
45 EXT     = .exe
46 endif
47
48 # Rules
49
50 # The sample and library-test programs must be compiled for only one platform
51 # at a time.  So, those rules are done automatically only when a user names
52 # a system on the command-line.  (A user can do those rules with their
53 # defaults by putting "all samples tests" on the command-line.)
54 #
55 all:    bins libs docs $(SYS:%=samples tests)
56
57 bins:
58         @$(MAKE) -C src -f make/gcc.mak CC65_INC=\\\"${CC65INC}/\\\" CC65_LIB=\\\"${CC65LIB}/\\\"
59
60 libs:
61         @$(MAKE) -C libsrc
62
63 # This rule won't try to generate HTML files
64 # if a host system doesn't have LinuxDoc Tools.
65 docs:
66         @if linuxdoc -B check doc/index >/dev/null 2>&1; \
67           then $(MAKE) -C doc html; \
68           else echo '"LinuxDoc Tools" is not installed; skipping HTML documentation.'; \
69           fi
70
71 # Some platforms cannot compile all of the sample and library-test programs.
72 # So, these rules ignore errors.
73
74 samples:
75         -@$(MAKE) -k -C samples prefix=$(prefix) $(SYS:%=SYS=%)
76
77 tests:
78         -@$(MAKE) -k -C testcode/lib prefix=$(prefix) $(SYS:%=SYS=%)
79
80 clean zap:
81         $(MAKE) -C src -f make/gcc.mak $@
82         $(MAKE) -C libsrc $@
83         $(MAKE) -C doc $@
84         $(MAKE) -C samples $@
85 #       $(MAKE) -C testcode/lib $@ $(SYS:%=SYS=%)
86
87 uninstall:      install-test
88         cd $(bindir) && $(RM) ar65${EXT} ca65${EXT} cc65${EXT} cl65${EXT} \
89           co65${EXT} da65${EXT} ld65${EXT} od65${EXT} grc${EXT} ca65html
90         $(RM) -R $(CC65DATA) $(CC65DOC)
91
92 install:        install-test install-dirs install-bins install-libs install-docs
93         @echo
94         @echo 'You can export some shell environment variables:'
95         @echo
96         @echo 'CC65_INC=$(CC65INC)'
97         @echo 'CC65_LIB=$(CC65LIB)'
98         @echo
99
100 .PHONY: install-test
101 install-test:
102         @if [ `id -u` != 0 ]; then \
103           echo; \
104           echo 'If you are denied permission to install or uninstall this package,'; \
105           echo 'then you will need to do "make/gcc.mak install" or "make/gcc.mak uninstall"'; \
106           echo 'as either the root user or an administrator.'; \
107           echo; \
108           fi 2>/dev/null
109
110 .PHONY: install-dirs
111 install-dirs:
112         [ -d $(bindir) ] || $(MKDIR) $(bindir)
113         [ -d $(datadir) ] || $(MKDIR) $(datadir)
114         [ -d $(docdir) ] || $(MKDIR) $(docdir)
115         [ -d $(libdir) ] || $(MKDIR) $(libdir)
116         [ -d $(CC65DOC) ] || $(MKDIR) $(CC65DOC)
117         [ -d $(CC65DATA) ] || $(MKDIR) $(CC65DATA)
118         [ -d $(CC65ASM) ] || $(MKDIR) $(CC65ASM)
119         [ -d $(CC65LIB) ] || $(MKDIR) $(CC65LIB)
120         [ -d $(CC65INC) ] || $(MKDIR) $(CC65INC)
121         [ -d $(CC65INC)/em ] || $(MKDIR) $(CC65INC)/em
122         [ -d $(CC65INC)/geos ] || $(MKDIR) $(CC65INC)/geos
123         [ -d $(CC65INC)/joystick ] || $(MKDIR) $(CC65INC)/joystick
124         [ -d $(CC65INC)/mouse ] || $(MKDIR) $(CC65INC)/mouse
125         [ -d $(CC65INC)/sys ] || $(MKDIR) $(CC65INC)/sys
126         [ -d $(CC65INC)/tgi ] || $(MKDIR) $(CC65INC)/tgi
127         [ -d $(CC65DATA)/emd ] || $(MKDIR) $(CC65DATA)/emd
128         [ -d $(CC65DATA)/joy ] || $(MKDIR) $(CC65DATA)/joy
129         [ -d $(CC65DATA)/mou ] || $(MKDIR) $(CC65DATA)/mou
130         [ -d $(CC65DATA)/ser ] || $(MKDIR) $(CC65DATA)/ser
131         [ -d $(CC65DATA)/tgi ] || $(MKDIR) $(CC65DATA)/tgi
132
133 install-bins:
134         for f in ar65 ca65 cc65 cl65 co65 da65 ld65 od65 grc; \
135           do $(INSTALL_STRIP) src/$$f/$$f${EXT} $(bindir) || exit 1; \
136           done
137         $(INSTALL_PROG) src/ca65html/ca65html $(bindir)
138
139 install-libs:
140         for f in asminc/*.inc; \
141           do $(INSTALL_DATA) $$f $(CC65ASM) || exit 1; \
142           done
143         for f in include/*.h; \
144           do $(INSTALL_DATA) $$f $(CC65INC) || exit 1; \
145           done
146         for d in em geos joystick mouse sys tgi; \
147           do for f in include/$$d/*.h; \
148             do $(INSTALL_DATA) $$f $(CC65INC)/$$d || exit 1; \
149             done || exit 1; \
150           done
151         for f in libsrc/*.lib; \
152           do $(INSTALL_DATA) $$f $(CC65LIB) || exit 1; \
153           done
154         for d in emd joy mou ser tgi; \
155           do for f in libsrc/*.$$d; \
156             do $(INSTALL_DATA) $$f $(CC65DATA)/$$d || exit 1; \
157             done || exit 1; \
158           done
159
160 install-docs:
161         for f in src/ld65/cfg/*.cfg src/ca65/macpack/*.mac; \
162           do $(INSTALL_DATA) $$f $(CC65DOC) || exit 1; \
163           done
164         for f in readme.1st compile.txt CREDITS BUGS internal.txt newvers.txt; \
165           do $(INSTALL_DATA) doc/$$f $(CC65DOC) || exit 1; \
166           done
167         if [ -f doc/index.htm* ]; \
168           then for f in doc/*.htm*; \
169             do $(INSTALL_DATA) $$f $(CC65DOC) || exit 1; \
170             done; \
171           fi