1# This is a -*-Makefile-*-, or close enough
2
3AUTOMAKE_OPTIONS = 1.7 dist-bzip2 check-news
4ACLOCAL_AMFLAGS	=  -I config
5
6SUBDIRS =	glob config po doc
7
8bin_PROGRAMS =	make
9
10if USE_CUSTOMS
11  remote =	remote-cstms.c
12else
13  remote =	remote-stub.c
14endif
15
16make_SOURCES =	ar.c arscan.c commands.c default.c dir.c expand.c file.c \
17		function.c getopt.c getopt1.c implicit.c job.c main.c \
18		misc.c read.c remake.c $(remote) rule.c signame.c \
19		variable.c version.c vpath.c hash.c
20
21EXTRA_make_SOURCES = remote-stub.c remote-cstms.c
22
23noinst_HEADERS = commands.h dep.h filedef.h job.h make.h rule.h variable.h \
24		debug.h getopt.h gettext.h hash.h
25
26make_LDADD =	@LIBOBJS@ @ALLOCA@ $(GLOBLIB) @GETLOADAVG_LIBS@ @LIBINTL@
27
28man_MANS =	make.1
29
30DEFS =		-DLOCALEDIR=\"$(localedir)\" -DLIBDIR=\"$(libdir)\" -DINCLUDEDIR=\"$(includedir)\" @DEFS@
31
32AM_CPPFLAGS =	$(GLOBINC)
33
34
35# Extra stuff to include in the distribution.
36# Note we need all the glob stuff here, rather than in glob/Makefile.am,
37# because often that directory isn't built on the systems used by the
38# maintainers.
39
40EXTRA_DIST =	README build.sh.in $(man_MANS)\
41		README.customs\
42		SCOPTIONS SMakefile\
43		README.Amiga Makefile.ami config.ami make.lnk amiga.c amiga.h\
44		README.DOS Makefile.DOS configure.bat dosbuild.bat configh.dos\
45		README.W32 NMakefile config.h.W32 build_w32.bat subproc.bat\
46		readme.vms makefile.vms makefile.com config.h-vms \
47		vmsdir.h vmsfunctions.c vmsify.c
48
49MAKE_HOST =	@MAKE_HOST@
50
51
52# Forward targets
53
54html:
55	cd doc && $(MAKE) $(AM_MAKEFLAGS) $@
56
57.PHONY: html
58
59# --------------- Internationalization Section
60
61localedir =	$(datadir)/locale
62
63# --------------- Local INSTALL Section
64
65# If necessary, change the gid of the app and turn on the setgid flag.
66#
67
68# Whether or not make needs to be installed setgid.
69# The value should be either `true' or `false'.
70# On many systems, the getloadavg function (used to implement the `-l'
71# switch) will not work unless make is installed setgid kmem.
72#
73inst_setgid = @NEED_SETGID@
74
75# Install make setgid to this group so it can get the load average.
76#
77inst_group = @KMEM_GROUP@
78
79install-exec-local:
80	@if $(inst_setgid); then \
81	   app=$(DESTDIR)$(bindir)/`echo $(bin_PROGRAMS)|sed '$(transform)'`; \
82	   if chgrp $(inst_group) $$app && chmod g+s $$app; then \
83	     echo "chgrp $(inst_group) $$app && chmod g+s $$app"; \
84	   else \
85	     echo "$$app needs to be owned by group $(inst_group) and setgid;"; \
86	     echo "otherwise the \`-l' option will probably not work."; \
87	     echo "You may need special privileges to complete the installation"; \
88	     echo "of $$app."; \
89	   fi; \
90	 else true; fi
91
92# --------------- 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