Makefile.in 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. # Maintenance productions for the automated test directory
  2. # Copyright (C) 2010-2012 Free Software Foundation, Inc.
  3. # This file is part of GNU Emacs.
  4. # GNU Emacs is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. # GNU Emacs is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. # You should have received a copy of the GNU General Public License
  13. # along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  14. SHELL = /bin/sh
  15. srcdir = @srcdir@
  16. top_srcdir = @top_srcdir@
  17. abs_top_builddir = @abs_top_builddir@
  18. test = $(srcdir)
  19. VPATH = $(srcdir)
  20. lispsrc = $(top_srcdir)/lisp
  21. lisp = ${abs_top_builddir}/lisp
  22. # You can specify a different executable on the make command line,
  23. # e.g. "make EMACS=../src/emacs ...".
  24. # We sometimes change directory before running Emacs (typically when
  25. # building out-of-tree, we chdir to the source directory), so we need
  26. # to use an absolute file name.
  27. EMACS = ${abs_top_builddir}/src/emacs
  28. # Command line flags for Emacs.
  29. EMACSOPT = -batch --no-site-file --no-site-lisp
  30. # Extra flags to pass to the byte compiler
  31. BYTE_COMPILE_EXTRA_FLAGS =
  32. # For example to not display the undefined function warnings you can use this:
  33. # BYTE_COMPILE_EXTRA_FLAGS = --eval '(setq byte-compile-warnings (quote (not unresolved)))'
  34. # The example above is just for developers, it should not be used by default.
  35. # The actual Emacs command run in the targets below.
  36. emacs = EMACSLOADPATH=$(lispsrc):$(test) LC_ALL=C $(EMACS) $(EMACSOPT)
  37. # Common command to find subdirectories
  38. setwins=subdirs=`(find . -type d -print)`; \
  39. for file in $$subdirs; do \
  40. case $$file in */.* | */.*/* | */=* ) ;; \
  41. *) wins="$$wins $$file" ;; \
  42. esac; \
  43. done
  44. all: check
  45. doit:
  46. # Files MUST be compiled one by one. If we compile several files in a
  47. # row (i.e., in the same instance of Emacs) we can't make sure that
  48. # the compilation environment is clean. We also set the load-path of
  49. # the Emacs used for compilation to the current directory and its
  50. # subdirectories, to make sure require's and load's in the files being
  51. # compiled find the right files.
  52. .SUFFIXES: .elc .el
  53. # An old-fashioned suffix rule, which, according to the GNU Make manual,
  54. # cannot have prerequisites.
  55. .el.elc:
  56. @echo Compiling $<
  57. @$(emacs) $(BYTE_COMPILE_EXTRA_FLAGS) -f batch-byte-compile $<
  58. .PHONY: lisp-compile compile-main compile compile-always
  59. lisp-compile:
  60. cd $(lisp); $(MAKE) $(MFLAGS) compile EMACS=$(EMACS)
  61. # In `compile-main' we could directly do
  62. # ... | xargs $(MAKE) $(MFLAGS) EMACS="$(EMACS)"
  63. # and it works, but it generates a lot of messages like
  64. # make[2]: « gnus/gnus-mlspl.elc » is up to date.
  65. # so instead, we use "xargs echo" to split the list of file into manageable
  66. # chunks and then use an intermediate `compile-targets' target so the
  67. # actual targets (the .elc files) are not mentioned as targets on the
  68. # make command line.
  69. .PHONY: compile-targets
  70. # TARGETS is set dynamically in the recursive call from `compile-main'.
  71. compile-targets: $(TARGETS)
  72. # Compile all the Elisp files that need it. Beware: it approximates
  73. # `no-byte-compile', so watch out for false-positives!
  74. compile-main: compile-clean lisp-compile
  75. @(cd $(test); $(setwins); \
  76. els=`echo "$$wins " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 's| |/*.el |g'`; \
  77. for el in $$els; do \
  78. test -f $$el || continue; \
  79. test ! -f $${el}c && GREP_OPTIONS= grep '^;.*no-byte-compile: t' $$el > /dev/null && continue; \
  80. echo "$${el}c"; \
  81. done | xargs echo) | \
  82. while read chunk; do \
  83. $(MAKE) $(MFLAGS) compile-targets EMACS="$(EMACS)" TARGETS="$$chunk"; \
  84. done
  85. .PHONY: compile-clean
  86. # Erase left-over .elc files that do not have a corresponding .el file.
  87. compile-clean:
  88. @cd $(test); $(setwins); \
  89. elcs=`echo "$$wins " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 's| |/*.elc |g'`; \
  90. for el in $$(echo $$elcs | sed -e 's/\.elc/\.el/g'); do \
  91. if test -f "$$el" -o \! -f "$${el}c"; then :; else \
  92. echo rm "$${el}c"; \
  93. rm "$${el}c"; \
  94. fi \
  95. done
  96. # Compile all Lisp files, but don't recompile those that are up to
  97. # date. Some .el files don't get compiled because they set the
  98. # local variable no-byte-compile.
  99. # Calling make recursively because suffix rule cannot have prerequisites.
  100. # Explicitly pass EMACS (sometimes ../src/bootstrap-emacs) to those
  101. # sub-makes that run rules that use it, for the sake of some non-GNU makes.
  102. compile: $(LOADDEFS) autoloads compile-first
  103. $(MAKE) $(MFLAGS) compile-main EMACS=$(EMACS)
  104. # Compile all Lisp files. This is like `compile' but compiles files
  105. # unconditionally. Some files don't actually get compiled because they
  106. # set the local variable no-byte-compile.
  107. compile-always: doit
  108. cd $(test); rm -f *.elc */*.elc */*/*.elc */*/*/*.elc
  109. $(MAKE) $(MFLAGS) compile EMACS=$(EMACS)
  110. bootstrap-clean:
  111. cd $(test); rm -f *.elc */*.elc */*/*.elc */*/*/*.elc
  112. distclean:
  113. -rm -f ./Makefile
  114. maintainer-clean: distclean bootstrap-clean
  115. check: compile-main
  116. @(cd $(test); $(setwins); \
  117. pattern=`echo "$$wins " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 's| |/*.el |g'`; \
  118. for el in $$pattern; do \
  119. test -f $$el || continue; \
  120. args="$$args -l $$el"; \
  121. els="$$els $$el"; \
  122. done; \
  123. echo Testing $$els; \
  124. $(emacs) $$args -f ert-run-tests-batch-and-exit)
  125. # Makefile ends here.