(read_makefile): Remove unused variable.
[make.git] / GNUmakefile
blob65f8b5f3c6b3cb13b8c81178c93215e5057945fe
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 # Tell autoconf/autoheader to use m4 files from the master source.
53 ACFLAGS := -m /home/gd/gnu/autoconf
54 configure config.h.in: $(patsubst %,/home/gd/gnu/autoconf/%.m4,\
55 acspecific acgeneral)
56 config.h.in: /home/gd/gnu/autoconf/acconfig.h
57 configure: configure.in; autoconf $(ACFLAGS)
58 config.h.in: configure.in; autoheader $(ACFLAGS)
60 ifdef customs
61 defines := $(defines) -Ipmake/customs -Ipmake/lib/include
62 LOADLIBES := $(addprefix pmake/customs/,customslib.o rpc.o xlog.o) \
63 pmake/lib/sprite/libsprite.a
64 endif
66 ifdef ARCH
68 ifndef no_libc
69 libc_dir = /home/gd2/gnu/libc/$(ARCH)
70 ifneq ($(wildcard $(libc_dir)),)
71 ifneq ($(wildcard $(libc_dir)/works-for-make),)
72 #CPPFLAGS := -I$(libc_dir)/include
73 #LDFLAGS := -nostdlib $(libc_dir)/lib/start.o
74 #LOADLIBES := $(LOADLIBES) \
75 # $(libc_dir)/lib/mcheck-init.o \
76 # $(libc_dir)/lib/libc.a \
77 # -lgcc \
78 # $(libc_dir)/lib/libc.a
79 CC := $(CC) -b glibc
81 # getopt is in libc.
82 GETOPT =
83 #GETOPT_SRC = Don't clear this or dist will break.
85 # glob is in libc too.
86 GLOB =
88 else
90 CPPFLAGS := $(CPPFLAGS) -Iglob
92 endif # works-for-make
93 endif # $(libc_dir)
94 endif # !no_libc
96 # We know the type of machine, so put the binaries in subdirectories.
97 $(ARCH)/%.o: %.c
98 $(COMPILE.c) -Iglob $< $(OUTPUT_OPTION)
99 $(ARCH)/glob/libglob.a: FORCE
100 $(MAKE) -C $(@D) $(@F) \
101 CC='$(CC)' CFLAGS='$(CFLAGS) -I..' \
102 CPPFLAGS='$(CPPFLAGS) -DHAVE_CONFIG_H'
103 FORCE:
104 objs := $(addprefix $(ARCH)/,$(objs))
105 prog := $(ARCH)/make
107 archpfx = $(ARCH)/
109 $(archpfx)load.o: load.c
110 $(COMPILE.c) $(LOAD_AVG) $< -o $@
111 $(archpfx)load.dep: load.c
112 $(mkdep) $(LOAD_AVG) $< | sed 's,$*\.o,& $@,' > $@
114 CPPFLAGS := -I$(ARCH) $(CPPFLAGS) -DHAVE_CONFIG_H $(filter-out @%@,$(defines))
116 ifneq "$(wildcard $(ARCH)/makefile)" ""
117 include $(ARCH)/makefile
118 endif
119 objs := $(objs) $(addprefix $(ARCH)/,$(ALLOCA) $(extras))
121 else # Not ARCH
122 prog := make
123 endif
125 ifneq "$(findstring gcc,$(CC))" ""
126 CFLAGS = -g -W -Wunused -Wpointer-arith -Wreturn-type -Wswitch
127 else
128 CFLAGS = -g
129 endif
130 LDFLAGS = -g
132 # Define the command to make dependencies.
133 ifneq "$(findstring gcc,$(CC))" ""
134 # Don't include system directories.
135 mkdep-nolib = $(CC) -MM $(CPPFLAGS)
136 else
137 mkdep-nolib = $(mkdep)
138 endif
139 mkdep = $(CC) -M $(CPPFLAGS)
141 depfiles = $(patsubst %.o,%.dep,$(filter %.o,$(objs)))
144 .PHONY: default
145 default: $(prog)
147 $(prog): $(objs) $(globdep) #$(addprefix $(ARCH)/,gmalloc.o mcheck.o)
148 $(CC) $(LDFLAGS) $^ $(globlib) $(LOADLIBES) -o $@.new
149 mv -f $@.new $@
151 globfiles = $(addprefix glob/,COPYING.LIB Makefile.in \
152 glob.c fnmatch.c glob.h fnmatch.h)
153 $(globfiles): stamp-glob ;
154 stamp-glob: /home/gd/gnu/libc/posix/glob.tar
155 -rm -rf glob
156 tar xvf $< glob
157 touch $@
158 /home/gd/gnu/libc/posix/glob.tar: force
159 $(MAKE) -C $(@D) $(@F) no_deps=t
160 .PHONY: force
161 force:
163 # Make the Unix-compatible Makefile to be distributed by appending
164 # the automatically-generated dependencies to compatMakefile.
165 ifeq ($(mkdep),$(mkdep-nolib))
166 nolib-deps = $(depfiles)
167 else
168 %.dep: %.c
169 $(mkdep-nolib) $< | sed -e 's,$*\.o,$(@:.dep=.o) $@,' > $(@:.dep=.dtm)
170 mv -f $(@:.dep=.dtm) $@
171 nolib-deps = $(patsubst $(archpfx)%,%,$(depfiles))
172 endif
173 # The distributed Makefile.in should contain deps for remote-stub only.
174 Makefile.in: compatMakefile $(nolib-deps:remote-%.dep=remote-stub.dep)
175 (sed 's/^MAKE[ ]*=.*$$/@SET_MAKE@/' $<; \
176 echo '# Automatically generated dependencies.'; \
177 sed -e 's/ [^ ]*\.dep//' -e 's=$(archpfx)==' $(filter-out $<,$^) \
178 ) > $@
180 .SUFFIXES: .dep
181 # Maintain the automatically-generated dependencies.
182 ifndef no_deps
183 include $(depfiles)
184 endif
185 $(archpfx)%.dep: %.c
186 $(mkdep) $< | sed 's,$*\.o,$(@:.dep=.o) $@,' > $@
188 ETAGS = etags -T # for v19 etags
190 # Run the tests.
191 .PHONY: tests
192 testdir := $(shell ls -d1 make-test-?.? | sort -n +0.10 -0.11 +0.12 | tail -1l)
193 tests:# $(testdir)/run_make_tests.pl $(prog)
194 # cd $(<D); MAKELEVEL=0 perl $(<F)
196 build.sh.in: build.template compatMakefile
197 sed -e 's@%objs%@$(filter-out remote-% $(GLOB) $(ALLOCA) $(extras),\
198 $(patsubst $(archpfx)%,%,$(objs)))\
199 $(patsubst %.c,%.o,$(filter %.c,$(globfiles)))@' \
200 $< > $@.new
201 mv -f $@.new $@
203 # Make the distribution tar files.
205 .PHONY: dist
206 # Figure out the version number from the source of `version.c'.
207 version := \
208 $(strip $(shell sed -e '/=/!d' -e 's/^.*"\(.*\)";$$/\1/' < version.c))
209 tarfiles := make # make-doc
210 tarfiles := $(addsuffix -$(version).tar,$(tarfiles))
211 tarfiles := $(tarfiles:%=%.gz) # no more compress $(tarfiles:%=%.Z)
212 # Depend on default and doc so we don't ship anything that won't compile.
213 dist: default info dvi tests tarfiles
214 .PHONY: tarfiles
215 tarfiles: $(tarfiles)
217 .PHONY: rcs-mark-alpha
218 dist: rcs-mark-alpha
219 rcs-mark-alpha:
220 rcs -sAlpha -Nmake-$(version) RCS/[!=]*,v
222 dist: local-inst
223 .PHONY: local-inst
224 local-inst: $(prog)
225 install -c -g kmem -o $(USER) -m 2755 $< /usr/local/gnubin/make
227 # Put the alpha distribution files in the anonymous FTP directory.
228 alpha-files = $(tarfiles) GNUmakefile compatMakefile $(testdir).tar.Z
229 dist: alpha
230 .PHONY: alpha
231 alpha-dir := ~ftp/gnu
232 alpha-files := $(addprefix $(alpha-dir)/,$(alpha-files))
233 alpha: $(alpha-dir) $(alpha-files)
234 $(alpha-dir)/%: %
235 @rm -f $@
236 cp $< $@
238 # Implicit rule to make README and README-doc.
239 %: %.template version.c
240 rm -f $@
241 sed 's/VERSION/$(version)/' < $< > $@
242 # Make sure I don't edit it by accident.
243 chmod a-w $@
245 define make-tar
246 @rm -fr make-$(version)
247 ln -s . make-$(version)
248 tar cvhof $@ $(addprefix make-$(version)/,$^)
249 rm -f make-$(version)
250 endef
252 %.Z: %; compress -c $< > $@
253 %.gz: %; gzip -9 -c -v $< > $@
255 make-doc-$(version).tar: README-doc COPYING make.dvi make.info make.info*
256 $(make-tar)
257 make-$(version).tar: README INSTALL COPYING ChangeLog NEWS \
258 configure Makefile.in configure.in build.sh.in mkinstalldirs \
259 acconfig.h $(srcs) remote-*.c $(globfiles) \
260 make.texinfo make-stds.texi \
261 make.?? make.??s make.toc make.aux make.man texinfo.tex TAGS tags \
262 install.sh \
263 make.info make.info*
264 $(make-tar)
266 ifneq (,)
267 tests := $(filter-out %~,$(wildcard tests/*))
268 make-tests-$(version).tar.Z: $(tests)
269 @rm -fr make-tests-$(version)
270 ln -s tests make-tests-$(version)
271 tar cvhf $(@:.Z=) $(patsubst tests/%,make-tests-$(version)/%,$^)
272 rm -f make-tests-$(version)
273 compress -f $(@:.Z=)
274 endif
276 $(archpfx)loadtest: $(archpfx)load.o