Formerly make.texinfo.~122~
[make.git] / GNUmakefile
blob5c050726bff93d235c688a17f768c92e6a61e8ac
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) $(addprefix $(ARCH)/,gmalloc.o mcheck.o)
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 -rm -rf glob
152 tar xvf $< glob
153 touch $@
154 /home/gd/gnu/libc/posix/glob.tar: force
155 $(MAKE) -C $(@D) $(@F) no_deps=t
156 .PHONY: force
157 force:
159 # Make the Unix-compatible Makefile to be distributed by appending
160 # the automatically-generated dependencies to compatMakefile.
161 ifeq ($(mkdep),$(mkdep-nolib))
162 nolib-deps = $(depfiles)
163 else
164 %.dep: %.c
165 $(mkdep-nolib) $< | sed -e 's,$*\.o,$(@:.dep=.o) $@,' > $@
166 nolib-deps = $(patsubst $(archpfx)%,%,$(depfiles))
167 endif
168 # The distributed Makefile.in should contain deps for remote-stub only.
169 Makefile.in: compatMakefile $(nolib-deps:remote-%.dep=remote-stub.dep)
170 (cat $<; \
171 echo '# Automatically generated dependencies.'; \
172 sed -e 's/ [^ ]*\.dep//' -e 's=$(archpfx)==' $(filter-out $<,$^) \
173 ) > $@
175 .SUFFIXES: .dep
176 # Maintain the automatically-generated dependencies.
177 ifndef no_deps
178 include $(depfiles)
179 endif
180 $(archpfx)%.dep: %.c
181 $(mkdep) $< | sed 's,$*\.o,$(@:.dep=.o) $@,' > $@
183 ETAGS = etags -T # for v19 etags
185 # Run the tests.
186 .PHONY: tests
187 testdir := $(shell ls -d1 make-test-?.? | sort -n +0.10 -0.11 +0.12 | tail -1l)
188 tests:# $(testdir)/run_make_tests.pl $(prog)
189 # cd $(<D); MAKELEVEL=0 perl $(<F)
191 build.sh.in: build.template compatMakefile
192 sed -e 's@%objs%@$(filter-out remote-% $(GLOB) $(ALLOCA) $(extras),\
193 $(patsubst $(archpfx)%,%,$(objs)))\
194 $(patsubst %.c,%.o,$(filter %.c,$(globfiles)))@' \
195 $< > $@.new
196 mv -f $@.new $@
198 # Make the distribution tar files.
200 .PHONY: dist
201 # Figure out the version number from the source of `version.c'.
202 version := \
203 $(strip $(shell sed -e '/=/!d' -e 's/^.*"\(.*\)";$$/\1/' < version.c))
204 tarfiles := make make-doc
205 tarfiles := $(addsuffix -$(version).tar,$(tarfiles))
206 tarfiles := $(tarfiles:%=%.gz) # no more compress $(tarfiles:%=%.Z)
207 # Depend on default and doc so we don't ship anything that won't compile.
208 dist: default info dvi tests tarfiles
209 .PHONY: tarfiles
210 tarfiles: $(tarfiles)
212 dist: local-inst
213 .PHONY: local-inst
214 local-inst: $(prog)
215 install -c -g kmem -o $(USER) -m 2755 $< /usr/local/gnubin/make
217 # Put the alpha distribution files in the anonymous FTP directory.
218 alpha-files = $(tarfiles) GNUmakefile compatMakefile $(testdir).tar.Z
219 dist: alpha
220 .PHONY: alpha
221 alpha-dir := ~ftp/gnu
222 alpha-files := $(addprefix $(alpha-dir)/,$(alpha-files))
223 alpha: $(alpha-dir) $(alpha-files)
224 $(alpha-dir)/%: %
225 @rm -f $@
226 cp $< $@
228 # Implicit rule to make README and README-doc.
229 %: %.template version.c
230 rm -f $@
231 sed 's/VERSION/$(version)/' < $< > $@
232 # Make sure I don't edit it by accident.
233 chmod a-w $@
235 define make-tar
236 @rm -fr make-$(version)
237 ln -s . make-$(version)
238 tar cvhof $@ $(addprefix make-$(version)/,$^)
239 rm -f make-$(version)
240 endef
242 %.Z: %; compress -c $< > $@
243 %.gz: %; gzip -9 -c -v $< > $@
245 make-doc-$(version).tar: README-doc COPYING make.dvi make.info make.info*
246 $(make-tar)
247 make-$(version).tar: README INSTALL COPYING ChangeLog NEWS \
248 configure Makefile.in configure.in build.sh.in mkinstalldirs \
249 acconfig.h $(srcs) remote-*.c $(globfiles) \
250 make.texinfo make-stds.texi \
251 make.?? make.??s make.toc make.aux make.man texinfo.tex TAGS tags
252 $(make-tar)
254 ifneq (,)
255 tests := $(filter-out %~,$(wildcard tests/*))
256 make-tests-$(version).tar.Z: $(tests)
257 @rm -fr make-tests-$(version)
258 ln -s tests make-tests-$(version)
259 tar cvhf $(@:.Z=) $(patsubst tests/%,make-tests-$(version)/%,$^)
260 rm -f make-tests-$(version)
261 compress -f $(@:.Z=)
262 endif
264 $(archpfx)loadtest: $(archpfx)load.o