1# This is a -*-Makefile-*-, or close enough
2#
3# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
4# Free Software Foundation, Inc.
5# This file is part of GNU Make.
6#
7# GNU Make is free software; you can redistribute it and/or modify it under the
8# terms of the GNU General Public License as published by the Free Software
9# Foundation; either version 2, or (at your option) any later version.
10#
11# GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
12# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License along with
16# GNU Make; see the file COPYING.  If not, write to the Free Software
17# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
19AUTOMAKE_OPTIONS = 1.8 dist-bzip2 check-news ansi2knr
20ACLOCAL_AMFLAGS	=  -I config
21
22MAKE_HOST =	@MAKE_HOST@
23
24# Only process if target is MS-Windows
25if WINDOWSENV
26  MAYBE_W32 =	w32
27  W32INC =	-I $(top_srcdir)/w32/include
28  W32LIB =	-Lw32 -lw32
29endif
30
31SUBDIRS =	glob config po doc $(MAYBE_W32)
32
33bin_PROGRAMS =	make
34
35if USE_CUSTOMS
36  remote =	remote-cstms.c
37else
38  remote =	remote-stub.c
39endif
40
41
42make_SOURCES =	ar.c arscan.c commands.c default.c dir.c expand.c file.c \
43		function.c getopt.c getopt1.c implicit.c job.c main.c \
44		misc.c read.c remake.c $(remote) rule.c signame.c \
45		strcache.c variable.c version.c vpath.c hash.c
46
47EXTRA_make_SOURCES = vmsjobs.c remote-stub.c remote-cstms.c
48
49noinst_HEADERS = commands.h dep.h filedef.h job.h make.h rule.h variable.h \
50		debug.h getopt.h gettext.h hash.h
51
52make_LDADD =	@LIBOBJS@ @ALLOCA@ $(GLOBLIB) @GETLOADAVG_LIBS@ @LIBINTL@
53# Only process if target is MS-Windows
54if WINDOWSENV
55    make_LDADD += $(W32LIB)
56endif
57
58man_MANS =	make.1
59
60DEFS =		-DLOCALEDIR=\"$(localedir)\" -DLIBDIR=\"$(libdir)\" -DINCLUDEDIR=\"$(includedir)\" @DEFS@
61
62AM_CPPFLAGS =	$(GLOBINC)
63# Only process if target is MS-Windows
64if WINDOWSENV
65    AM_CPPFLAGS +=	$(W32INC)
66endif
67
68
69# Extra stuff to include in the distribution.
70
71EXTRA_DIST =	README build.sh.in $(man_MANS) \
72		README.customs README.OS2 \
73		SCOPTIONS SMakefile \
74		README.Amiga Makefile.ami config.ami make.lnk amiga.c amiga.h \
75		README.DOS Makefile.DOS configure.bat dosbuild.bat configh.dos\
76		README.W32 NMakefile config.h.W32 build_w32.bat subproc.bat \
77		make_msvc_net2003.sln make_msvc_net2003.vcproj \
78		readme.vms makefile.vms makefile.com config.h-vms \
79		vmsdir.h vmsfunctions.c vmsify.c
80
81# This is built during configure, but behind configure's back
82
83DISTCLEANFILES = build.sh
84
85# Forward targets
86
87html:
88	cd doc && $(MAKE) $(AM_MAKEFLAGS) $@
89
90.PHONY: html
91
92# --------------- Internationalization Section
93
94localedir =	$(datadir)/locale
95
96# --------------- Local INSTALL Section
97
98# If necessary, change the gid of the app and turn on the setgid flag.
99#
100
101# Whether or not make needs to be installed setgid.
102# The value should be either `true' or `false'.
103# On many systems, the getloadavg function (used to implement the `-l'
104# switch) will not work unless make is installed setgid kmem.
105#
106inst_setgid = @NEED_SETGID@
107
108# Install make setgid to this group so it can get the load average.
109#
110inst_group = @KMEM_GROUP@
111
112install-exec-local:
113	@if $(inst_setgid); then \
114	   app=$(DESTDIR)$(bindir)/`echo $(bin_PROGRAMS)|sed '$(transform)'`; \
115	   if chgrp $(inst_group) $$app && chmod g+s $$app; then \
116	     echo "chgrp $(inst_group) $$app && chmod g+s $$app"; \
117	   else \
118	     echo "$$app needs to be owned by group $(inst_group) and setgid;"; \
119	     echo "otherwise the \`-l' option will probably not work."; \
120	     echo "You may need special privileges to complete the installation"; \
121	     echo "of $$app."; \
122	   fi; \
123	 else true; fi
124
125# --------------- Local DIST Section
126
127# Install the w32 and tests subdirectories
128#
129dist-hook:
130	(cd $(srcdir); \
131	 sub=`find w32 tests -follow \( -name CVS -prune -o -name .cvsignore -o -name work -prune \) -o \( -name \*.orig -o -name \*.rej -o -name \*~ -prune \) -o -type f -print`; \
132	 tar chf - $$sub) \
133	| (cd $(distdir); tar xfBp -)
134
135
136# --------------- Local CHECK Section
137
138check-local: check-regression check-loadavg
139	@banner=" Regression PASSED: GNU Make $(VERSION) ($(MAKE_HOST)) built with $(CC) "; \
140	dashes=`echo "$$banner" | sed s/./=/g`; \
141	echo; \
142	echo "$$dashes"; \
143	echo "$$banner"; \
144	echo "$$dashes"; \
145	echo
146
147.PHONY: check-loadavg check-regression
148
149check-loadavg: loadavg$(EXEEXT)
150	@echo The system uptime program believes the load average to be:
151	-uptime
152	@echo The GNU load average checking code thinks:
153	-./loadavg$(EXEEXT)
154
155# The loadavg function is invoked during "make check" to test getloadavg.
156check_PROGRAMS = loadavg
157nodist_loadavg_SOURCES = getloadavg.c
158loadavg_CPPFLAGS = -DTEST
159loadavg_LDADD = @GETLOADAVG_LIBS@
160
161# > check-regression
162#
163# Look for the make test suite, and run it if found and we can find perl.
164# If we're building outside the tree, we use symlinks to make a local copy of
165# the test suite.  Unfortunately the test suite itself isn't localizable yet.
166#
167MAKETESTFLAGS =
168
169check-regression:
170	@if test -f "$(srcdir)/tests/run_make_tests"; then \
171	  if $(PERL) -v >/dev/null 2>&1; then \
172	    case `cd $(srcdir); pwd` in `pwd`) : ;; \
173	      *) test -d tests || mkdir tests; \
174		 rm -f srctests; \
175		 if ln -s "$(srcdir)/tests" srctests; then \
176		   for f in run_make_tests run_make_tests.pl test_driver.pl scripts; do \
177		     rm -f tests/$$f; ln -s ../srctests/$$f tests; \
178		   done; fi ;; \
179	    esac; \
180	    echo "cd tests && $(PERL) ./run_make_tests.pl -make ../make$(EXEEXT) $(MAKETESTFLAGS)"; \
181	    cd tests && $(PERL) ./run_make_tests.pl -make ../make$(EXEEXT) $(MAKETESTFLAGS); \
182	  else \
183	    echo "Can't find a working Perl ($(PERL)); the test suite requires Perl."; \
184	  fi; \
185	 else \
186	  echo "Can't find the GNU Make test suite ($(srcdir)/tests)."; \
187	 fi
188
189
190# --------------- Maintainer's Section
191
192# Tell automake that I haven't forgotten about this file and it will be
193# created before we build a distribution (see maintMakefile in the CVS
194# distribution).
195
196README:
197
198@MAINT_MAKEFILE@
199