;;; ==================================================================== ;;; @Emacs-Lisp-file{ ;;; author = "Nelson H. F. Beebe", ;;; version = "1.13", ;;; date = "29 June 2007", ;;; time = "17:42:42 MDT", ;;; filename = "make.el", ;;; address = "Center for Scientific Computing ;;; University of Utah ;;; Department of Mathematics, 110 LCB ;;; 155 S 1400 E RM 233 ;;; Salt Lake City, UT 84112-0090 ;;; USA", ;;; telephone = "+1 801 581 5254", ;;; FAX = "+1 801 581 4148", ;;; URL = "http://www.math.utah.edu/~beebe", ;;; checksum = "56203 820 2872 29902", ;;; email = "beebe@math.utah.edu, beebe@acm.org, ;;; beebe@computer.org (Internet)", ;;; codetable = "ISO/ASCII", ;;; keywords = "BibTeX, C, C++, file dependencies, Fortran, ;;; GNU Emacs, Java, LaTeX, make, Makefile, TeX", ;;; license = "public domain", ;;; supported = "yes", ;;; docstring = "This file supplies three convenient public ;;; Emacs functions for creating and maintaining ;;; UNIX Makefiles that adhere to GNU standards ;;; for targets and installation location ;;; variables: ;;; ;;; make-makefile ;;; remake-all-header-file-dependencies ;;; remake-SFTRAN3-header-file-dependencies ;;; remake-cpp-header-file-dependencies ;;; remake-fortran-header-file-dependencies ;;; remake-tex-header-file-dependencies ;;; ;;; The checksum field above contains a CRC-16 ;;; checksum as the first value, followed by the ;;; equivalent of the standard UNIX wc (word ;;; count) utility output of lines, words, and ;;; characters. This is produced by Robert ;;; Solovay's checksum utility.", ;;; } ;;; ==================================================================== (defconst make-version "1.13") ;NB: update this at every change (defconst make-date "[29-Jun-2007]") ;NB: update this at every change (provide 'make) (defconst make-code-version (concat make-version " " make-date) "Version number of the make.el library, a collection of functions for automatic generation of UNIX Makefile contents.") (defconst make-code-version "1.13 [29-Jun-2007]") ;;; (defconst make-code-version "1.12 [01-Nov-2003]") ;;; (defconst make-code-version "1.11 [20-Dec-2002]") ;;; (defconst make-code-version "1.10 [25-Mar-1999]") ;;; (defconst make-code-version "1.09 [26-Feb-1999]") ;;; (defconst make-code-version "1.08 [11-Dec-1998]") ;;; (defconst make-code-version "1.07 [03-Dec-1998]") ;;; (defconst make-code-version "1.06 [23-Jul-1998]") ;;; (defconst make-code-version "1.05 [14-Jul-1998]") ;;; (defconst make-code-version "1.04 [04-Jul-1998]") ;;; (defconst make-code-version "1.03 [23-Jun-1998]") ;;; (defconst make-code-version "1.02 [27-Mar-1998]") ;;; (defconst make-code-version "1.01 [17-Mar-1998]") ;;; (defconst make-code-version "1.00 [13-Mar-1998]") (defvar make-suffixes "" "Makefile .SUFFIXES list") (require 'clsc) ;updated clsc [1.52] Tue Apr 21 09:22:55 1998 ;to do (provide 'clsc) ;;; (if (not (fboundp 'date)) ;should use (require 'clsc), but that library ;;; (load-library "clsc")) ;does not yet do (provide 'clsc) ;;; ==================================================================== ;;; Public functions: (defun make-makefile () "Create a Makefile template in the current buffer, which must be initially empty, for files in the current directory. On completion, some limited editing, followed by saving the buffer under the name Makefile or makefile, will be required. All of the GNU standard Makefile targets and macros are provided. The programming languages recognized are: C C++ Emacs Fortran Fortran-90 Java LaTeX SFTRAN3 TeX TeXinfo Header file dependencies are automatically created for files in: C C++ Fortran Fortran-90 LaTeX SFTRAN3 TeX TeXinfo Each file include/input statement must appear on a line by itself, with optional trailing comments, in order to be properly recognized. Use the function remake-all-header-file-dependencies, or the language-specific functions remake-fortran-header-file-dependencies, remake-cpp-header-file-dependencies, remake-SFTRAN3-header-file-dependencies, and/or remake-tex-header-file-dependencies, to update object file dependency lists if header file includes are modified in any of the source files. The assumed file extensions are: ====================================================== Language Source Header Object ====================================================== C .c .h .o C++ .C .h .o C++ .cc .h .o C++ .cxx .h .o C++ .cpp .h .o Emacs .el -n/a- .elc Fortran .f .inc .o Fortran 90 .F90 -any- .o Fortran 90 .f90 .inc .o Java .java -any- .class LaTeX .ltx -any- .dvi SFTRAN3 .sf3 .inc .o TeX .tex -any- .dvi TeXinfo .texi -any- .dvi TeXinfo .texinfo -any- .dvi ====================================================== Fortran files with extensions .F and .F90 are assumed to contain C-style #include statements, rather than Fortran INCLUDE statements. Java files also have an associated .html documentation file created by javadoc." (interactive) (if (not (= (point-min) (point-max))) (error "Non-empty buffer for make-makefile")) (let ((separator-comment "#=======================================================================") (subdirs nil)) ;; (message "Making subdirectory lists...") (save-restriction (narrow-to-region (point) (point)) (shell-command "echo `find * -type d -print -prune | egrep -v 'cxx_repository|CVS|RCS|SCCS' | sort`" t) (if (> (point-max) (1+ (point-min))) (progn (setq subdirs (buffer-substring (point-min) (1- (point-max)))) (kill-region (point-min) (point-max))))) ;; (message "Making macro definitions...") (insert separator-comment "\n") (insert "# Makefile for files in " (expand-file-name default-directory) "\n") (insert "#\n") (insert "# " ) (date) (insert "\n") (insert separator-comment "\n# Program definitions\n\n") (insert "PROGRAM\t\t= CHANGE-THIS-VALUE\n" "PROGLIB\t\t= CHANGE-THIS-VALUE\n" "VERSION\t\t= 1.0\n\n") (insert separator-comment "\n# Installation locations\n\n") (insert "prefix\t\t= /usr/local\n" "bindir\t\t= $(prefix)/bin\n" "catdir\t\t= $(prefix)/man/cat$(manext)\n" "libdir\t\t= $(libtop)/$(PROGRAM)-$(VERSION)\n" "libtop\t\t= $(prefix)/$(PROGLIB)/\n" "mandir\t\t= $(prefix)/man/man$(manext)\n" "manext\t\t= 1\n" "shrlibdir\t= $(shrlibtop)/$(PROGRAM)-$(VERSION)\n" "shrlibtop\t= $(prefix)/share/$(PROGLIB)/\n\n") (insert separator-comment "\n# Macro definitions\n\n") (if (directory-files "." nil "[.]ltx$" t) (insert "BIBTEX\t\t= bibtex\n\n" "BIBTEXFLAGS\t=\n\n")) (insert "CAT\t\t= cat\n\n") (insert "CHKDELIM\t= chkdelim\n\n") (insert "CHKDELIMFLAGS\t= -tex -i LG\\'\n\n") (insert "CHMOD\t\t= chmod\n\n") (insert "CP\t\t= /bin/cp -p\n" "CP\t\t= rcp -p\n\n") (insert "DETEX\t\t= detex\n\n" "DETEXFLAGS\t= -m -n -s\n\n") (if (directory-files "." nil "[.]\\(ltx\\|tex\\|texi\\|texinfo\\)$" t) (insert "DVIPS\t\t= dvips-type1\n\n" "DVIPSFLAGS\t= -j0\n\n")) (insert "DW\t\t= dw\n\n") (if (directory-files "." nil "[.]el$" t) (insert "EMACS\t\t= emacs\n\n")) (insert "ISPELL\t\t= ispell\n\n") (if (directory-files "." nil "[.]java$" t) (insert "JAVA\t\t= java\n\n" "JAVAC\t\t= javac\n\n" "JAVADOC\t\t= javadoc\n\n" "JAVALD\t\t= javald\n\n")) (if (directory-files "." nil "[.]ltx$" t) (insert "LATEX\t\t= latex\n" "LATEX\t\t= latex2e\n\n" "LATEXFLAGS\t=\n\n")) (insert "LIBFILES\t= /dev/null\n\n") (if (directory-files "." nil "[.]ltx$" t) (insert "MAKEINDEX\t= makeindex\n\n" "MAKEINDEXFLAGS\t=\n\n")) (if (directory-files "." nil "[.]texi$" t) (insert "MAKEINFO\t= makeinfo\n\n" "MAKEINFOFLAGS\t=\n\n")) (if (directory-files "." nil "[.]texinfo$" t) (insert "MAKEINFO\t= makeinfo\n\n" "MAKEINFOFLAGS\t=\n\n")) (insert "LN\t\t= ln\n\n") (insert "LS\t\t= ls\n\n") (insert "MKDIR\t\t= mkdir -p\n\n") (insert "MV\t\t= /bin/mv\n\n") (if (directory-files "." nil "[.]\\(ltx\\|tex\\|texi\\|texinfo\\)$" t) (insert "PSTOPDF\t\t= ps2pdf\n" "PSTOPDF\t\t= distill\n\n" "PSTOPDFFLAGS\t=\n\n")) (insert "RM\t\t= /bin/rm -f\n\n") (insert "SED\t\t= sed\n\n") (if (directory-files "." nil "[.]sf3$" t) (insert "SF3\t\t= xsf3\n\n")) (insert "SHELL\t\t= /bin/sh\n\n") (insert "SHRLIBFILES\t= /dev/null\n\n") (insert "SORT\t\t= sort\n\n") (insert "SPELL\t\t= spell\n\n") (insert "SPELLFILTER\t= $(CAT)\n" "SPELLFILTER\t= $(SED) -e 's/[0-9,.:;?&]/ /g'\n\n") (if (directory-files "." nil "[.]tex$" t) (insert "TEX\t\t= tex\n\n")) (if (directory-files "." nil "[.]texi$" t) (insert "TEXINDEX\t= texindex\n\n" "TEXINDEXFLAGS\t=\n\n" "TEXINFO\t\t= texinfo\n\n" "TEXINFOFLAGS\t=\n\n")) (if (directory-files "." nil "[.]texinfo$" t) (insert "TEXINDEX\t\t= texindex\n\n" "TEXINDEXFLAGS\t=\n\n" "TEXINFO\t= texinfo\n\n" "TEXINFOFLAGS\t=\n\n")) (if subdirs (insert separator-comment "\n# Subdirectories\n\n" "SUBDIRS\t\t= " subdirs "\n" "SUBDIRLOOP\t= for subdir in $(SUBDIRS) ; \\\n" "\t\tdo \\\n" "\t\t\techo ============================== Making $@ in $$subdir ; \\\n" "\t\t\t( cd $$subdir && $(MAKE) $(MFLAGS) $@ ) ; \\\n" "\t\tdone\n\n")) (let ((list) (wrap-column 72) (make-suffixes nil)) (insert separator-comment "\n# Compiler flags and source files\n\n") (if (setq list (directory-files "." nil "[.]c$" nil)) (insert "CDEFINES\t=\n" "CINCLUDES\t=\n" "CFLAGS\t\t= $(COPT) $(CDEFINES) $(CINCLUDES)\n" "COPT\t\t= -g\n" "COBJS\t\t= $(CSRCS:.c=.o)\n" "CSRCS\t\t= " (make-file-list-string list wrap-column) "\n\n")) (if (setq list (directory-files "." nil "[.]C$\\|[.]cc$\\|[.]cpp$\\|[.]cxx$" nil)) (insert "CXXDEFINES\t\t=\n" "CXXINCLUDES\t\t=\n" "CXXFLAGS\t\t= $(CXXOPT) $(CXXDEFINES) $(CXXINCLUDES)\n" "CXXOPT\t\t= -g\n" "CXXOBJS\t\t= $(CXXSRCS:.cc=.o)\n" "CXXSRCS\t\t= " (make-file-list-string list wrap-column) "\n\n")) (if (setq list (directory-files "." nil "[.]el$" nil)) (progn (setq make-suffixes (concat make-suffixes (if (> (length make-suffixes) 0) " " "") ".elc .el")) (insert "ELFLAGS\t\t= $(ELOPT)\n" "ELOPT\t\t=\n" "ELOBJS\t\t= $(ELSRCS:.el=.elc)\n" "ELSRCS\t\t= " (make-file-list-string list wrap-column) "\n\n"))) (if (setq list (directory-files "." nil "[.]f$" nil)) (insert "FFLAGS\t\t= $(FOPT)\n" "FOPT\t\t= -g\n" "FOBJS\t\t= $(FSRCS:.f=.o)\n" "FSRCS\t\t= " (make-file-list-string list wrap-column) "\n\n")) (if (setq list (directory-files "." nil "[.]f90$" nil)) (insert "F90FLAGS\t\t= $(F90OPT)\n" "F90OPT\t\t= -g\n" "F90OBJS\t\t= $(F90SRCS:.f=.o)\n" "F90SRCS\t\t= " (make-file-list-string list wrap-column) "\n\n")) (if (setq list (directory-files "." nil "[.]h$" nil)) (insert "HSRCS\t\t= " (make-file-list-string list wrap-column) "\n\n")) (if (setq list (directory-files "." nil "[.]inc$" nil)) (insert "INCSRCS\t\t= " (make-file-list-string list wrap-column) "\n\n")) (if (setq list (directory-files "." nil "[.]java$" nil)) (progn (setq make-suffixes (concat make-suffixes (if (> (length make-suffixes) 0) " " "") ".class .html .java")) (insert "JAVACFLAGS\t=\n" "JAVADOCFLAGS\t=\n" "JAVADOCS\t= $(JAVASRCS:.java=.html)\n" "JAVAEXES\t= $(JAVASRCS:.java=)\n" "JAVAFLAGS\t=\n" "JAVALDFLAGS\t=\n" "JAVAOBJS\t= $(JAVASRCS:.java=.class)\n" "JAVASRCS\t= " (make-file-list-string list wrap-column) "\n" "JAVATOPDOCS\t= AllNames.html packages.html tree.html\n\n"))) (if (setq list (directory-files "." nil "[.]ltx$" nil)) (progn (setq make-suffixes (concat make-suffixes (if (> (length make-suffixes) 0) " " "") ".pdf .ps .ckd .dvi .aux .dw .ser .ltx")) (insert "LATEXFLAGS\t= $(LATEXOPT)\n" "LATEXOPT\t=\n" "LATEXOBJS\t= $(LATEXSRCS:.ltx=.dvi)\n" "LATEXSRCS\t= " (make-file-list-string list wrap-column) "\n\n"))) (if (setq list (directory-files "." nil "[.]sf3$" nil)) (progn (setq make-suffixes (concat make-suffixes (if (> (length make-suffixes) 0) " " "") ".o .f .sf3")) (insert "SF3FLAGS\t= $(SF3OPT)\n" "SF3OPT\t\t= -g\n" "SF3OBJS\t\t= $(SF3SRCS:.sf3=.o)\n" "SF3SRCS\t\t= " (make-file-list-string list wrap-column) "\n\n"))) (if (setq list (directory-files "." nil "[.]tex$" nil)) (progn (setq make-suffixes (concat make-suffixes (if (> (length make-suffixes) 0) " " "") ".pdf .ps .ckd .dvi .dw .ser .tex")) (insert "TEXFLAGS\t= $(TEXOPT)\n" "TEXOPT\t\t=\n" "TEXOBJS\t\t= $(TEXSRCS:.tex=.dvi)\n" "TEXSRCS\t\t= " (make-file-list-string list wrap-column) "\n\n"))) (if (directory-files "." nil "[.]texi$" t) (setq make-suffixes (concat make-suffixes (if (> (length make-suffixes) 0) " " "") ".info .texi"))) (if (directory-files "." nil "[.]texinfo$" t) (setq make-suffixes (concat make-suffixes (if (> (length make-suffixes) 0) " " "") ".info .texinfo"))) (if (setq list (directory-files "." nil "[.]texi$" nil)) (progn (setq make-suffixes (concat make-suffixes (if (> (length make-suffixes) 0) " " "") ".pdf .ps .ckd .dvi .dw .ser .texi")) (insert "TEXINFOFLAGS\t= $(TEXINFOOPT)\n" "TEXINFOOPT\t=\n" "TEXINFOOBJS\t= $(TEXINFOSRCS:.texi=.dvi)\n" "TEXINFOSRCS\t= " (make-file-list-string list wrap-column) "\n\n"))) (if (setq list (directory-files "." nil "[.]texinfo$" nil)) (progn (setq make-suffixes (concat make-suffixes (if (> (length make-suffixes) 0) " " "") ".pdf .ps .ckd .dvi .dw .ser .texinfo")) (insert "TEXINFOFLAGS\t= $(TEXINFOOPT)\n" "TEXINFOOPT\t=\n" "TEXINFOOBJS\t= $(TEXINFOSRCS:.texinfo=.dvi)\n" "TEXINFOSRCS\t= " (make-file-list-string list wrap-column) "\n\n"))) (insert separator-comment "\n# Suffixes and extra rule(s)\n\n") (if make-suffixes (insert ".SUFFIXES:\t" make-suffixes "\n\n")) ) ;end (let ...) ;; (message "Making rules...") (make-makefile-rule "." "[.]\\(ltx\\|tex\\|texi\\|texinfo\\)$" ".ltx.ckd .tex.ckd .texi.ckd .texinfo.ckd" '("$(CHKDELIM) $(CHKDELIMFLAGS) $< >$@")) (make-makefile-rule "." "[.]\\(ltx\\|tex\\|texi\\|texinfo\\)$" ".ltx.dw .tex.dw .texi.dw .texinfo.dw" '("$(DETEX) $(DETEXFLAGS) $< | $(DW) >$@")) (make-makefile-rule "." "[.]\\(ltx\\|tex\\|texi\\|texinfo\\)$" ".dvi.ps" '("$(DVIPS) -o$@ $(DVIPSFLAGS) $<")) (make-makefile-rule "." "[.]\\(ltx\\|tex\\|texi\\|texinfo\\)$" ".dvi.pdf" '("$(DVIPS) -o$*.ps $(DVIPSFLAGS) $<" "$(PSTOPDF) $(PSTOPDFFLAGS) $*.ps")) (make-makefile-rule "." "[.]el$" ".el.elc" '("$(EMACS) --no-site-file --batch $(ELFLAGS) --eval '(byte-compile-file \"$<\")'")) (make-makefile-rule "." "[.]java$" ".java.class" '("$(JAVAC) $(JAVACFLAGS) $<")) (make-makefile-rule "." "[.]java$" ".java.html" '("$(JAVADOC) $(JAVADOCFLAGS) $<")) (make-makefile-rule "." "[.]java$" ".java" '("$(JAVALD) $(JAVALDFLAGS) $*")) (make-makefile-rule "." "[.]ltx$" ".ltx.dvi" '("-$(LATEX) $(LATEXFLAGS) $<" "-$(BIBTEX) $(BIBTEXFLAGS) $*" "-$(LATEX) $(LATEXFLAGS) $<" "-$(MAKEINDEX) $(MAKEINDEXFLAGS) $<" "$(LATEX) $(LATEXFLAGS) $<" "$(MAKEINDEX) $(MAKEINDEXFLAGS) $<")) (make-makefile-rule "." "[.]\\(ltx\\|tex\\|texi\\|texinfo\\)$" ".ltx.ser .tex.ser .texi.ser .texinfo.ser" '("if test -f $*.sok ; then true ; else touch $*.sok ; fi" "$(DETEX) $(DETEXFLAGS) $< | $(SPELLFILTER) | $(SPELL) +$*.sok >$@" "$(DETEX) $(DETEXFLAGS) $< | $(SPELLFILTER) | $(ISPELL) -l -p $*.sok >>$@" "$(MV) $@ $@.tmp" "$(SORT) -u $@.tmp >$@" "-$(RM) $@.tmp")) (make-makefile-rule "." "[.]\\(ltx\\|tex\\|texi\\|texinfo\\)$" ".ps.pdf" '("$(PSTOPDF) $(PSTOPDFFLAGS) $<")) (make-makefile-rule "." "[.]texi$" ".texi.dvi" '("$(TEXINFO) $(TEXINFOFLAGS) $<")) (make-makefile-rule "." "[.]texinfo$" ".texinfo.dvi" '("$(TEXINFO) $(TEXINFOFLAGS) $<")) (make-makefile-rule "." "[.]texi$" ".texi.info" '("$(MAKEINFO) $(MAKEINFOFLAGS) $<")) (make-makefile-rule "." "[.]texinfo$" ".texinfo.info" '("$(MAKEINFO) $(MAKEINFOFLAGS) $<")) (make-makefile-rule "." "[.]sf3$" ".sf3.o" '("$(SF3) $(SF3FLAGS) -c $<")) (make-makefile-rule "." "[.]sf3$" ".sf3.f" '("$(SF3) $(SF3FLAGS) -E -K $<")) (make-makefile-rule "." "[.]tex$" ".tex.dvi" '("$(TEX) $(TEXFLAGS) $<")) (insert separator-comment "\n# Targets:\n\n") ;; (message "Making targets...") (insert "all:\n" "\t@echo CHANGE THIS TARGET TO RUN THE DEFAULT ACTION\n\n") (insert "check:\n" "\t@echo 'There is no validation suite for this program (yet)'\n\n") (if (or (directory-files "." nil "[.]ltx$" nil) (directory-files "." nil "[.]tex$" nil) (directory-files "." nil "[.]texi$" nil) (directory-files "." nil "[.]texinfo$" nil)) (insert "chkdelim:\t$(LATEXSRCS:.ltx=.ckd) $(TEXSRCS:.tex=.ckd)\n\n")) (insert "clean:\n" (if (directory-files "." nil "[.]java$" nil) "\t-$(RM) $(JAVAOBJS)\n" "") "\t-$(RM) *.dw\n" "\t-$(RM) *.i\n" "\t-$(RM) *.o\n" "\t-$(RM) *.ser\n" "\t-$(RM) *~\n" "\t-$(RM) \\#*\n" "\t-$(RM) a.out\n" "\t-$(RM) core core.*\n" (if subdirs "\t-$(SUBDIRLOOP)\n\n" "\n")) (insert "clobber:\tdistclean\n" (if subdirs "\t-$(SUBDIRLOOP)\n\n" "\n")) (insert "distclean:\tmostlyclean\n" "\t-$(RM) $(PROGRAM)\n" (if (directory-files "." nil "[.]java$" nil) (concat "\t-$(RM) $(JAVADOCS) $(JAVATOPDOCS)\n" "\t-$(RM) $(JAVAEXES)\n") "") (if (directory-files "." nil "[.]ltx$" nil) "\t-$(RM) *.aux *.bbl *.ind *.idx\n" "") (if subdirs "\t-$(SUBDIRLOOP)\n\n" "\n")) (if (directory-files "." nil "[.]java$" nil) (insert "docs:\t$(JAVATOPDOCS)\n\n")) (if (or (directory-files "." nil "[.]ltx$" nil) (directory-files "." nil "[.]tex$" nil) (directory-files "." nil "[.]texi$" nil) (directory-files "." nil "[.]texinfo$" nil)) (insert "dw:\t$(LATEXSRCS:.ltx=.dw) $(TEXSRCS:.tex=.dw)\n\n")) (insert "install:\tinstall-exe install-lib install-shrlib install-man install-show\n" (if subdirs "\t$(SUBDIRLOOP)\n\n" "\n")) (insert "install-exe:\tuninstall-exe\n" "\t$(CP) $(PROGRAM) $(bindir)/$(PROGRAM)\n" "\t$(LN) $(bindir)/$(PROGRAM) $(bindir)/$(PROGRAM)-$(VERSION)\n" "\t$(CHMOD) 775 $(bindir)/$(PROGRAM) $(bindir)/$(PROGRAM)-$(VERSION)\n\n") (insert "install-lib:\tuninstall-lib\n" "##\t$(MKDIR) $(libtop)\n" "##\t@if test -d $(libtop) ; then true ; else echo Cannot create $(libtop) ; exit 1 ; fi\n" "##\t$(MKDIR) $(libdir)\n" "##\t@if test -d $(libdir) ; then true ; else echo Cannot create $(libdir) ; exit 1 ; fi\n" "##\t$(CP) $(LIBFILES) $(libdir)/\n" "##\t$(CHMOD) 664 $(libdir)/*\n\n") (insert "install-man:\tuninstall-man\n" "\t$(CP) $(PROGRAM).man $(mandir)/$(PROGRAM).$(manext)\n" "\t$(CHMOD) 664 $(mandir)/$(PROGRAM).$(manext)\n\n") (insert "install-show:\n" "\t@echo ''\n" "\t@echo Installed files...\n" "\t@$(LS) -l $(bindir)/$(PROGRAM) $(bindir)/$(PROGRAM)-$(VERSION) \\\n" "\t\t$(mandir)/$(PROGRAM).$(manext)\n" "\t@if test -d $(libdir) ; then $(LS) -lR $(libdir) ; fi\n" "\t@if test -d $(shrlibdir) ; then $(LS) -lR $(shrlibdir) ; fi\n" "\t@echo ''\n\n") (insert "install-shrlib:\tuninstall-shrlib\n" "##\t$(MKDIR) $(shrlibtop)\n" "##\t@if test -d $(shrlibtop) ; then true ; else echo Cannot create $(shrlibtop) ; exit 1 ; fi\n" "##\t$(MKDIR) $(shrlibdir)\n" "##\t@if test -d $(shrlibdir) ; then true ; else echo Cannot create $(shrlibdir) ; exit 1 ; fi\n" "##\t$(CP) $(SHRLIBFILES) $(shrlibdir)/\n" "##\t$(CHMOD) 664 $(shrlibdir)/*\n\n") (if (directory-files "." nil "[.]java$" nil) (insert "$(JAVATOPDOCS): $(JAVASRCS)\n" "\t$(JAVADOC) $(JAVADOCFLAGS) $(JAVASRCS)\n\n")) (insert "maintainer-clean:\tdistclean\n" "\t@echo \"This command is intended for maintainers to use;\"\n" "\t@echo \"it deletes files that may require special tools to rebuild.\"\n" (if subdirs "\t-$(SUBDIRLOOP)\n\n" "\n")) (insert "mostlyclean:\tclean\n" (if (directory-files "." nil "[.]el$" nil) "\t-$(RM) *.elc\n" "") (if (directory-files "." nil "[.]ltx$" nil) "\t-$(RM) *.blg *.dvi *.ilg *.log\n" "") (if subdirs "\t-$(SUBDIRLOOP)\n\n" "\n")) (if (directory-files "." nil "[.]java$" nil) (insert "programs:\t$(JAVAOBJS) $(JAVAEXES)\n\n")) (if (or (directory-files "." nil "[.]ltx$" nil) (directory-files "." nil "[.]tex$" nil) (directory-files "." nil "[.]texi$" nil) (directory-files "." nil "[.]texinfo$" nil)) (insert "spell:\t$(LATEXSRCS:.ltx=.ser) $(TEXSRCS:.tex=.ser)\n\n")) (insert "uninstall:\tuninstall-exe uninstall-lib uninstall-shrlib uninstall-man\n" (if subdirs "\t-$(SUBDIRLOOP)\n\n" "\n")) (insert "uninstall-exe:\n" "\t-$(RM) $(bindir)/$(PROGRAM)\n" "\t-$(RM) $(bindir)/$(PROGRAM)-$(VERSION)\n\n") (insert "uninstall-lib:\n" "##\t-$(RM) -r $(libdir)\n\n") (insert "uninstall-man:\n" "\t-$(RM) $(mandir)/$(PROGRAM).$(manext)\n" "\t-$(RM) $(catdir)/$(PROGRAM).$(manext)\n\n") (insert "uninstall-shrlib:\n" "##\t-$(RM) -r $(shrlibdir)\n\n") (insert separator-comment "\n# File dependencies\n") ;; (message "Making file dependencies...") (remake-all-header-file-dependencies) (goto-char (point-max)) (delete-blank-lines) (insert "\n" separator-comment "\n") (goto-char (point-min))) (if (fboundp 'makefile-mode) (makefile-mode))) (defun remake-all-header-file-dependencies () "Remake all file header dependency sections." (interactive) (remake-cpp-header-file-dependencies) (remake-fortran-header-file-dependencies) (remake-SFTRAN3-header-file-dependencies) (remake-tex-header-file-dependencies)) (defun remake-cpp-header-file-dependencies () "Delete any existing C/C++/F77/F90 header file dependency section, and recreate it. Correct deletion of the old section relies on finding the header comment previously inserted by make-cpp-header-file-dependencies." (interactive) (goto-char (point-min)) (if (search-forward "\n# C/C++ header file dependencies" nil t) (progn (beginning-of-line) (let ((start (point))) (or (search-forward "\n#" nil t) (goto-char (point-max))) (beginning-of-line) (kill-region start (point)))) (goto-char (point-max))) (make-cpp-header-file-dependencies "." "[.]c$\\|[.]C$\\|[.]cc$\\|[.]cpp$\\|[.]cxx$\\|[.]F$\\|[.]F90$") (goto-char (point-max))) (defun remake-fortran-header-file-dependencies () "Delete any existing Fortran header file dependency section, and recreate it. Correct deletion of the old section relies on finding the header comment previously inserted by make-fortran-header-file-dependencies." (interactive) (goto-char (point-min)) (if (search-forward "\n# Fortran/SFTRAN3 header file dependencies" nil t) (progn (beginning-of-line) (let ((start (point))) (or (search-forward "\n#" nil t) (goto-char (point-max))) (beginning-of-line) (kill-region start (point)))) (goto-char (point-max))) (make-fortran-header-file-dependencies "." "[.]f$\\|[.]f90$\\|[.]sf3$") (goto-char (point-max))) (defun remake-SFTRAN3-header-file-dependencies () "Delete any existing SFTRAN3 header file dependency section, and recreate it. Correct deletion of the old section relies on finding the header comment previously inserted by make-fortran-header-file-dependencies." (interactive) (goto-char (point-min)) (if (search-forward "\n# SFTRAN3 header file dependencies" nil t) (progn (beginning-of-line) (let ((start (point))) (or (search-forward "\n#" nil t) (goto-char (point-max))) (beginning-of-line) (kill-region start (point)))) (goto-char (point-max))) (make-SFTRAN3-header-file-dependencies "." "[.]sf3$") (goto-char (point-max))) (defun remake-tex-header-file-dependencies () "Delete any existing LaTeX/TeXinfo/TeX header file dependency section, and recreate it. Correct deletion of the old section relies on finding the header comment previously inserted by make-tex-header-file-dependencies." (interactive) (goto-char (point-min)) (if (search-forward "\n# LaTeX/TeXinfo/TeX header file dependencies" nil t) (progn (beginning-of-line) (let ((start (point))) (or (search-forward "\n#" nil t) (goto-char (point-max))) (beginning-of-line) (kill-region start (point)))) (goto-char (point-max))) (make-tex-header-file-dependencies "." "[.]ltx$\\|[.]tex$\\|[.]texi$\\|[.]texinfo$") (goto-char (point-max))) ;;; ==================================================================== ;;; Private internal functions: (defun make-cpp-header-file-dependencies (directory match-regexp) "Make C and C++ header file dependency lists for files in DIRECTORY that match MATCH-REGEXP, and insert them in the buffer at the current point." (let* ((file-list (directory-files directory nil match-regexp nil)) (file-list-string (make-file-list-string file-list))) (save-restriction (narrow-to-region (point) (point)) (insert "# C/C++ header file dependencies\n\n") (shell-command (concat "egrep " "'^[ \t]*[#][ \t]*include[ \t]+\"' " file-list-string " | awk '{sub(/[ \\t]*#include/,\"\",$1); " "sub(/[.][a-z0-9]+:$/,\".o:\",$1); " "printf(\"%-15s\\t%s\\n\"," "$1, substr($2,2,length($2)-2))}'" " | sort ; echo ''") t) ;; If we found no dependencies, remove the insertion (goto-char (point-min)) (if (not (search-forward ".o:" nil t)) (kill-region (point-min) (point-max))) (goto-char (point-max))))) (defun make-file-list-string (file-list &optional wrap-column) "Convert FILE-LIST, a list of filenames, to a blank-separated string of filenames and return that string. If WRAP-COLUMN is non-nil, the string will be wrapped with a backslash-newline-tab-tab-space-space at that column." (let ((s "") (line-length 0)) (while (car file-list) (setq s (concat s (if (> (length s) 0) (if (and wrap-column (< wrap-column (+ 16 2 line-length (length (car file-list))))) (progn (setq line-length 0) " \\\n\t\t ") (setq line-length (1+ line-length)) " ") "") (car file-list))) (setq line-length (+ line-length (length (car file-list)))) (setq file-list (cdr file-list))) s)) (defun make-fortran-header-file-dependencies (directory match-regexp) "Make Fortran and SFTRAN3 header file dependency lists for files in DIRECTORY that match MATCH-REGEXP, and insert them in the buffer at the current point." (let* ((file-list (directory-files directory nil match-regexp nil)) (file-list-string (make-file-list-string file-list))) (save-restriction (narrow-to-region (point) (point)) (insert "# Fortran/SFTRAN3 header file dependencies\n\n") (shell-command (concat "egrep " "\"^[ \t]+[Ii][Nn][Cc][Ll][Uu][Dd][Ee][ \t]+'\" " file-list-string " | awk '{sub(/[.][a-z0-9]+:$/,\".o:\",$1); " " printf(\"%-15s\\t%s\\n\"," "$1, substr($3,2,length($3)-2))}'" " | sort ; echo ''") t) ;; If we found no dependencies, remove the insertion (goto-char (point-min)) (if (not (search-forward ".o:" nil t)) (kill-region (point-min) (point-max))) (goto-char (point-max))))) (defun make-makefile-rule (directory match-regexp target command-list) "Make a Makefile rule for files in DIRECTORY that match MATCH-REGEXP with suffix-pair TARGET, and one or more commands from COMMAND-LIST." (let ((file-list (directory-files directory nil match-regexp t))) (if file-list (progn (insert target ":\n") (while (car command-list) (insert "\t" (car command-list) "\n") (setq command-list (cdr command-list))) (insert "\n"))) file-list)) (defun make-SFTRAN3-header-file-dependencies (directory match-regexp) "Make SFTRAN3 header file dependency lists for files in DIRECTORY that match MATCH-REGEXP, and insert them in the buffer at the current point." (let* ((file-list (directory-files directory nil match-regexp nil)) (file-list-string (make-file-list-string file-list))) (save-restriction (narrow-to-region (point) (point)) (insert "# SFTRAN3 header file dependencies\n\n") (shell-command (concat "egrep " "\"^[Ii][Nn][Cc][Ll][Uu][Dd][Ee][ \t]+[(]\" " file-list-string " | awk '{sub(/[.][a-z0-9]+:$/,\".o:\",$1); " " printf(\"%-15s\\t%s\\n\"," "$1, \"sftran.inc\")}'" " | sort ; echo ''") t) ;; If we found no dependencies, remove the insertion (goto-char (point-min)) (if (not (search-forward ".o:" nil t)) (kill-region (point-min) (point-max))) (goto-char (point-max))))) (defun make-tex-header-file-dependencies (directory match-regexp) "Make LaTeX/TeXinfo/TeX file dependency lists for files in DIRECTORY that match MATCH-REGEXP, and insert them in the buffer at the current point." (let* ((file-list (directory-files directory nil match-regexp nil)) (file-list-string (make-file-list-string file-list))) (save-restriction (narrow-to-region (point) (point)) (insert "# LaTeX/TeXinfo/TeX header file dependencies\n\n") (shell-command (concat "egrep " "\"^[ \t]*[@\\\\](input|include)[{ \t]\" " file-list-string " | awk '{gsub(/[{}]/,\" \",$0); " "sub(/[.][a-z0-9]+:/,\".dvi:\",$1); " "sub(/:.*/,\":\",$1); " " printf(\"%-15s\\t%s\\n\", $1, $2)}'" " | sort ; echo ''") t) ;; If we found no dependencies, remove the insertion (goto-char (point-min)) (if (not (search-forward ".dvi:" nil t)) (kill-region (point-min) (point-max))) (goto-char (point-max)))))