Sun Jul 28 15:37:09 1996 Rob Tulloh (tulloh@tivoli.com)
[make.git] / GNUmakefile
blobdc3440974b5dee3d651b87dbac917ef991a221c3
1 # GNU Make-specific makefile for GNU Make.
3 # Copyright (C) 1990, 91, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
4 # This file is part of GNU Make.
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))
53 CPPFLAGS := $(filter-out @%@,$(defines) $(CPPFLAGS)) -DHAVE_CONFIG_H
55 ifdef AC_MACRODIR
56 configure config.h.in: $(patsubst %,$(AC_MACRODIR)/%.m4,acspecific acgeneral)
57 config.h.in: $(AC_MACRODIR)/acconfig.h
58 endif
59 configure: configure.in aclocal.m4
60 autoconf $(ACFLAGS)
61 test -d CVS && cvs commit -m'autoconf $(ACFLAGS)' $@
62 config.h.in: configure.in aclocal.m4
63 autoheader $(ACFLAGS)
64 test -d CVS && cvs commit -m'autoheader $(ACFLAGS)' $@
66 ifdef customs
67 defines := $(defines) -Ipmake/customs -Ipmake/lib/include
68 LOADLIBES := $(addprefix pmake/customs/,customslib.o rpc.o xlog.o) \
69 pmake/lib/sprite/libsprite.a
70 endif
72 ifdef ARCH
74 ifndef no_libc
75 libc_dir = /home/gd2/gnu/libc/$(ARCH)
76 ifneq ($(wildcard $(libc_dir)),)
77 ifneq ($(wildcard $(libc_dir)/works-for-make),)
78 #CPPFLAGS := -I$(libc_dir)/include
79 #LDFLAGS := -nostdlib $(libc_dir)/lib/start.o
80 #LOADLIBES := $(LOADLIBES) \
81 # $(libc_dir)/lib/mcheck-init.o \
82 # $(libc_dir)/lib/libc.a \
83 # -lgcc \
84 # $(libc_dir)/lib/libc.a
85 CC := $(CC) -b glibc
87 # getopt is in libc.
88 GETOPT =
89 #GETOPT_SRC = Don't clear this or dist will break.
91 # glob is in libc too.
92 GLOB =
94 else
96 endif # works-for-make
97 endif # $(libc_dir)
98 endif # !no_libc
100 # We know the type of machine, so put the binaries in subdirectories.
101 $(ARCH)/%.o: %.c
102 $(COMPILE.c) -Iglob $< $(OUTPUT_OPTION)
103 $(ARCH)/glob/libglob.a: FORCE
104 $(MAKE) -C $(@D) $(@F)
105 FORCE:
106 objs := $(addprefix $(ARCH)/,$(objs))
107 prog := $(ARCH)/make
109 archpfx = $(ARCH)/
111 $(archpfx)load.o: load.c
112 $(COMPILE.c) $(LOAD_AVG) $< -o $@
113 $(archpfx)load.dep: load.c
114 $(mkdep) $(LOAD_AVG) $< | sed 's,$*\.o,& $@,' > $@
116 CPPFLAGS := -I$(ARCH) -Iglob -DHAVE_CONFIG_H $(filter-out @%@,$(CPPFLAGS))
118 ifneq "$(wildcard $(ARCH)/makefile)" ""
119 include $(ARCH)/makefile
120 endif
121 objs := $(objs) $(addprefix $(ARCH)/,$(ALLOCA) $(extras))
123 else # Not ARCH
124 prog := make
125 endif
127 ifneq "$(findstring gcc,$(CC))" ""
128 CFLAGS = -g -Wall -Wtraditional -Wid-clash-31 -Wpointer-arith \
129 -Wbad-function-cast -Wconversion
130 else
131 CFLAGS = -g
132 endif
133 LDFLAGS = -g
135 # Define the command to make dependencies.
136 mkdep-nolib = $(CC) -MM $(CPPFLAGS)
137 mkdep = $(CC) -M $(CPPFLAGS)
139 depfiles = $(patsubst %.o,%.dep,$(filter %.o,$(objs)))
142 .PHONY: default
143 default: $(prog)
145 $(prog): $(objs) $(globdep) #$(addprefix $(ARCH)/,gmalloc.o mcheck.o)
146 $(CC) $(LDFLAGS) $^ $(globlib) $(LOADLIBES) -o $@.new
147 mv -f $@.new $@
149 libc-srcdir = ../libc
150 globfiles = $(addprefix glob/,COPYING.LIB configure.in configure Makefile.in \
151 Makefile.ami SCOPTIONS SMakefile \
152 configure.bat glob.c fnmatch.c glob.h fnmatch.h)
153 $(globfiles): stamp-glob ;
154 stamp-glob: $(libc-srcdir)/posix/glob.tar
155 -rm -f stamp-glob glob/*
156 tar xvf $< glob
157 cvs commit -m'Updated from libc' glob
158 touch $@
159 $(libc-srcdir)/posix/glob.tar: force
160 $(MAKE) -C $(@D) $(@F) no_deps=t
161 .PHONY: force
162 force:
164 # Make the Unix-compatible Makefile to be distributed by appending
165 # the automatically-generated dependencies to compatMakefile.
166 ifeq ($(mkdep),$(mkdep-nolib))
167 nolib-deps = $(depfiles)
168 else
169 %.dep: %.c
170 $(mkdep-nolib) $< | sed -e 's,$*\.o,$(@:.dep=.o) $@,' > $(@:.dep=.dtm)
171 mv -f $(@:.dep=.dtm) $@
172 nolib-deps = $(patsubst $(archpfx)%,%,$(depfiles))
173 endif
174 # The distributed Makefile.in should contain deps for remote-stub only.
175 Makefile.in: compatMakefile $(nolib-deps:remote-%.dep=remote-stub.dep)
176 (sed 's/^MAKE[ ]*=.*$$/@SET_MAKE@/' $<; \
177 echo '# Automatically generated dependencies.'; \
178 sed -e 's/ [^ ]*\.dep//' -e 's=$(archpfx)==' $(filter-out $<,$^) \
179 ) > $@
180 cvs commit -mRegenerated $@
182 .SUFFIXES: .dep
183 # Maintain the automatically-generated dependencies.
184 ifndef no_deps
185 -include $(depfiles)
186 endif
187 $(archpfx)%.dep: %.c
188 $(mkdep) $< | sed 's,$*\.o,$(@:.dep=.o) $@,' > $@
190 ETAGS = etags -T # for v19 etags
192 # Run the tests.
193 .PHONY: tests
194 testdir := $(shell ls -d1 make-test-?.? | sort -n +0.10 -0.11 +0.12 | tail -1l)
195 tests:# $(testdir)/run_make_tests.pl $(prog)
196 # cd $(<D); MAKELEVEL=0 perl $(<F)
198 build.sh.in: build.template compatMakefile
199 sed -e 's@%objs%@$(filter-out remote-% $(GLOB) $(ALLOCA) $(extras),\
200 $(patsubst $(archpfx)%,%,$(objs)))\
201 $(patsubst %.c,%.o,$(filter %.c,$(globfiles)))@' \
202 $< > $@.new
203 chmod a+x $@.new
204 mv -f $@.new $@
205 cvs commit -mRegenerated $@
207 # Make the distribution tar files.
209 .PHONY: dist
210 # Figure out the version number from the source of `version.c'.
211 version := \
212 $(strip $(shell sed -e '/=/!d' -e 's/^.*"\(.*\)";$$/\1/' < version.c))
213 tarfiles := make # make-doc
214 tarfiles := $(addsuffix -$(version).tar,$(tarfiles))
215 tarfiles := $(tarfiles:%=%.gz) # no more compress $(tarfiles:%=%.Z)
216 # Depend on default and doc so we don't ship anything that won't compile.
217 dist: cvs-mark default info dvi tests tarfiles
218 .PHONY: tarfiles
219 tarfiles: $(tarfiles)
221 vmsfiles = config.h-vms makefile.com makefile.vms readme.vms \
222 vmsdir.h vmsfunctions.c vmsify.c
223 amigafiles = README.Amiga config.ami Makefile.ami SCOPTIONS SMakefile \
224 amiga.c amiga.h make.lnk
225 win32files = README.WIN32 build_w32.bat config.h.WIN32 subproc.bat NMakefile \
226 $(addprefix w32/,pathstuff.c compat/dirent.c include/dirent.h \
227 include/pathstuff.h include/sub_proc.h \
228 include/w32err.h subproc/NMakefile \
229 subproc/build.bat subproc/misc.c \
230 subproc/proc.h subproc/sub_proc.c \
231 subproc/w32err.c)
232 distfiles=README INSTALL COPYING ChangeLog NEWS \
233 configure Makefile.in configure.in build.sh.in mkinstalldirs \
234 configh.dos configure.bat \
235 $(amigafiles) $(vmsfiles) $(win32files) \
236 aclocal.m4 acconfig.h $(srcs) remote-*.c $(globfiles) \
237 make.texinfo make-stds.texi \
238 make.?? make.??s make.toc make.aux make.man texinfo.tex TAGS tags \
239 install-sh \
240 make.info make.info*
242 ifndef dist-flavor
243 dist-flavor = alpha
244 endif
245 .PHONY: cvs-mark
246 cvs-mark: $(distfiles)
247 cvs tag -F make-$(subst .,-,$(version))
249 dist: local-inst
250 .PHONY: local-inst
251 local-inst: $(prog)
252 install -c -g kmem -o $(USER) -m 2755 $< /usr/local/gnubin/make
254 # Put the alpha distribution files in the anonymous FTP directory.
255 alpha-files = $(tarfiles) GNUmakefile compatMakefile $(testdir).tar.Z
256 dist: alpha
257 .PHONY: alpha
258 alpha-dir := ~ftp/gnu
259 alpha-files := $(addprefix $(alpha-dir)/,$(alpha-files))
260 alpha: $(alpha-dir) $(alpha-files)
261 $(alpha-dir)/%: %
262 @rm -f $@
263 cp $< $@
265 # Implicit rule to make README and README-doc.
266 %: %.template version.c
267 rm -f $@
268 sed 's/VERSION/$(version)/' < $< > $@
269 # Make sure I don't edit it by accident.
270 chmod a-w $@
271 cvs commit -m'Regenerated for $(version)' $@
273 define make-tar
274 @rm -fr make-$(version)
275 ln -s . make-$(version)
276 tar cvhof $@ $(addprefix make-$(version)/,$^)
277 rm -f make-$(version)
278 endef
280 %.Z: %; compress -c $< > $@
281 %.gz: %; gzip -9 -c -v $< > $@
283 make-$(version).tar: $(distfiles)
284 $(make-tar)
286 ifneq (,)
287 tests := $(filter-out %~,$(wildcard tests/*))
288 make-tests-$(version).tar.Z: $(tests)
289 @rm -fr make-tests-$(version)
290 ln -s tests make-tests-$(version)
291 tar cvhf $(@:.Z=) $(patsubst tests/%,make-tests-$(version)/%,$^)
292 rm -f make-tests-$(version)
293 compress -f $(@:.Z=)
294 endif
296 $(archpfx)loadtest: $(archpfx)load.o