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