Abbreviate copyright years.
[make.git] / GNUmakefile
blob2ae480199690e4a9e27bd340659faec487a80979
1 # GNU Make-specific makefile for GNU Make.
3 # Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
4 # This file is part of GNU Make.
5 #
6 # GNU Make is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
9 # any later version.
11 # GNU Make is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with GNU Make; see the file COPYING. If not, write to
18 # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20 .PHONY: default
21 default:
23 # Set `ARCH' to a string for the type of machine.
24 ifndef ARCH
25 ifdef machine
26 ARCH = $(machine)
27 endif # machine
28 endif # not ARCH
30 override srcdir := .
31 override CC := $(CC)
33 ifeq ($(ARCH),hp300)
34 #customs=yes
35 endif
36 ifdef customs
37 override REMOTE := cstms
38 else
39 override REMOTE := stub
40 endif
42 # Get most of the information from the Unix-compatible makefile.
43 include compatMakefile
45 MAKE = $(MAKE_COMMAND) $(MAKEOVERRIDES)
47 # Remove autoconf magic.
48 extras := $(filter-out getloadavg.o @%@,$(extras)) getloadavg.o
49 LOADLIBES := $(filter-out @%@,$(LOADLIBES))
50 ALLOCA := $(filter-out @%@,$(ALLOCA))
52 ifdef AC_MACRODIR
53 configure config.h.in: $(patsubst %,$(AC_MACRODIR)/%.m4,acspecific acgeneral)
54 config.h.in: $(AC_MACRODIR)/acconfig.h
55 endif
56 configure: configure.in; autoconf $(ACFLAGS)
57 config.h.in: configure.in; autoheader $(ACFLAGS)
59 ifdef customs
60 defines := $(defines) -Ipmake/customs -Ipmake/lib/include
61 LOADLIBES := $(addprefix pmake/customs/,customslib.o rpc.o xlog.o) \
62 pmake/lib/sprite/libsprite.a
63 endif
65 ifdef ARCH
67 ifndef no_libc
68 libc_dir = /home/gd2/gnu/libc/$(ARCH)
69 ifneq ($(wildcard $(libc_dir)),)
70 ifneq ($(wildcard $(libc_dir)/works-for-make),)
71 #CPPFLAGS := -I$(libc_dir)/include
72 #LDFLAGS := -nostdlib $(libc_dir)/lib/start.o
73 #LOADLIBES := $(LOADLIBES) \
74 # $(libc_dir)/lib/mcheck-init.o \
75 # $(libc_dir)/lib/libc.a \
76 # -lgcc \
77 # $(libc_dir)/lib/libc.a
78 CC := $(CC) -b glibc
80 # getopt is in libc.
81 GETOPT =
82 #GETOPT_SRC = Don't clear this or dist will break.
84 # glob is in libc too.
85 GLOB =
87 else
89 CPPFLAGS := $(CPPFLAGS) -Iglob
91 endif # works-for-make
92 endif # $(libc_dir)
93 endif # !no_libc
95 # We know the type of machine, so put the binaries in subdirectories.
96 $(ARCH)/%.o: %.c
97 $(COMPILE.c) -Iglob $< $(OUTPUT_OPTION)
98 $(ARCH)/glob/libglob.a: FORCE
99 $(MAKE) -C $(@D) $(@F) \
100 CC='$(CC)' CFLAGS='$(CFLAGS) -I..' \
101 CPPFLAGS='$(CPPFLAGS) -DHAVE_CONFIG_H'
102 FORCE:
103 objs := $(addprefix $(ARCH)/,$(objs))
104 prog := $(ARCH)/make
106 archpfx = $(ARCH)/
108 $(archpfx)load.o: load.c
109 $(COMPILE.c) $(LOAD_AVG) $< -o $@
110 $(archpfx)load.dep: load.c
111 $(mkdep) $(LOAD_AVG) $< | sed 's,$*\.o,& $@,' > $@
113 CPPFLAGS := -I$(ARCH) $(CPPFLAGS) -DHAVE_CONFIG_H $(filter-out @%@,$(defines))
115 ifneq "$(wildcard $(ARCH)/makefile)" ""
116 include $(ARCH)/makefile
117 endif
118 objs := $(objs) $(addprefix $(ARCH)/,$(ALLOCA) $(extras))
120 else # Not ARCH
121 prog := make
122 endif
124 ifneq "$(findstring gcc,$(CC))" ""
125 CFLAGS = -g -W -Wunused -Wpointer-arith -Wreturn-type -Wswitch
126 else
127 CFLAGS = -g
128 endif
129 LDFLAGS = -g
131 # Define the command to make dependencies.
132 ifneq "$(findstring gcc,$(CC))" ""
133 # Don't include system directories.
134 mkdep-nolib = $(CC) -MM $(CPPFLAGS)
135 else
136 mkdep-nolib = $(mkdep)
137 endif
138 mkdep = $(CC) -M $(CPPFLAGS)
140 depfiles = $(patsubst %.o,%.dep,$(filter %.o,$(objs)))
143 .PHONY: default
144 default: $(prog)
146 $(prog): $(objs) $(globdep) #$(addprefix $(ARCH)/,gmalloc.o mcheck.o)
147 $(CC) $(LDFLAGS) $^ $(globlib) $(LOADLIBES) -o $@.new
148 mv -f $@.new $@
150 globfiles = $(addprefix glob/,COPYING.LIB Makefile.in \
151 glob.c fnmatch.c glob.h fnmatch.h)
152 $(globfiles): stamp-glob ;
153 stamp-glob: /home/gd/gnu/libc/posix/glob.tar
154 -rm -rf glob
155 tar xvf $< glob
156 touch $@
157 /home/gd/gnu/libc/posix/glob.tar: force
158 $(MAKE) -C $(@D) $(@F) no_deps=t
159 .PHONY: force
160 force:
162 # Make the Unix-compatible Makefile to be distributed by appending
163 # the automatically-generated dependencies to compatMakefile.
164 ifeq ($(mkdep),$(mkdep-nolib))
165 nolib-deps = $(depfiles)
166 else
167 %.dep: %.c
168 $(mkdep-nolib) $< | sed -e 's,$*\.o,$(@:.dep=.o) $@,' > $(@:.dep=.dtm)
169 mv -f $(@:.dep=.dtm) $@
170 nolib-deps = $(patsubst $(archpfx)%,%,$(depfiles))
171 endif
172 # The distributed Makefile.in should contain deps for remote-stub only.
173 Makefile.in: compatMakefile $(nolib-deps:remote-%.dep=remote-stub.dep)
174 (sed 's/^MAKE[ ]*=.*$$/@SET_MAKE@/' $<; \
175 echo '# Automatically generated dependencies.'; \
176 sed -e 's/ [^ ]*\.dep//' -e 's=$(archpfx)==' $(filter-out $<,$^) \
177 ) > $@
179 .SUFFIXES: .dep
180 # Maintain the automatically-generated dependencies.
181 ifndef no_deps
182 include $(depfiles)
183 endif
184 $(archpfx)%.dep: %.c
185 $(mkdep) $< | sed 's,$*\.o,$(@:.dep=.o) $@,' > $@
187 ETAGS = etags -T # for v19 etags
189 # Run the tests.
190 .PHONY: tests
191 testdir := $(shell ls -d1 make-test-?.? | sort -n +0.10 -0.11 +0.12 | tail -1l)
192 tests:# $(testdir)/run_make_tests.pl $(prog)
193 # cd $(<D); MAKELEVEL=0 perl $(<F)
195 build.sh.in: build.template compatMakefile
196 sed -e 's@%objs%@$(filter-out remote-% $(GLOB) $(ALLOCA) $(extras),\
197 $(patsubst $(archpfx)%,%,$(objs)))\
198 $(patsubst %.c,%.o,$(filter %.c,$(globfiles)))@' \
199 $< > $@.new
200 mv -f $@.new $@
202 # Make the distribution tar files.
204 .PHONY: dist
205 # Figure out the version number from the source of `version.c'.
206 version := \
207 $(strip $(shell sed -e '/=/!d' -e 's/^.*"\(.*\)";$$/\1/' < version.c))
208 tarfiles := make # make-doc
209 tarfiles := $(addsuffix -$(version).tar,$(tarfiles))
210 tarfiles := $(tarfiles:%=%.gz) # no more compress $(tarfiles:%=%.Z)
211 # Depend on default and doc so we don't ship anything that won't compile.
212 dist: rcs-mark default info dvi tests tarfiles
213 .PHONY: tarfiles
214 tarfiles: $(tarfiles)
216 ifndef dist-flavor
217 dist-flavor = alpha
218 endif
219 .PHONY: rcs-mark rcs-mark-alpha rcs-mark-beta
220 rcs-mark: rcs-mark-$(dist-flavor)
221 rcs-mark-alpha: RCS/[!=]*,v;rcs -sAlpha -Nmake-$(version-): $^
222 rcs-mark-beta: RCS/[!=]*,v;rcs -sBeta -Nmake-$(version-): $^
223 version- = $(subst .,-,$(version))
225 dist: local-inst
226 .PHONY: local-inst
227 local-inst: $(prog)
228 install -c -g kmem -o $(USER) -m 2755 $< /usr/local/gnubin/make
230 # Put the alpha distribution files in the anonymous FTP directory.
231 alpha-files = $(tarfiles) GNUmakefile compatMakefile $(testdir).tar.Z
232 dist: alpha
233 .PHONY: alpha
234 alpha-dir := ~ftp/gnu
235 alpha-files := $(addprefix $(alpha-dir)/,$(alpha-files))
236 alpha: $(alpha-dir) $(alpha-files)
237 $(alpha-dir)/%: %
238 @rm -f $@
239 cp $< $@
241 # Implicit rule to make README and README-doc.
242 %: %.template version.c
243 rm -f $@
244 sed 's/VERSION/$(version)/' < $< > $@
245 # Make sure I don't edit it by accident.
246 chmod a-w $@
248 define make-tar
249 @rm -fr make-$(version)
250 ln -s . make-$(version)
251 tar cvhof $@ $(addprefix make-$(version)/,$^)
252 rm -f make-$(version)
253 endef
255 %.Z: %; compress -c $< > $@
256 %.gz: %; gzip -9 -c -v $< > $@
258 make-doc-$(version).tar: README-doc COPYING make.dvi make.info make.info*
259 $(make-tar)
260 make-$(version).tar: README INSTALL COPYING ChangeLog NEWS \
261 configure Makefile.in configure.in build.sh.in mkinstalldirs \
262 acconfig.h $(srcs) remote-*.c $(globfiles) \
263 make.texinfo make-stds.texi \
264 make.?? make.??s make.toc make.aux make.man texinfo.tex TAGS tags \
265 install.sh \
266 make.info make.info*
267 $(make-tar)
269 ifneq (,)
270 tests := $(filter-out %~,$(wildcard tests/*))
271 make-tests-$(version).tar.Z: $(tests)
272 @rm -fr make-tests-$(version)
273 ln -s tests make-tests-$(version)
274 tar cvhf $(@:.Z=) $(patsubst tests/%,make-tests-$(version)/%,$^)
275 rm -f make-tests-$(version)
276 compress -f $(@:.Z=)
277 endif
279 $(archpfx)loadtest: $(archpfx)load.o