|
Warning: this is an htmlized version!
The original is across this link, and the conversion rules are here. |
#######
#
# E-scripts on Make.
#
# Note 1: use the eev command (defined in eev.el) and the
# ee alias (in my .zshrc) to execute parts of this file.
# Executing this file as a whole makes no sense.
#
# Note 2: be VERY careful and make sure you understand what
# you're doing.
#
# Note 3: If you use a shell other than zsh things like |&
# and the for loops may not work.
#
# Note 4: I always run as root.
#
# Note 5: some parts are too old and don't work anymore. Some
# never worked.
#
# Note 6: the definitions for the find-xxxfile commands are on my
# .emacs.
#
# Note 7: if you see a strange command check my .zshrc -- it may
# be defined there as a function or an alias.
#
# Note 8: the sections without dates are always older than the
# sections with dates.
#
# This file is at <http://angg.twu.net/e/make.e>
# or at <http://angg.twu.net/e/make.e.html>.
# See also <http://angg.twu.net/emacs.html>,
# <http://angg.twu.net/.emacs[.html]>,
# <http://angg.twu.net/.zshrc[.html]>,
# <http://angg.twu.net/escripts.html>,
# and <http://angg.twu.net/>.
#
#######
# «.page» (to "page")
# «.environment» (to "environment")
# «.shell_functions» (to "shell_functions")
# «.call_function» (to "call_function")
# «.intermediate_files» (to "intermediate_files")
# «.makefile_toposort» (to "makefile_toposort")
# «.makefile_addtrace» (to "makefile_addtrace")
# «.cp-av-and-touch» (to "cp-av-and-touch")
# «.phony-targets» (to "phony-targets")
#####
#
# rewriting my page's makefiles
# 2000jun22
#
#####
# «page» (to ".page")
# (find-fline "~/TH/" "Makefile")
# (find-fline "~/TH/Makefile")
# (find-fline "~/TH/Makefile.auto")
# (find-fline "~/TH/Makefile.th")
# (find-fline "~/TH/Makefile0")
# (find-node "(make)Conditional Example")
# (find-node "(make)Conditional Syntax")
# (find-node "(make)Recursion")
# (find-node "(make)Environment")
# (find-node "(make)Variables/Recursion")
# (find-node "(make)Concept Index" ":=")
# (find-node "(make)Flavors")
# (find-node "(make)Flavors" "simply expanded variables")
# (find-node "(make)Flavors" "?=")
# (find-node "(make)Origin Function")
# (find-node "(make)Setting")
# (find-node "(make)Running")
# Is there some way to call Make with "inner targets" that are all
# passed to child Makes?
# (find-node "(make)Using Variables")
# (find-node "(make)Goals")
# (find-node "(make)Goals" "MAKECMDGOALS")
# (find-node "(make)Quick Reference" "MAKECMDGOALS")
#*
make -f - <<'---'
test:
@echo $(SUFFIXES)
---
#*
echo 'test:\n\t@echo $(SUFFIXES)' | make -f -
#*
function showmakevar () {
echo "test:\n\t@echo \$($1)" | make -f - $*[2,-1]
}
showmakevar SUFFIXES
showmakevar CFLAGS
showmakevar LDFLAGS
#*
#####
#
# searching the Make info docs
# 2000jun22
#
#####
# (find-status "make")
# (find-vldifile "make.list")
# (find-fline "/usr/doc/make/")
# (find-angg ".zshrc" "zcatinfo")
zcatinfo /usr/share/info/make > /tmp/make.info
# (find-fline "/tmp/make.info")
# Old:
rm -Rv ~/tmp/make/
mkdir ~/tmp/make/
cd ~/tmp/make/
cp -v /usr/share/info/make.info* .
gzip -dv *
# (find-fline "~/tmp/make/")
#####
#
# Difference between make XXX=yyy and XXX=yyy make
# 2000sep07
#
#####
# «environment» (to ".environment")
# (find-node "(make)Overriding")
# (find-node "(make)Options Summary" "--environment-overrides")
# (find-node "(make)Environment")
# (find-node "(make)Environment" "variable `SHELL'")
# (find-node "(make)Setting" "FOO ?= bar")
# (find-node "(make)Variables/Recursion" "`export'")
# (find-node "(make)Origin Function")
# More explanations for the
# "XXX=yyy command" syntax:
#
# (find-node "(bash)Simple Command Expansion" "variable assignments")
# (find-node "(bash)Simple Command Expansion" "If no command name results")
#*
echo $FOO
make -f - <<'---'
FOO="not overriden"
test:
# FOO is $(FOO)
---
make -f - FOO=parameter <<'---'
FOO="not overriden"
test:
# FOO is $(FOO)
---
FOO=environment make -f - <<'---'
FOO=not overriden
test:
# FOO is $(FOO)
---
#*
# Obs: ":=" seems to work identically to "=" in this respect.
#####
#
# Intermediate files
# 2000sep18
#
#####
# «intermediate_files» (to ".intermediate_files")
# (find-node "(make)Chained Rules" ".INTERMEDIATE")
# (find-node "(make)Automatic" "$^")
# (find-angg "LATEX/Makefile" "edrxnotes")
#*
rm -Rv /tmp/make/
mkdir /tmp/make/
cd /tmp/make/
cat > Makefile <<'---'
%.auto.dnt:
date > $@
%.tex:
date > $@
%.dvi: %.tex
echo $^ > $@
.INTERMEDIATE: 00apr10.auto.dnt 00apr29.auto.dnt
00apr10.dvi: 00apr10.tex 00apr10.auto.dnt
00apr29.dvi: 00apr29.tex 00apr29.auto.dnt
00feb24.dvi: 00feb24.tex 00feb24.auto.dnt
00feb25.dvi: 00feb25.tex
00jan03.dvi: 00jan03.tex
---
make 00apr10.dvi 00apr29.dvi 00feb24.dvi 00feb25.dvi 00jan03.dvi
#*
#####
#
# Defining make functions that call the shell
# 2000sep18
#
#####
# «shell_functions» (to ".shell_functions")
#*
# (find-angg ".zshrc" "TeX")
cd ~/LATEX/
dvitype -output-level=1 feb98.dvi \
| grep PSfile \
| perl -nle 'print m/"(.*)"/' \
| sort | uniq
#*
# (find-node "(make)Text Functions")
# (find-node "(make)Shell Function")
# «call_function» (to ".call_function")
# (find-node "(make)Call Function" "reverse = $(2) $(1)")
# (find-fline "/usr/doc/make/NEWS.gz" "$(call ...)")
# Big oops: $(call ...) was introduced in make 3.78 and one of the
# mirrors of my page is based on RedHat 6.1, that has only make 3.77;
# so my portable makefiles will have to avoid using $(call ...) for
# this moment.
#*
cat > /tmp/Makefile <<'---'
listepsfiles = \
$(shell dvitype -output-level=1 $(1) \
| grep PSfile \
| perl -nle 'print m/"(.*)"/' \
| sort | uniq)
demo:
echo $(call listepsfiles, feb98.dvi) > /dev/null
%-dvi.tgz:
echo tar -cvzf $@ $*.dvi $(call listepsfiles, $*.dvi) > /dev/null
---
cd ~/LATEX/
make -f /tmp/Makefile
make -f /tmp/Makefile feb98-dvi.tgz
#*
$(patsubst PATTERN,REPLACEMENT,TEXT)'
#####
#
# topological sort on makefiles
# 2000dec26
#
#####
# «makefile_toposort» (to ".makefile_toposort")
# (find-es "kernel" "make-kpkg_rules")
# (find-es "lua" "toposort")
# (find-es "perl" "reading_a_file_at_once")
#*
cat /usr/share/kernel-package/rules \
| perl -e 'undef $/; $_ = <>; s/\\\n//g; print' \
| tee ~/o \
| perl -nle 'if (m/^[^\t][^#:=]*:([^=]|$)/) { print }' \
| tee ~/o2 \
| lua ~/LUA/toposort.lua
# (find-fline "~/o" "debian:")
# (find-fline "~/o2" "debian:")
#*
cat /usr/share/kernel-package/rules \
| perl -e 'undef $/; $_ = <>; s/\\\n//g; print' \
| perl -nle 'if (m/^[^\t][^#:=]*:([^=]|$)/) { print }' \
| tee ~/o2 \
| lua ~/LUA/toposort.lua
#*
# (find-angg ".zshrc" "make")
cat /usr/share/kernel-package/rules \
| makefile_getdeps \
| lua ~/LUA/toposort.lua
#*
#####
#
# Adding "trace" lines to makefiles
# 2000dec26
#
#####
# «makefile_addtrace» (to ".makefile_addtrace")
# (find-angg ".zshrc" "make")
# (find-node "(make)Automatic")
# (find-es "kernel" "make-kpkg_rules")
#*
cat /usr/share/kernel-package/rules \
| perl -e 'undef $/; $_ = <>; s/\\\n//g; print' \
| perl -nle '
print;
if ( m/^[^\t][^#:=]*:([^=]|$)/ ) {
$n++; printf "\t# Dbg %d/%d \$\@: \$^\n", $n, $n+$.
};
' \
| l +/Dbg
#*
cat /usr/share/kernel-package/rules \
| makefile_addtrace \
| l +/Dbg
#*
#####
#
# pmake (the BSD make) on Debian
# 2001jul24
#
#####
# (find-status "pmake")
# (find-vldifile "pmake.list")
# (find-fline "/usr/doc/pmake/")
gv /usr/doc/pmake/tutorial.ps.gz &
zcat /usr/doc/pmake/tutorial.asc.gz \
| l '+/2.7. Invoking PMake'
#*
# (find-fline "/usr/share/mk/")
# (find-fline "/freebsd/usr/share/mk/")
cd /usr/share/mk/; ls | tee /tmp/olusm
cd /freebsd/usr/share/mk/; ls | tee /tmp/olfusm
diff /tmp/olusm /tmp/olfusm
#*
rm -Rv /tmp/psd/
cd /netbsd/usr/share/doc/
cp -diPpvR psd /tmp/
cd /tmp/psd/
#*
# (find-es "bsd" "ports")
# (find-fline "/freebsd/usr/ports/lang/tcl82/")
# (find-fline "/freebsd/usr/share/mk/bsd.port.mk")
# (find-fline "/freebsd/usr/ports/Mk/bsd.port.mk")
# (find-fline "/freebsd/usr/ports/Mk/bsd.port.mk" "\nSED?=")
rm -Rv /tmp/ports/
cd /freebsd/usr/
cp -diPpvR ports/lang/tcl82/ /tmp/
cd /tmp/ports/lang/tcl82/
pmake |& tee opm1
cd /tmp/ports/lang/tcl82/
cp -v /freebsd/usr/ports/Mk/bsd.port* .
cp -v /freebsd/usr/ports/Mk/bsd.sites* .
pmake -I `pwd` \
-d j \
SED=/bin/sed \
ARCH=$(uname -m) OPSYS=$(uname -s) OSREL=$(uname -r | sed -e 's/[-(].*//') \
OSVERSION=4.1 \
|& tee opm2
# -d mst
# "-p 2" is mentioned in the tutorial but is not accepted.
# (find-fline "/tmp/ports/lang/tcl82/")
# (find-fline "/tmp/ports/lang/tcl82/opm2")
#####
#
# the problem with cp -av in make
# 2005jan09
#
#####
# «cp-av-and-touch» (to ".cp-av-and-touch")
#*
# (find-node "(make)Automatic" "$^")
# (find-node "(coreutils)stat invocation")
# (find-man "1 stat")
# Try to comment out either cp -av or touch
cd /tmp/
touch file1; sleep 1; touch file2
cat > Makefile <<'%%%'
file1: file2
@echo $@ is older than $<
cp -av $< $@
stat file1 file2
touch $@
stat file1 file2
%%%
make
make
#*
#####
#
# .PHONY targets
# 2006jul19
#
#####
# «phony-targets» (to ".phony-targets")
# (find-node "(make)Phony Targets")
# (find-es "lua5" "install-5.1.1")
# (find-lua51file "src/Makefile")
# (find-lua51file "src/Makefile" ".PHONY:")
# (find-dn4 "Makefile")
# (find-dn4 "examples/Makefile")
# twb, 2006aug27
#
MAKEFILES := $(patsubst %.map,%.mk,$(wildcard *.map))
include $(MAKEFILES)
%.mk: %.map map2mk.sh
sh map2mk.sh $* <$< >$@
# Recursive Make Considered Harmful:
# http://miller.emu.id.au/pmiller/books/rmch/
# http://aegis.sourceforge.net/auug97.pdf
Something about auto dependencies (2006oct16; can I use that for TH?):
http://make.paulandlesley.org/autodep.html
# Local Variables:
# coding: raw-text-unix
# ee-delimiter-hash: "\n#*\n"
# ee-delimiter-percent: "\n%*\n"
# ee-anchor-format: "«%s»"
# End: