155682Smarkm# This is a -*-Makefile-*-, or close enough
255682Smarkm
355682SmarkmAUTOMAKE_OPTIONS = 1.7 dist-bzip2 check-news
455682SmarkmACLOCAL_AMFLAGS	=  -I config
555682Smarkm
655682SmarkmSUBDIRS =	glob config po doc
755682Smarkm
855682Smarkmbin_PROGRAMS =	make
955682Smarkm
1055682Smarkmif USE_CUSTOMS
1155682Smarkm  remote =	remote-cstms.c
1255682Smarkmelse
1355682Smarkm  remote =	remote-stub.c
1455682Smarkmendif
1555682Smarkm
1655682Smarkmmake_SOURCES =	ar.c arscan.c commands.c default.c dir.c expand.c file.c \
1755682Smarkm		function.c getopt.c getopt1.c implicit.c job.c main.c \
1855682Smarkm		misc.c read.c remake.c $(remote) rule.c signame.c \
1955682Smarkm		variable.c version.c vpath.c hash.c
2055682Smarkm
2155682SmarkmEXTRA_make_SOURCES = remote-stub.c remote-cstms.c
2255682Smarkm
2355682Smarkmnoinst_HEADERS = commands.h dep.h filedef.h job.h make.h rule.h variable.h \
2455682Smarkm		debug.h getopt.h gettext.h hash.h
2555682Smarkm
2655682Smarkmmake_LDADD =	@LIBOBJS@ @ALLOCA@ $(GLOBLIB) @GETLOADAVG_LIBS@ @LIBINTL@
2755682Smarkm
2855682Smarkmman_MANS =	make.1
2955682Smarkm
3055682SmarkmDEFS =		-DLOCALEDIR=\"$(localedir)\" -DLIBDIR=\"$(libdir)\" -DINCLUDEDIR=\"$(includedir)\" @DEFS@
3155682Smarkm
3255682SmarkmAM_CPPFLAGS =	$(GLOBINC)
3355682Smarkm
3455682Smarkm
3555682Smarkm# Extra stuff to include in the distribution.
36178825Sdfr# Note we need all the glob stuff here, rather than in glob/Makefile.am,
3755682Smarkm# because often that directory isn't built on the systems used by the
3855682Smarkm# maintainers.
3955682Smarkm
4055682SmarkmEXTRA_DIST =	README build.sh.in $(man_MANS)\
4155682Smarkm		README.customs\
4255682Smarkm		SCOPTIONS SMakefile\
4355682Smarkm		README.Amiga Makefile.ami config.ami make.lnk amiga.c amiga.h\
4455682Smarkm		README.DOS Makefile.DOS configure.bat dosbuild.bat configh.dos\
4555682Smarkm		README.W32 NMakefile config.h.W32 build_w32.bat subproc.bat\
4655682Smarkm		readme.vms makefile.vms makefile.com config.h-vms \
4755682Smarkm		vmsdir.h vmsfunctions.c vmsify.c
4855682Smarkm
4955682SmarkmMAKE_HOST =	@MAKE_HOST@
5055682Smarkm
5155682Smarkm
5255682Smarkm# Forward targets
5355682Smarkm
5455682Smarkmhtml:
5555682Smarkm	cd doc && $(MAKE) $(AM_MAKEFLAGS) $@
5655682Smarkm
5755682Smarkm.PHONY: html
5855682Smarkm
5955682Smarkm# --------------- Internationalization Section
6055682Smarkm
6155682Smarkmlocaledir =	$(datadir)/locale
6255682Smarkm
6355682Smarkm# --------------- Local INSTALL Section
6455682Smarkm
6555682Smarkm# If necessary, change the gid of the app and turn on the setgid flag.
6655682Smarkm#
6755682Smarkm
6855682Smarkm# Whether or not make needs to be installed setgid.
6990926Snectar# The value should be either `true' or `false'.
7055682Smarkm# On many systems, the getloadavg function (used to implement the `-l'
7155682Smarkm# switch) will not work unless make is installed setgid kmem.
7255682Smarkm#
7355682Smarkminst_setgid = @NEED_SETGID@
7455682Smarkm
7555682Smarkm# Install make setgid to this group so it can get the load average.
7655682Smarkm#
7755682Smarkminst_group = @KMEM_GROUP@
7855682Smarkm
7955682Smarkminstall-exec-local:
8055682Smarkm	@if $(inst_setgid); then \
8155682Smarkm	   app=$(DESTDIR)$(bindir)/`echo $(bin_PROGRAMS)|sed '$(transform)'`; \
8255682Smarkm	   if chgrp $(inst_group) $$app && chmod g+s $$app; then \
8355682Smarkm	     echo "chgrp $(inst_group) $$app && chmod g+s $$app"; \
8455682Smarkm	   else \
8555682Smarkm	     echo "$$app needs to be owned by group $(inst_group) and setgid;"; \
8655682Smarkm	     echo "otherwise the \`-l' option will probably not work."; \
8755682Smarkm	     echo "You may need special privileges to complete the installation"; \
8855682Smarkm	     echo "of $$app."; \
8955682Smarkm	   fi; \
9055682Smarkm	 else true; fi
9155682Smarkm
9255682Smarkm# --------------- Local DIST Section
93
94# Install the w32 and tests subdirectories
95#
96dist-hook:
97	(cd $(srcdir); \
98	 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`; \
99	 tar chf - $$sub) \
100	| (cd $(distdir); tar xfBp -)
101
102
103# --------------- Local CHECK Section
104
105check-local: check-regression check-loadavg
106	@banner=" Regression PASSED: GNU Make $(VERSION) ($(MAKE_HOST)) built with $(CC) "; \
107	dashes=`echo "$$banner" | sed s/./=/g`; \
108	echo; \
109	echo "$$dashes"; \
110	echo "$$banner"; \
111	echo "$$dashes"; \
112	echo
113
114.PHONY: check-loadavg check-regression
115
116check-loadavg: loadavg
117	@echo The system uptime program believes the load average to be:
118	-uptime
119	@echo The GNU load average checking code thinks:
120	-./loadavg
121
122# The loadavg function is invoked during "make check" to test getloadavg.
123noinst_PROGRAMS = loadavg
124loadavg_SOURCES = loadavg.c
125loadavg_CFLAGS = -DTEST
126loadavg_LDADD = @GETLOADAVG_LIBS@
127
128loadavg.c: $(srcdir)/getloadavg.c
129	cp $(srcdir)/getloadavg.c loadavg.c
130
131# > check-regression
132#
133# Look for the make test suite, and run it if found and we can find perl.
134# If we're building outside the tree, we use symlinks to make a local copy of
135# the test suite.  Unfortunately the test suite itself isn't localizable yet.
136#
137MAKETESTFLAGS =
138
139check-regression:
140	@if test -f "$(srcdir)/tests/run_make_tests"; then \
141	  if $(PERL) -v >/dev/null 2>&1; then \
142	    case `cd $(srcdir); pwd` in `pwd`) : ;; \
143	      *) test -d tests || mkdir tests; \
144		 rm -f srctests; \
145		 if ln -s "$(srcdir)/tests" srctests; then \
146		   for f in run_make_tests run_make_tests.pl test_driver.pl scripts; do \
147		     rm -f tests/$$f; ln -s ../srctests/$$f tests; \
148		   done; fi ;; \
149	    esac; \
150	    echo "cd tests && $(PERL) ./run_make_tests.pl -make ../make $(MAKETESTFLAGS)"; \
151	    cd tests && $(PERL) ./run_make_tests.pl -make ../make $(MAKETESTFLAGS); \
152	  else \
153	    echo "Can't find a working Perl ($(PERL)); the test suite requires Perl."; \
154	  fi; \
155	 else \
156	  echo "Can't find the GNU Make test suite ($(srcdir)/tests)."; \
157	 fi
158
159
160# --------------- Maintainer's Section
161
162@MAINT_MAKEFILE@
163