From 075ba16df2a1cde1b5a50c5e2088d797cf97595f Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sun, 28 Mar 1999 22:52:03 +0000 Subject: [PATCH] * m4/Makefile.am (dist_m4data_DATA): Renamed, and added new files. (EXTRA_DIST): Removed. * automake.in (dependency_macros): New global. (scan_one_configure_file): Recognize new dependency tracking macros, and define new resulting configure variables. (generate_dependency_code): New sub. (handle_dependencies): Use it. * depend2.am (DEP_@FPFX@COMPILE): New macro. (@EXT@.o): Use it. (@EXT@.lo): Likewise. * m4/depvars.m4: New file. * m4/objcdepend.m4: New file. * m4/cxxdepend.m4: New file. * m4/init.m4: Moved dependency handling code into depout.m4. * m4/depout.m4: New file. * m4/ccdepend.m4: New file. * m4/depend.m4: New file. --- ChangeLog | 19 +++++++ automake.in | 68 +++++++++++++++++-------- depend.am | 2 +- depend2.am | 49 ++++-------------- m4/Makefile.am | 9 ++-- m4/Makefile.in | 31 +++++------ m4/ccdepend.m4 | 7 +++ m4/cxxdepend.m4 | 7 +++ m4/depend.m4 | 130 +++++++++++++++++++++++++++++++++++++++++++++++ m4/depout.m4 | 34 +++++++++++++ m4/depvars.m4 | 69 +++++++++++++++++++++++++ m4/init.m4 | 31 +---------- m4/objcdepend.m4 | 14 +++++ 13 files changed, 355 insertions(+), 115 deletions(-) create mode 100644 m4/ccdepend.m4 create mode 100644 m4/cxxdepend.m4 create mode 100644 m4/depend.m4 create mode 100644 m4/depout.m4 create mode 100644 m4/depvars.m4 create mode 100644 m4/objcdepend.m4 diff --git a/ChangeLog b/ChangeLog index 50cded2ca..66547bb9b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,24 @@ 1999-03-28 Tom Tromey + * m4/Makefile.am (dist_m4data_DATA): Renamed, and added new + files. + (EXTRA_DIST): Removed. + * automake.in (dependency_macros): New global. + (scan_one_configure_file): Recognize new dependency tracking + macros, and define new resulting configure variables. + (generate_dependency_code): New sub. + (handle_dependencies): Use it. + * depend2.am (DEP_@FPFX@COMPILE): New macro. + (@EXT@.o): Use it. + (@EXT@.lo): Likewise. + * m4/depvars.m4: New file. + * m4/objcdepend.m4: New file. + * m4/cxxdepend.m4: New file. + * m4/init.m4: Moved dependency handling code into depout.m4. + * m4/depout.m4: New file. + * m4/ccdepend.m4: New file. + * m4/depend.m4: New file. + * depend2.am (@EXT@.o): Renamed to be old-style suffix pattern. (@EXT@.lo): Likewise. * m4/init.m4 (AM_INIT_AUTOMAKE): Don't create `.deps/.P'; it is no diff --git a/automake.in b/automake.in index e27a506d6..53c285b72 100755 --- a/automake.in +++ b/automake.in @@ -286,6 +286,10 @@ $obsolete_rx = '(' . join ('|', keys %obsolete_macros) . ')'; # This maps languages names onto properties. %language_map = (); +# This hash keeps track of whether various configure macros for +# dependency tracking have been seen. +%dependency_macros = (); + # Initialize global constants and our list of languages that are @@ -2504,6 +2508,30 @@ distcheck: dist &handle_dist_worker ($makefile); } +# Generate dependency-tracking code for a single language. +# Subroutine of handle_dependencies. +sub generate_dependency_code +{ + local ($lang, $fullname, $subst) = @_; + + local ($error) = 0; + local ($ext); + foreach $ext (&lang_extensions ($lang)) + { + if (! defined $dependency_macros{$fullname} && ! $error) + { + &am_error ("dependency tracking enabled but \`AM_${fullname}_DEPENDENCIES' not seen in configure.in"); + $error = 1; + } + + $output_rules .= + &file_contents_with_transform ('s/\@EXT\@/' . $ext . '/g;' + . 's/\@FPFX\@/' . $fullname . '/g;' + . 's/\@PFX\@/' . $subst . '/g;', + 'depend2'); + } +} + # Handle auto-dependency code. sub handle_dependencies { @@ -2520,27 +2548,13 @@ sub handle_dependencies $output_rules .= &file_contents ('depend'); push (@clean, 'depend'); &push_phony_cleaners ('depend'); + # FIXME: this should use another property of the language - # instead of being hard-coded. - $output_rules .= - &file_contents_with_transform ('s/\@EXT\@/.c/g;' - . 's/\@PFX\@//g;', - 'depend2'); - local ($ext); - foreach $ext (&lang_extensions ('objc')) - { - $output_rules .= - &file_contents_with_transform ('s/\@EXT\@/' . $ext . '/g;' - . 's/\@PFX\@/OBJC/g;', - 'depend2'); - } - foreach $ext (&lang_extensions ('cxx')) - { - $output_rules .= - &file_contents_with_transform ('s/\@EXT\@/' . $ext .'/g;' - . 's/\@PFX\@/CXX/g;', - 'depend2'); - } + # instead having which languages can do dependency + # tracking hard-coded. + &generate_dependency_code ('c', 'CC', ''); + &generate_dependency_code ('objc', 'OBJC', 'OBJC'); + &generate_dependency_code ('cxx', 'CXX', 'CXX'); } } } @@ -4034,11 +4048,14 @@ sub scan_one_configure_file # but later define it elsewhere. This is pretty hacky. We # also explicitly avoid INSTALL_SCRIPT and some other # variables because they are defined in header-vars.am. + # Also avoid `DEP_' as it is erroneously extracted from + # depend.m4. # FIXME. if (/$AC_SUBST_PATTERN/o && $1 ne 'ANSI2KNR' && $1 ne 'INSTALL_SCRIPT' - && $1 ne 'INSTALL_DATA') + && $1 ne 'INSTALL_DATA' + && $1 ne 'DEP_') { $configure_vars{$1} = $filename . ':' . $.; } @@ -4094,6 +4111,15 @@ sub scan_one_configure_file { $configure_vars{'FLIBS'} = $filename . ':' . $.; } + + # Look for dependency-tracking macros. + if (/AM_(CC|CXX|OBJC)_DEPENDENCIES/) + { + $dependency_macros{$1} = 1; + $configure_vars{'DEP_' . $1 . 'PRECOMP'} = $filename . ':' . $.; + $configure_vars{'DEP_' . $1 . 'POSTCOMP'} = $filename . ':' . $.; + $configure_vars{'DEP_' . $1 . 'FLAG'} = $filename . ':' . $.; + } } close (CONFIGURE); diff --git a/depend.am b/depend.am index 4c54a146f..232753cac 100644 --- a/depend.am +++ b/depend.am @@ -18,7 +18,7 @@ ## This fragment is probably only useful for maintainers. It relies ## on GNU make and gcc. It is only included in the generated -## Makefile.in if `automake' is not passed the `--include-deps' flag. +## Makefile.in if `automake' is not passed the `--ignore-deps' flag. include $(DEP_FILES) diff --git a/depend2.am b/depend2.am index 17140b9b1..9f60b042b 100644 --- a/depend2.am +++ b/depend2.am @@ -11,49 +11,20 @@ ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. +## Note that this must all be on one line to avoid a problem with +## automake's `.am' file reader. This is a convenience macro a user +## can use to run a compilation. You should set the shell variables +## `file' and `compile' first. +DEP_@FPFX@COMPILE = $(DEP_@FPFX@PRECOMP); echo " $$compile -c $$file"; $$compile $(DEP_@FPFX@FLAG) -c $$file; status=$$?; if test "$$status" -ne 0; then exit $$status; else $(DEP_@FPFX@POSTCOMP); fi + ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. @EXT@.o: - @echo '$(@PFX@COMPILE) -c $<'; \ -## There are various ways to get dependency output from gcc. Here's -## why we pick this rather obscure method: -## - Don't want to use -MD because we'd like the dependencies to end -## up in a subdir. Having to rename by hand is ugly. -## (We might end up doing this anyway to support other compilers.) -## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like -## -MM, not -M (despite what the docs say). -## - Using -M directly means running the compiler twice (even worse -## than renaming). - $(@PFX@COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< -## This next piece of magic avoids the `deleted header file' problem. -## The problem is that when a header file which appears in a .P file -## is deleted, the dependency causes make to die (because there is -## typically no way to rebuild the header). We avoid this by adding -## dummy dependencies for each header file. Too bad gcc doesn't do -## this for us directly. - @-cp .deps/$(*F).pp .deps/$(*F).P; \ - tr ' ' '\012' < .deps/$(*F).pp \ -## Some versions of gcc put a space before the `:'. On the theory -## that the space means something, we add a space to the output as -## well. - | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ - >> .deps/$(*F).P; \ - rm .deps/$(*F).pp + @file='$<'; compile='$(@PFX@COMPILE)'; \ + $(DEP_@FPFX@COMPILE) @EXT@.lo: - @echo '$(LT@PFX@COMPILE) -c $<'; \ -## See above to understand implementation weirdness. - $(LT@PFX@COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< -## Account for versions of gcc that put a space before the `:'. - @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ - < .deps/$(*F).pp > .deps/$(*F).P; \ -## See above to understand deleted header file trick. - tr ' ' '\012' < .deps/$(*F).pp \ -## Some versions of gcc put a space before the `:'. On the theory -## that the space means something, we add a space to the output as -## well. - | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ - >> .deps/$(*F).P; \ - rm -f .deps/$(*F).pp + @file='$<'; compile='$(LT@PFX@COMPILE)'; suffix='\1.o \1.lo'; \ + $(DEP_@FPFX@COMPILE) diff --git a/m4/Makefile.am b/m4/Makefile.am index 8e6cbcf1e..6986b47a1 100644 --- a/m4/Makefile.am +++ b/m4/Makefile.am @@ -4,9 +4,8 @@ AUTOMAKE_OPTIONS = gnits MAINT_CHARSET = latin1 m4datadir = $(datadir)/aclocal -m4data_DATA = ccstdc.m4 cond.m4 dmalloc.m4 error.m4 header.m4 init.m4 \ +dist_m4data_DATA = ccdepend.m4 ccstdc.m4 cond.m4 cxxdepend.m4 \ +depend.m4 depout.m4 depvars.m4 dmalloc.m4 error.m4 header.m4 init.m4 \ lex.m4 lispdir.m4 maintainer.m4 missing.m4 mktime.m4 multi.m4 \ -obstack.m4 protos.m4 ptrdiff.m4 regex.m4 sanity.m4 strtod.m4 \ -termios.m4 winsz.m4 - -EXTRA_DIST = $(m4data_DATA) +objcdepend.m4 obstack.m4 protos.m4 ptrdiff.m4 regex.m4 sanity.m4 \ +strtod.m4 termios.m4 winsz.m4 diff --git a/m4/Makefile.in b/m4/Makefile.in index ca3dd9320..fe6cf9061 100644 --- a/m4/Makefile.in +++ b/m4/Makefile.in @@ -69,15 +69,13 @@ AUTOMAKE_OPTIONS = gnits MAINT_CHARSET = latin1 m4datadir = $(datadir)/aclocal -m4data_DATA = ccstdc.m4 cond.m4 dmalloc.m4 error.m4 header.m4 init.m4 lex.m4 lispdir.m4 maintainer.m4 missing.m4 mktime.m4 multi.m4 obstack.m4 protos.m4 ptrdiff.m4 regex.m4 sanity.m4 strtod.m4 termios.m4 winsz.m4 +dist_m4data_DATA = ccdepend.m4 ccstdc.m4 cond.m4 cxxdepend.m4 depend.m4 depout.m4 depvars.m4 dmalloc.m4 error.m4 header.m4 init.m4 lex.m4 lispdir.m4 maintainer.m4 missing.m4 mktime.m4 multi.m4 objcdepend.m4 obstack.m4 protos.m4 ptrdiff.m4 regex.m4 sanity.m4 strtod.m4 termios.m4 winsz.m4 - -EXTRA_DIST = $(m4data_DATA) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_CLEAN_FILES = -DATA = $(m4data_DATA) +DATA = $(dist_m4data_DATA) -DIST_COMMON = $(m4data_DATA) Makefile.am Makefile.in +DIST_COMMON = $(dist_m4data_DATA) Makefile.am Makefile.in DISTFILES = $(DIST_COMMON) $(SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -93,19 +91,19 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status -install-m4dataDATA: $(m4data_DATA) +install-dist_m4dataDATA: $(dist_m4data_DATA) @$(NORMAL_INSTALL) $(mkinstalldirs) $(DESTDIR)$(m4datadir) - @list='$(m4data_DATA)'; for p in $$list; do \ + @list='$(dist_m4data_DATA)'; for p in $$list; do \ if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \ f="`echo $$p | sed -e 's|^.*/||'`"; \ echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(m4datadir)/$$f"; \ $(INSTALL_DATA) $$d$$p $(DESTDIR)$(m4datadir)/$$f; \ done -uninstall-m4dataDATA: +uninstall-dist_m4dataDATA: @$(NORMAL_UNINSTALL) - @list='$(m4data_DATA)'; for p in $$list; do \ + @list='$(dist_m4data_DATA)'; for p in $$list; do \ f="`echo $$p | sed -e 's|^.*/||'`"; \ echo " rm -f $(DESTDIR)$(m4datadir)/$$f"; \ rm -f $(DESTDIR)$(m4datadir)/$$f; \ @@ -119,11 +117,6 @@ distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) subdir = m4 distdir: $(DISTFILES) - here=`cd $(top_builddir) && pwd`; \ - top_distdir=`cd $(top_distdir) && pwd`; \ - distdir=`cd $(distdir) && pwd`; \ - cd $(top_srcdir) \ - && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnits m4/Makefile @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ @@ -145,20 +138,20 @@ installcheck: installcheck-am install-exec-am: install-exec: install-exec-am -install-data-am: install-m4dataDATA +install-data-am: install-dist_m4dataDATA install-data: install-data-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am install: install-am -uninstall-am: uninstall-m4dataDATA +uninstall-am: uninstall-dist_m4dataDATA uninstall: uninstall-am all-am: Makefile $(DATA) all-redirect: all-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install installdirs: - $(mkinstalldirs) $(DESTDIR)$(m4datadir) + $(mkinstalldirs) $(DESTDIR)$(dist_m4datadir) mostlyclean-generic: @@ -188,8 +181,8 @@ maintainer-clean-am: maintainer-clean-generic distclean-am maintainer-clean: maintainer-clean-am -.PHONY: uninstall-m4dataDATA install-m4dataDATA tags distdir info-am \ -info dvi-am dvi check check-am installcheck-am installcheck \ +.PHONY: uninstall-dist_m4dataDATA install-dist_m4dataDATA tags distdir \ +info-am info dvi-am dvi check check-am installcheck-am installcheck \ install-exec-am install-exec install-data-am install-data install-am \ install uninstall-am uninstall all-redirect all-am all install-strip \ installdirs mostlyclean-generic distclean-generic clean-generic \ diff --git a/m4/ccdepend.m4 b/m4/ccdepend.m4 new file mode 100644 index 000000000..9f65a0f4b --- /dev/null +++ b/m4/ccdepend.m4 @@ -0,0 +1,7 @@ +dnl Dependency tracking checks for C. +dnl AM_CC_DEPENDENCIES + +AC_DEFUN(AM_CC_DEPENDENCIES,[ +AC_REQUIRE([AC_PROG_CC]) +AC_REQUIRE([AC_PROG_CPP]) +AM_DEPENDENCIES([CC])]) diff --git a/m4/cxxdepend.m4 b/m4/cxxdepend.m4 new file mode 100644 index 000000000..be87d01a9 --- /dev/null +++ b/m4/cxxdepend.m4 @@ -0,0 +1,7 @@ +dnl Dependency tracking checks for C++. +dnl AM_CXX_DEPENDENCIES + +AC_DEFUN(AM_CXX_DEPENDENCIES,[ +AC_REQUIRE([AC_PROG_CXX]) +AC_REQUIRE([AC_PROG_CXXCPP]) +AM_DEPENDENCIES([CXX])]) diff --git a/m4/depend.m4 b/m4/depend.m4 new file mode 100644 index 000000000..789a2a85c --- /dev/null +++ b/m4/depend.m4 @@ -0,0 +1,130 @@ +dnl See how the compiler implements dependency checking. +dnl Usage: +dnl AM_DEPENDENCIES(NAME, PFX) +dnl NAME is either "CC" or "CXX". + +dnl Conceptually dependency tracking has 3 parts: +dnl (1) a pre-compilation step +dnl (2) the compilation step (which we can affect only using a flag) +dnl (3) a post-compilation step (which is almost always the same sed +dnl magic to work around the deleted header file problem) +dnl We try a few techniques and use that to set a single cache variable. +dnl Then we use the cache variable to set the actual variables we use. +dnl A fair amount of ugliness is required to share this code betewen +dnl C and C++. + + +AC_DEFUN(AM_DEPENDENCIES,[ +AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS]) +AC_REQUIRE([AM_DEP_SET_VARS]) +ifelse([$1],CC,[ +depcc="$CC" +depcpp="$CPP" +depgcc="$GCC" +depcompile=COMPILE],[ +depcc="$CXX" +depcpp="$CXXCPP" +depgcc="$GXX" +depcompile=CXXCOMPILE]) +AC_MSG_CHECKING([dependency style of $depcc]) +AC_CACHE_VAL(am_cv_[$1]_dependencies_compiler_type,[ +am_cv_[$1]_dependencies_compiler_type=none +if test "$depgcc" = yes; then + am_cv_[$1]_dependencies_compiler_type=gcc +else + echo '#include "confest.h"' > conftest.c + echo > conftest.h + + dnl SGI compiler has its own method for side-effect dependency + dnl tracking. + if test "$am_cv_[$1]_dependencies_compiler_type" = none; then + rm -f conftest.P + if $depcc -c -MDupdate conftest.P && test -f conftest.P; then + am_cv_[$1]_dependencies_compiler_type=sgi + fi + fi + + if test "$am_cv_[$1]_dependencies_compiler_type" = none; then + if test -n "`$depcc -M conftest.c`"; then + am_cv_[$1]_dependencies_compiler_type=dashmstdout + fi + fi + + dnl As a last resort, see if we can run CPP and extract line + dnl information from the output. + dnl FIXME + + rm -f conftest.* +fi +]) +AC_MSG_RESULT($am_cv_[$1]_dependencies_compiler_type) + +DEP_[$1]FLAG= +DEP_[$1]PRECOMP=: +DEP_[$1]POSTCOMP=: + +case "$am_cv_[$1]_dependencies_compiler_type" in + gcc) + depprecomp=none + DEP_[$1]FLAG="$depgccflag" + deppostcomp=sedmagic + ;; + + sgi) + depprecomp=none + DEP_[$1]FLAG='-MDupdate .deps/$$pp' + deppostcomp=sedmagic + ;; + + dashmstdout) + depprecomp=dashmstdout + deppostcomp=sedmagic + ;; + + cpp) + depprecomp=cpp + deppostcomp=none + ;; + + none) + depprecomp=none + deppostcomp=none + ;; +esac + +case "$depprecomp" in + none) + ;; + + dashmstdout) + DEP_[$1]PRECOMP="\$($depcompile) -M \$\$file > .deps/\$\$pp" + ;; + + cpp) + dnl We want a pre compilation step which runs CPP (but with all + dnl the right options! This is hard). Then we want to run sed + dnl on the output, extract `#line' or `# NNN' lines, and turn + dnl that into correct dependencies. We might as well do this + dnl all in one step, so we have no post-compilation step here. + FIXME + ;; +esac + +dnl We always prepend some boilerplate to the precompilation rule. +dnl This makes it very easy for the user to use this code -- he must +dnl only set the "file" variable. +DEP_[$1]PRECOMP="$depstdprecomp [$]DEP_[$1]PRECOMP" + +case "$deppostcomp" in + sedmagic) + DEP_[$1]POSTCOMP="$depsedmagic" + ;; + + none) + ;; +esac + +AC_SUBST(DEP_[$1]PRECOMP) +AC_SUBST(DEP_[$1]POSTCOMP) +AC_SUBST(DEP_[$1]FLAG) +]) diff --git a/m4/depout.m4 b/m4/depout.m4 new file mode 100644 index 000000000..4a753c960 --- /dev/null +++ b/m4/depout.m4 @@ -0,0 +1,34 @@ +dnl Generate code to set up dependency tracking. +dnl This macro should only be invoked once -- use via AC_REQUIRE. +dnl Usage: +dnl AM_OUTPUT_DEPENDENCY_COMMANDS + +dnl +dnl This code is only required when automatic dependency tracking +dnl is enabled. FIXME. This creates each `.P' file that we will +dnl need in order to bootstrap the dependency handling code. +AC_DEFUN(AM_OUTPUT_DEPENDENCY_COMMANDS,[ +AC_OUTPUT_COMMANDS([ +find . -name Makefile -print | while read mf; do + # Extract the definition of DEP_FILES from the Makefile withou + # running `make'. + deps="`sed -n -e ' + /^DEP_FILES = .*\\\\$/ { + s/^DEP_FILES = // + :loop + s/\\\\$// + p + n + /\\\\$/ b loop + p + } + /^DEP_FILES = / s/^DEP_FILES = //p' $mf`" + # If we found a definition, proceed to create all the files. + if test -n "$deps"; then + dirpart="`echo $mf | sed -e 's|/.*$||'`" + test -d "$dirpart/.deps" || mkdir "$dirpart/.deps" + for file in $deps; do + test -f "$dirpart/$file" || : > "$dirpart/$file" + done + fi +done])]) diff --git a/m4/depvars.m4 b/m4/depvars.m4 new file mode 100644 index 000000000..f2b864a71 --- /dev/null +++ b/m4/depvars.m4 @@ -0,0 +1,69 @@ +dnl Set some convenience variables used by dependency tracking. +dnl These variables have the same (complicated) values for every +dnl way gcc can be invoked. So we just define them once, here. +dnl You should only AC_REQUIRE this macro. + +dnl The variables defined at the end are: +dnl depsedmagic - sed magic to use as the post-compilation phase +dnl This one is not gcc-specific. +dnl depgccflag = flag to pass to gcc +dnl depstdprecomp - standard precompilation magic + +AC_DEFUN(AM_DEP_SET_VARS,[ +dnl This next piece of magic avoids the `deleted header file' problem. +dnl The problem is that when a header file which appears in a .P file +dnl is deleted, the dependency causes make to die (because there is +dnl typically no way to rebuild the header). We avoid this by adding +dnl dummy dependencies for each header file. Too bad gcc doesn't do +dnl this for us directly. +dnl Some versions of gcc put a space before the `:'. On the theory +dnl that the space means something, we add a space to the output as +dnl well. +dnl We remove # comments because that lets this same piece of magic +dnl work with SGI compilers. +dnl This is extremely ugly. We have to have it all on one line +dnl because AC_SUBST can't handle multi-line substitutions. We build +dnl the value up in pieces to make it a bit clearer. + +dnl Change the target if required, and remove hash comments. +changequote(<<,>>) +val="sed -e \"s/^\\([^:]*\\)\\.o[ ]*:/\$\$suffix :/\" -e 's/\\#.*\$\$//' < .deps/\$\$pp > .deps/\$\$p;" +changequote([,]) + +dnl Remove newlines and trailing backslashes, and generate a new +dnl dummy target for each header mentioned. +val="$val tr ' ' '\\012' < .deps/\$\$pp | sed -e 's/^\\\\\$\$//' -e '/^\$\$/ d' -e '/:\$\$/ d' -e 's/\$\$/ :/' >> .deps/\$\$p;" + +dnl Remove the temp file and exit with a good status. +depsedmagic="$val rm -f .deps/\$\$pp; :" + +dnl There are various ways to get dependency output from gcc. Here's +dnl why we pick this rather obscure method: +dnl - Don't want to use -MD because we'd like the dependencies to end +dnl up in a subdir. Having to rename by hand is ugly. +dnl (We might end up doing this anyway to support other compilers.) +dnl - The DEPENDENCIES_OUTPUT environment variable makes gcc act like +dnl -MM, not -M (despite what the docs say). +dnl - Using -M directly means running the compiler twice (even worse +dnl than renaming). +depgccflag='-Wp,-MD,.deps/$$pp' + +dnl We use this same precompilation boilerplate to make the user's job +dnl easy -- he only has to set the `file' variable in the shell +dnl before invoking the compilation rules. Again, we build it up in +dnl pieces for clarity. + +dnl Compute the default suffix. +val="test -z \"\$\$suffix\" && suffix='\\1.o';" + +dnl First compute P as root part of file (no directory or extension). +changequote(<<,>>) +val="$val p=\"\`echo \$\$file | sed -e 's|^.*/||' -e 's|\\.[^.]*\$\$||'\`\";" +changequote([,]) + +dnl Now use P to compute PP (name of a temp file), and then finally the +dnl real value of P (which is the resulting dependency file name). +val="$val pp=\"\$\$p.pp\"; p=\"\$\$p.P\";" + +depstdprecomp="$val" +]) diff --git a/m4/init.m4 b/m4/init.m4 index a3f4d74f0..45b621747 100644 --- a/m4/init.m4 +++ b/m4/init.m4 @@ -44,33 +44,4 @@ if test -n "$TAR"; then fi fi AC_SUBST(AMTARFLAGS) -AC_REQUIRE([AC_PROG_MAKE_SET]) -dnl -dnl This code is only required when automatic dependency tracking -dnl is enabled. FIXME. This creates each `.P' file that we will -dnl need in order to bootstrap the dependency handling code. -AC_OUTPUT_COMMANDS([ -find . -name Makefile -print | while read mf; do - # Extract the definition of DEP_FILES from the Makefile withou - # running `make'. - deps="`sed -n -e ' - /^DEP_FILES = .*\\\\$/ { - s/^DEP_FILES = // - :loop - s/\\\\$// - p - n - /\\\\$/ b loop - p - } - /^DEP_FILES = / s/^DEP_FILES = //p' $mf`" - # If we found a definition, proceed to create all the files. - if test -n "$deps"; then - dirpart="`echo $mf | sed -e 's|/.*$||'`" - test -d "$dirpart/.deps" || mkdir "$dirpart/.deps" - for file in $deps; do - test -f "$dirpart/$file" || : > "$dirpart/$file" - done - fi -done]) -]) +AC_REQUIRE([AC_PROG_MAKE_SET])]) diff --git a/m4/objcdepend.m4 b/m4/objcdepend.m4 new file mode 100644 index 000000000..e03ed84d5 --- /dev/null +++ b/m4/objcdepend.m4 @@ -0,0 +1,14 @@ +dnl Dependency tracking checks for Objective C. +dnl AM_OJBC_DEPENDENCIES + +dnl Since only gcc can handle Objective C, we skip the checks. + +AC_DEFUN(AM_OBJC_DEPENDENCIES,[ +AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS]) +AC_REQUIRE([AM_DEP_SET_VARS]) +DEP_OBJCFLAG="$depgccflag" +DEP_OBJCPRECOMP="$depstdprecomp" +DEP_OBJCPOSTCOMP="$depsedmagic" +AC_SUBST(DEP_OBJCFLAG) +AC_SUBST(DEP_OBJCPRECOMP) +AC_SUBST(DEP_OBJCPOSTCOMP)]) -- 2.47.2