(make-$(version).tar): Rename install.sh to install-sh.
[platform/upstream/make.git] / GNUmakefile
1 # GNU Make-specific makefile for GNU Make.
2
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.
10 #
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.
15
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.
19
20 .PHONY: default
21 default:
22
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
29
30 override srcdir := .
31 override CC := $(CC)
32
33 ifeq ($(ARCH),hp300)
34 #customs=yes
35 endif
36 ifdef customs
37 override REMOTE := cstms
38 else
39 override REMOTE := stub
40 endif
41
42 # Get most of the information from the Unix-compatible makefile.
43 include compatMakefile
44
45 MAKE = $(MAKE_COMMAND) $(MAKEOVERRIDES)
46
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
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)
60
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
66
67 ifdef ARCH
68
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
81
82 # getopt is in libc.
83 GETOPT =
84 #GETOPT_SRC = Don't clear this or dist will break.
85
86 # glob is in libc too.
87 GLOB = 
88
89 else
90
91 CPPFLAGS := $(filter-out @%@,$(CPPFLAGS)) -Iglob
92
93 endif    # works-for-make
94 endif    # $(libc_dir)
95 endif    # !no_libc
96
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
105
106 archpfx = $(ARCH)/
107
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,& $@,' > $@
112
113 CPPFLAGS := -I$(ARCH) $(CPPFLAGS) -DHAVE_CONFIG_H $(filter-out @%@,$(defines))
114
115 ifneq "$(wildcard $(ARCH)/makefile)" ""
116 include $(ARCH)/makefile
117 endif
118 objs := $(objs) $(addprefix $(ARCH)/,$(ALLOCA) $(extras))
119
120 else # Not ARCH
121 prog := make
122 endif
123
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
130
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)
139
140 depfiles = $(patsubst %.o,%.dep,$(filter %.o,$(objs)))
141
142
143 .PHONY: default
144 default: $(prog)
145
146 $(prog): $(objs) $(globdep) #$(addprefix $(ARCH)/,gmalloc.o mcheck.o)
147         $(CC) $(LDFLAGS) $^ $(globlib) $(LOADLIBES) -o $@.new
148         mv -f $@.new $@
149
150 globfiles = $(addprefix glob/,COPYING.LIB 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:
161
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         ) > $@
178
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) $@,' > $@
186
187 ETAGS = etags -T # for v19 etags
188
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)
194
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         mv -f $@.new $@
201 \f
202 # Make the distribution tar files.
203
204 .PHONY: dist
205 # Figure out the version number from the source of `version.c'.
206 version := \
207   $(strip $(shell sed -e '/=/!d' -e 's/^.*"\(.*\)";$$/\1/' < version.c))
208 tarfiles := make # make-doc
209 tarfiles := $(addsuffix -$(version).tar,$(tarfiles))
210 tarfiles := $(tarfiles:%=%.gz) # no more compress $(tarfiles:%=%.Z)
211 # Depend on default and doc so we don't ship anything that won't compile.
212 dist: rcs-mark default info dvi tests tarfiles
213 .PHONY: tarfiles
214 tarfiles: $(tarfiles)
215
216 ifndef dist-flavor
217 dist-flavor = alpha
218 endif
219 .PHONY: rcs-mark rcs-mark-alpha rcs-mark-beta
220 rcs-mark: rcs-mark-$(dist-flavor)
221 rcs-mark-alpha: RCS/[!=]*,v;rcs -sAlpha -Nmake-$(version-): $^
222 rcs-mark-beta: RCS/[!=]*,v;rcs -sBeta -Nmake-$(version-): $^
223 version- = $(subst .,-,$(version))
224
225 dist: local-inst
226 .PHONY: local-inst
227 local-inst: $(prog)
228         install -c -g kmem -o $(USER) -m 2755 $< /usr/local/gnubin/make
229
230 # Put the alpha distribution files in the anonymous FTP directory.
231 alpha-files = $(tarfiles) GNUmakefile compatMakefile $(testdir).tar.Z
232 dist: alpha
233 .PHONY: alpha
234 alpha-dir := ~ftp/gnu
235 alpha-files := $(addprefix $(alpha-dir)/,$(alpha-files))
236 alpha: $(alpha-dir) $(alpha-files)
237 $(alpha-dir)/%: %
238         @rm -f $@
239         cp $< $@
240
241 # Implicit rule to make README and README-doc.
242 %: %.template version.c
243         rm -f $@
244         sed 's/VERSION/$(version)/' < $< > $@
245 # Make sure I don't edit it by accident.
246         chmod a-w $@
247
248 define make-tar
249 @rm -fr make-$(version)
250 ln -s . make-$(version)
251 tar cvhof $@ $(addprefix make-$(version)/,$^)
252 rm -f make-$(version)
253 endef
254
255 %.Z: %; compress -c $< > $@
256 %.gz: %; gzip -9 -c -v $< > $@
257
258 make-doc-$(version).tar: README-doc COPYING make.dvi make.info make.info*
259         $(make-tar)
260 make-$(version).tar: README INSTALL COPYING ChangeLog NEWS \
261           configure Makefile.in configure.in build.sh.in mkinstalldirs \
262           acconfig.h $(srcs) remote-*.c $(globfiles) \
263           make.texinfo make-stds.texi \
264           make.?? make.??s make.toc make.aux make.man texinfo.tex TAGS tags \
265           install-sh \
266           make.info make.info*
267         $(make-tar)
268
269 ifneq (,)
270 tests := $(filter-out %~,$(wildcard tests/*))
271 make-tests-$(version).tar.Z: $(tests)
272         @rm -fr make-tests-$(version)
273         ln -s tests make-tests-$(version)
274         tar cvhf $(@:.Z=) $(patsubst tests/%,make-tests-$(version)/%,$^)
275         rm -f make-tests-$(version)
276         compress -f $(@:.Z=)
277 endif
278
279 $(archpfx)loadtest: $(archpfx)load.o