]> git.sur5r.net Git - cc65/blob - make/gcc.mak
Greg King's grammar and typo corrections
[cc65] / make / gcc.mak
1 #! /usr/bin/make -f
2 # -*- makefile -*-
3 #
4 # Main gcc Makefile.
5 # This makefile is maintained by Greg King <gngking@erols.com>.
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
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-program/-script
37 INSTALL         = install
38 #INSTALL                = install-sh
39
40 INSTALL_DATA    = $(INSTALL) -c -m 644
41 INSTALL_PROG    = $(INSTALL) -c -m 755
42 INSTALL_STRIP   = $(INSTALL_PROG) -s
43
44 # Rules
45
46 # The sample and library-test programs must be compiled for only one platform
47 # at a time.  So, those rules are done automatically only when a user names
48 # a system on the command-line.  (A user can do those rules with their
49 # defaults by putting "all samples tests" on the command-line.)
50 #
51 all:    bins libs docs $(SYS:%=samples tests)
52
53 bins:
54         @$(MAKE) -C src -f make/gcc.mak
55
56 libs:
57         @$(MAKE) -C libsrc
58
59 # A host system might not have LinuxDoc Tools, so this rule ignores errors.
60 docs:
61         -@$(MAKE) -C doc html
62
63 # Some platforms cannot compile all of the sample and library-test programs.
64 # So, these rules ignore errors.
65
66 samples:
67         -@$(MAKE) -k -C samples $(SYS:%=SYS=%)
68
69 tests:
70         -@$(MAKE) -k -C testcode/lib $(SYS:%=SYS=%)
71
72 clean zap:
73         $(MAKE) -C src -f make/gcc.mak $@
74         $(MAKE) -C libsrc $@
75         $(MAKE) -C doc $@
76         $(MAKE) -C samples $@
77         $(MAKE) -C testcode/lib $@ $(SYS:%=SYS=%)
78
79 uninstall:      install-test
80         cd $(bindir) && $(RM) ar65 ca65 cc65 cl65 co65 da65 ld65 od65 grc ca65html
81         $(RM) -R $(CC65DATA) $(CC65DOC)
82
83 install:        install-test install-dirs install-bins install-libs install-docs
84         @echo
85         @echo 'You should export some shell environment variables:'
86         @echo
87         @echo 'CC65_INC=$(CC65INC)'
88         @echo 'CC65_LIB=$(CC65LIB)'
89         @echo
90
91 .PHONY: install-test
92 install-test:
93         @if [ `id -u` != 0 ]; then                                      \
94           echo >&2;                                                     \
95           echo 'Do "make install" or "make uninstall" as root.' >&2;    \
96           echo >&2;                                                     \
97           false;                                                        \
98           fi
99
100 .PHONY: install-dirs
101 install-dirs:
102         -$(MKDIR) -p $(bindir) $(docdir) $(libdir)
103         -$(MKDIR) $(CC65DATA) $(CC65ASM) $(CC65DOC) $(CC65INC)
104         -$(MKDIR) $(CC65INC)/em $(CC65INC)/geos $(CC65INC)/joystick \
105           $(CC65INC)/mouse $(CC65INC)/sys $(CC65INC)/tgi
106         -$(MKDIR) $(CC65LIB) $(CC65DATA)/emd $(CC65DATA)/joy \
107           $(CC65DATA)/mou $(CC65DATA)/ser $(CC65DATA)/tgi
108
109 install-bins:
110         for f in ar65 ca65 cc65 cl65 co65 da65 ld65 od65 grc; \
111           do $(INSTALL_STRIP) src/$$f/$$f $(bindir) || exit 1; \
112           done
113         $(INSTALL_PROG) src/ca65html/ca65html $(bindir)
114
115 install-libs:
116         for f in asminc/*.inc; \
117           do $(INSTALL_DATA) $$f $(CC65ASM) || exit 1; \
118           done
119         for f in include/*.h; \
120           do $(INSTALL_DATA) $$f $(CC65INC) || exit 1; \
121           done
122         for d in em geos joystick mouse sys tgi; \
123           do for f in include/$$d/*.h; \
124             do $(INSTALL_DATA) $$f $(CC65INC)/$$d || exit 1; \
125             done || exit 1; \
126           done
127         for f in libsrc/*.lib libsrc/*.o; \
128           do $(INSTALL_DATA) $$f $(CC65LIB) || exit 1; \
129           done
130         for d in emd joy mou ser tgi; \
131           do for f in libsrc/*.$$d; \
132             do $(INSTALL_DATA) $$f $(CC65DATA)/$$d || exit 1; \
133             done || exit 1; \
134           done
135
136 install-docs:
137         for f in src/ld65/cfg/*.cfg; \
138           do $(INSTALL_DATA) $$f $(CC65DOC) || exit 1; \
139           done
140         for f in readme.1st compile.txt CREDITS BUGS internal.txt newvers.txt; \
141           do $(INSTALL_DATA) doc/$$f $(CC65DOC) || exit 1; \
142           done
143         -for f in doc/*.html; \
144           do $(INSTALL_DATA) $$f $(CC65DOC) || exit 1; \
145           done