1# This is a -*-Makefile-*-, or close enough
2#
3# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
4# 2007, 2008, 2009, 2010 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
8# the terms of the GNU General Public License as published by the Free Software
9# Foundation; either version 3 of the License, or (at your option) any later
10# version.
11#
12# GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
13# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
15# details.
16#
17# You should have received a copy of the GNU General Public License along with
18# this program.  If not, see <http://www.gnu.org/licenses/>.
19
20AUTOMAKE_OPTIONS = 1.8 dist-bzip2 check-news
21ACLOCAL_AMFLAGS	=  -I config
22
23MAKE_HOST =	@MAKE_HOST@
24
25# Only process if target is MS-Windows
26if WINDOWSENV
27  MAYBE_W32 =	w32
28  W32INC =	-I $(top_srcdir)/w32/include
29  W32LIB =	-Lw32 -lw32
30endif
31
32# we can safely drop doc and po when bootstrapping kmk.
33# SUBDIRS =	glob config po doc $(MAYBE_W32)
34SUBDIRS =	glob config $(MAYBE_W32)
35
36bin_PROGRAMS =	kmk kmk_redirect
37
38if USE_CUSTOMS
39  remote =	remote-cstms.c
40else
41  remote =	remote-stub.c
42endif
43
44
45kmk_SOURCES =	ar.c arscan.c commands.c default.c dir.c expand.c file.c \
46		function.c getopt.c getopt1.c implicit.c job.c main.c \
47		misc.c read.c remake.c $(remote) rule.c signame.c \
48		strcache.c variable.c version.c vpath.c hash.c \
49		\
50		expreval.c \
51		incdep.c \
52		strcache2.c \
53		alloccache.c \
54		kbuild.c \
55		kbuild-object.c \
56		electric.c \
57		../lib/md5.c \
58		../lib/kDep.c \
59		../lib/kbuild_version.c \
60		../lib/dos2unix.c \
61		../lib/maybe_con_fwrite.c \
62		\
63		kmkbuiltin.c \
64		kmkbuiltin/append.c \
65		kmkbuiltin/cat.c \
66		kmkbuiltin/chmod.c \
67		kmkbuiltin/cmp.c \
68		kmkbuiltin/cmp_util.c \
69		kmkbuiltin/cp.c \
70		kmkbuiltin/cp_utils.c \
71		kmkbuiltin/echo.c \
72		kmkbuiltin/expr.c \
73		kmkbuiltin/install.c \
74		kmkbuiltin/kDepIDB.c \
75		kmkbuiltin/kDepObj.c \
76		kmkbuiltin/ln.c \
77		kmkbuiltin/md5sum.c \
78		kmkbuiltin/mkdir.c \
79		kmkbuiltin/mv.c \
80		kmkbuiltin/printf.c \
81		kmkbuiltin/redirect.c \
82		kmkbuiltin/rm.c \
83		kmkbuiltin/rmdir.c \
84		kmkbuiltin/sleep.c \
85		kmkbuiltin/test.c \
86		kmkbuiltin/touch.c \
87               \
88		kmkbuiltin/err.c \
89		kmkbuiltin/fts.c \
90		kmkbuiltin/setmode.c \
91		kmkbuiltin/strmode.c \
92		kmkbuiltin/strlcpy.c \
93		kmkbuiltin/osdep.c \
94		kmkbuiltin/kbuild_protection.c \
95		kmkbuiltin/common-env-and-cwd-opt.c
96
97kmk_redirect_SOURCES = kmkbuiltin/redirect.c \
98		kmkbuiltin/common-env-and-cwd-opt.c \
99		kmkbuiltin/err.c \
100		../lib/kbuild_version.c
101kmk_redirect_CFLAGS = -UKMK
102
103
104EXTRA_kmk_SOURCES = vmsjobs.c remote-stub.c remote-cstms.c
105
106noinst_HEADERS = commands.h dep.h filedef.h job.h make.h rule.h variable.h \
107		debug.h getopt.h gettext.h hash.h
108
109#kmk_LDADD =	@LIBOBJS@ @ALLOCA@ $(GLOBLIB) @GETLOADAVG_LIBS@ @LIBINTL@
110kmk_LDADD =	@LIBOBJS@ @ALLOCA@ $(GLOBLIB) @GETLOADAVG_LIBS@
111# Only process if target is MS-Windows
112if WINDOWSENV
113    kmk_LDADD += $(W32LIB)
114endif
115
116man_MANS =	make.1
117
118# org - DEFS =		-DLOCALEDIR=\"$(localedir)\" -DLIBDIR=\"$(libdir)\" -DINCLUDEDIR=\"$(includedir)\" @DEFS@
119DEFS = \
120	-DNO_ARCHIVES \
121	-DEXPERIMENTAL \
122	-DCONFIG_WITH_TOUPPER_TOLOWER \
123	-DCONFIG_WITH_DEFINED \
124	-DCONFIG_WITH_EXPLICIT_MULTITARGET \
125	-DCONFIG_WITH_DOT_MUST_MAKE \
126	-DCONFIG_WITH_PREPEND_ASSIGNMENT \
127	-DCONFIG_WITH_LOCAL_VARIABLES \
128	-DCONFIG_WITH_2ND_TARGET_EXPANSION \
129	-DCONFIG_WITH_ALLOC_CACHES \
130	-DCONFIG_WITH_STRCACHE2 \
131	\
132	-DKMK \
133	-DKMK_HELPERS \
134	-DCONFIG_NO_DEFAULT_SUFFIXES \
135	-DCONFIG_NO_DEFAULT_PATTERN_RULES	\
136	-DCONFIG_NO_DEFAULT_TERMINAL_RULES \
137	-DCONFIG_NO_DEFAULT_SUFFIX_RULES \
138	-DCONFIG_NO_DEFAULT_VARIABLES \
139	-DCONFIG_WITH_EXTENDED_NOTPARALLEL \
140	-DCONFIG_WITH_INCLUDEDEP \
141	-DCONFIG_WITHOUT_THREADS \
142	-DCONFIG_WITH_VALUE_LENGTH \
143	\
144	-DCONFIG_WITH_ABSPATHEX \
145	-DCONFIG_WITH_COMMANDS_FUNC \
146	-DCONFIG_WITH_DATE \
147	-DCONFIG_WITH_DEFINED_FUNCTIONS \
148	-DCONFIG_WITH_EVALPLUS \
149	-DCONFIG_WITH_FILE_SIZE \
150	-DCONFIG_WITH_LOOP_FUNCTIONS \
151	-DCONFIG_WITH_MATH \
152	-DCONFIG_WITH_NANOTS \
153	-DCONFIG_WITH_ROOT_FUNC \
154	-DCONFIG_WITH_RSORT \
155	-DCONFIG_WITH_STACK \
156	-DCONFIG_WITH_STRING_FUNCTIONS \
157	-DCONFIG_WITH_WHERE_FUNCTION \
158	-DCONFIG_WITH_WHICH \
159	-DCONFIG_WITH_XARGS \
160	\
161	-DCONFIG_WITH_COMPARE \
162	-DCONFIG_WITH_SET_CONDITIONALS \
163	-DCONFIG_WITH_IF_CONDITIONALS \
164	-DCONFIG_WITH_PRINTF \
165	-DCONFIG_WITH_MINIMAL_STATS \
166	-DCONFIG_PRETTY_COMMAND_PRINTING \
167	-DCONFIG_WITH_PRINT_STATS_SWITCH \
168	-DCONFIG_WITH_PRINT_TIME_SWITCH \
169	-DCONFIG_WITH_RDONLY_VARIABLE_VALUE \
170	-DCONFIG_WITH_LAZY_DEPS_VARS \
171	\
172	-DKBUILD_TYPE=\"$(KBUILD_TYPE)\" \
173	-DKBUILD_HOST=\"$(KBUILD_TARGET)\" \
174	-DKBUILD_HOST_ARCH=\"$(KBUILD_TARGET_ARCH)\" \
175	-DKBUILD_HOST_CPU=\"$(KBUILD_TARGET_CPU)\" \
176	\
177	-DKBUILD_SVN_REV=1 \
178	-DKBUILD_VERSION_MAJOR=0 \
179	-DKBUILD_VERSION_MINOR=1 \
180	-DKBUILD_VERSION_PATCH=9998 \
181	\
182	-DCONFIG_WITH_KMK_BUILTIN \
183    @DEFS@
184
185AM_CPPFLAGS =	$(GLOBINC) -I$(srcdir)/../lib -I$(srcdir)/../lib/kStuff/include
186# Only process if target is MS-Windows
187if WINDOWSENV
188    AM_CPPFLAGS +=	$(W32INC)
189endif
190
191
192# Extra stuff to include in the distribution.
193
194EXTRA_DIST =	README build.sh.in $(man_MANS) \
195		README.customs README.OS2 \
196		SCOPTIONS SMakefile \
197		README.Amiga Makefile.ami config.ami make.lnk amiga.c amiga.h \
198		README.DOS Makefile.DOS configure.bat dosbuild.bat configh.dos\
199		README.W32 NMakefile config.h.W32 build_w32.bat subproc.bat \
200		make_msvc_net2003.sln make_msvc_net2003.vcproj \
201		readme.vms makefile.vms makefile.com config.h-vms \
202		vmsdir.h vmsfunctions.c vmsify.c
203
204# This is built during configure, but behind configure's back
205
206DISTCLEANFILES = build.sh
207
208# Forward targets
209
210html:
211	cd doc && $(MAKE) $(AM_MAKEFLAGS) $@
212
213.PHONY: html
214
215# --------------- Internationalization Section
216
217localedir =	$(datadir)/locale
218
219# --------------- Local INSTALL Section
220
221# If necessary, change the gid of the app and turn on the setgid flag.
222#
223
224# Whether or not make needs to be installed setgid.
225# The value should be either `true' or `false'.
226# On many systems, the getloadavg function (used to implement the `-l'
227# switch) will not work unless make is installed setgid kmem.
228#
229inst_setgid = @NEED_SETGID@
230
231# Install make setgid to this group so it can get the load average.
232#
233inst_group = @KMEM_GROUP@
234
235install-exec-local:
236	@if $(inst_setgid); then \
237	   app=$(DESTDIR)$(bindir)/`echo $(bin_PROGRAMS)|sed '$(transform)'`; \
238	   if chgrp $(inst_group) $$app && chmod g+s $$app; then \
239	     echo "chgrp $(inst_group) $$app && chmod g+s $$app"; \
240	   else \
241	     echo "$$app needs to be owned by group $(inst_group) and setgid;"; \
242	     echo "otherwise the \`-l' option will probably not work."; \
243	     echo "You may need special privileges to complete the installation"; \
244	     echo "of $$app."; \
245	   fi; \
246	 else true; fi
247
248# --------------- Local DIST Section
249
250# Install the w32 and tests subdirectories
251#
252dist-hook:
253	(cd $(srcdir); \
254	 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`; \
255	 tar chf - $$sub) \
256	| (cd $(distdir); tar xfBp -)
257
258
259# --------------- Local CHECK Section
260
261check-local: check-regression check-loadavg
262	@banner=" Regression PASSED: GNU Make $(VERSION) ($(MAKE_HOST)) built with $(CC) "; \
263	dashes=`echo "$$banner" | sed s/./=/g`; \
264	echo; \
265	echo "$$dashes"; \
266	echo "$$banner"; \
267	echo "$$dashes"; \
268	echo
269
270.PHONY: check-loadavg check-regression
271
272check-loadavg: loadavg$(EXEEXT)
273	@echo The system uptime program believes the load average to be:
274	-uptime
275	@echo The GNU load average checking code thinks:
276	-./loadavg$(EXEEXT)
277
278# The loadavg function is invoked during "make check" to test getloadavg.
279check_PROGRAMS = loadavg
280nodist_loadavg_SOURCES = getloadavg.c
281loadavg_CPPFLAGS = -DTEST
282loadavg_LDADD = @GETLOADAVG_LIBS@
283
284# > check-regression
285#
286# Look for the make test suite, and run it if found and we can find perl.
287# If we're building outside the tree, we use symlinks to make a local copy of
288# the test suite.  Unfortunately the test suite itself isn't localizable yet.
289#
290MAKETESTFLAGS =
291
292check-regression:
293	@if test -f "$(srcdir)/tests/run_make_tests"; then \
294	  if $(PERL) -v >/dev/null 2>&1; then \
295	    case `cd $(srcdir); pwd` in `pwd`) : ;; \
296	      *) test -d tests || mkdir tests; \
297		 rm -f srctests; \
298		 if ln -s "$(srcdir)/tests" srctests; then \
299		   for f in run_make_tests run_make_tests.pl test_driver.pl scripts; do \
300		     rm -f tests/$$f; ln -s ../srctests/$$f tests; \
301		   done; fi ;; \
302	    esac; \
303	    echo "cd tests && $(PERL) ./run_make_tests.pl -make ../make$(EXEEXT) $(MAKETESTFLAGS)"; \
304	    cd tests && $(PERL) ./run_make_tests.pl -make ../make$(EXEEXT) $(MAKETESTFLAGS); \
305	  else \
306	    echo "Can't find a working Perl ($(PERL)); the test suite requires Perl."; \
307	  fi; \
308	 else \
309	  echo "Can't find the GNU Make test suite ($(srcdir)/tests)."; \
310	 fi
311
312
313# --------------- Maintainer's Section
314
315# Tell automake that I haven't forgotten about this file and it will be
316# created before we build a distribution (see maintMakefile in the CVS
317# distribution).
318
319README:
320
321@MAINT_MAKEFILE@
322