(variable_expand): Fix braino in last change.
[make.git] / GNUmakefile
blob05ffa29902311626845308825c3c266d534276e5
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 prefix = /usr/local
49 exec_prefix = $(prefix)
50 extras := $(filter-out getloadavg.o @%@,$(extras)) getloadavg.o
51 LOADLIBES := $(filter-out @%@,$(LOADLIBES))
52 ALLOCA := $(filter-out @%@,$(ALLOCA))
54 ifdef AC_MACRODIR
55 configure config.h.in: $(patsubst %,$(AC_MACRODIR)/%.m4,acspecific acgeneral)
56 config.h.in: $(AC_MACRODIR)/acconfig.h
57 endif
58 configure: configure.in; autoconf $(ACFLAGS)
59 config.h.in: configure.in; autoheader $(ACFLAGS)
61 ifdef customs
62 defines := $(defines) -Ipmake/customs -Ipmake/lib/include
63 LOADLIBES := $(addprefix pmake/customs/,customslib.o rpc.o xlog.o) \
64 pmake/lib/sprite/libsprite.a
65 endif
67 ifdef ARCH
69 ifndef no_libc
70 libc_dir = /home/gd2/gnu/libc/$(ARCH)
71 ifneq ($(wildcard $(libc_dir)),)
72 ifneq ($(wildcard $(libc_dir)/works-for-make),)
73 #CPPFLAGS := -I$(libc_dir)/include
74 #LDFLAGS := -nostdlib $(libc_dir)/lib/start.o
75 #LOADLIBES := $(LOADLIBES) \
76 # $(libc_dir)/lib/mcheck-init.o \
77 # $(libc_dir)/lib/libc.a \
78 # -lgcc \
79 # $(libc_dir)/lib/libc.a
80 CC := $(CC) -b glibc
82 # getopt is in libc.
83 GETOPT =
84 #GETOPT_SRC = Don't clear this or dist will break.
86 # glob is in libc too.
87 GLOB =
89 else
91 CPPFLAGS := $(filter-out @%@,$(CPPFLAGS)) -Iglob
93 endif # works-for-make
94 endif # $(libc_dir)
95 endif # !no_libc
97 # We know the type of machine, so put the binaries in subdirectories.
98 $(ARCH)/%.o: %.c
99 $(COMPILE.c) -Iglob $< $(OUTPUT_OPTION)
100 $(ARCH)/glob/libglob.a: FORCE
101 $(MAKE) -C $(@D) $(@F)
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 configure.in configure 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 chmod a+x $@.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: rcs-mark default info dvi tests tarfiles
214 .PHONY: tarfiles
215 tarfiles: $(tarfiles)
217 ifndef dist-flavor
218 dist-flavor = alpha
219 endif
220 .PHONY: rcs-mark rcs-mark-alpha rcs-mark-beta
221 rcs-mark: rcs-mark-$(dist-flavor)
222 rcs-mark-alpha: RCS/[!=]*,v;rcs -sAlpha -Nmake-$(version-): $^
223 rcs-mark-beta: RCS/[!=]*,v;rcs -sBeta -Nmake-$(version-): $^
224 version- = $(subst .,-,$(version))
226 dist: local-inst
227 .PHONY: local-inst
228 local-inst: $(prog)
229 install -c -g kmem -o $(USER) -m 2755 $< /usr/local/gnubin/make
231 # Put the alpha distribution files in the anonymous FTP directory.
232 alpha-files = $(tarfiles) GNUmakefile compatMakefile $(testdir).tar.Z
233 dist: alpha
234 .PHONY: alpha
235 alpha-dir := ~ftp/gnu
236 alpha-files := $(addprefix $(alpha-dir)/,$(alpha-files))
237 alpha: $(alpha-dir) $(alpha-files)
238 $(alpha-dir)/%: %
239 @rm -f $@
240 cp $< $@
242 # Implicit rule to make README and README-doc.
243 %: %.template version.c
244 rm -f $@
245 sed 's/VERSION/$(version)/' < $< > $@
246 # Make sure I don't edit it by accident.
247 chmod a-w $@
249 define make-tar
250 @rm -fr make-$(version)
251 ln -s . make-$(version)
252 tar cvhof $@ $(addprefix make-$(version)/,$^)
253 rm -f make-$(version)
254 endef
256 %.Z: %; compress -c $< > $@
257 %.gz: %; gzip -9 -c -v $< > $@
259 make-doc-$(version).tar: README-doc COPYING make.dvi make.info make.info*
260 $(make-tar)
261 make-$(version).tar: README INSTALL COPYING ChangeLog NEWS \
262 configure Makefile.in configure.in build.sh.in mkinstalldirs \
263 acconfig.h $(srcs) remote-*.c $(globfiles) \
264 make.texinfo make-stds.texi \
265 make.?? make.??s make.toc make.aux make.man texinfo.tex TAGS tags \
266 install-sh \
267 make.info make.info*
268 $(make-tar)
270 ifneq (,)
271 tests := $(filter-out %~,$(wildcard tests/*))
272 make-tests-$(version).tar.Z: $(tests)
273 @rm -fr make-tests-$(version)
274 ln -s tests make-tests-$(version)
275 tar cvhf $(@:.Z=) $(patsubst tests/%,make-tests-$(version)/%,$^)
276 rm -f make-tests-$(version)
277 compress -f $(@:.Z=)
278 endif
280 $(archpfx)loadtest: $(archpfx)load.o