# Makefile for building HTML files from custom meta-tags, or redefining
# certain HTML tags.
# 01/10/26 RB Dartmouth College
# The original files are named .src
# All files are also dependants of buildhtml.conf, which sets colours, fonts etc.
# "make rebuild" should be performed after changing that file
.SUFFIXES: .shtml .html .src .htinc .sh .ksh
.src.html:
buildhtml $<
.src.shtml:
buildhtml -S $<
# For example scripts, first convert to basic HTML (.src), then process like the other HTML files
# Also, create an HTML-safe version for inclusion in SSI (.htinc), and a link to a .txt version for plain text.
# The .htinc and .txt files are built as side effects of the .ksh.html rule, not explicit dependencies.
.ksh.html:
rm -f $*.txt
ln -s $< $*.txt
ksh2html -i $< >$*.htinc
ksh2html $< | buildhtml -n > $*.html
.ksh.htinc:
ksh2html -i $< >$*.htinc
# To turn generic files into HTML include, just protect HTML entities like <,>,&
# .txt.htinc:
# sed -e 's/&/\&/g' -e 's/\</g' -e 's/>/\>/g' < $< >$*.htinc
.ksh.src:
ksh2html $< > $*.src
.sh.html:
rm -f $*.txt
ln -s $< $*.txt
ksh2html -i $< >$*.htinc
ksh2html $< | buildhtml -n > $*.html
.sh.htinc:
ksh2html -i $< >$*.htinc
.sh.src:
ksh2html $< > $*.src
# EDITABLE ITEMS
# These are generated as needed from the .src file by the rule above. List them in the order desired
# for the presentation - that ordering will be used for the menu.
# Don't list the intro and slide_list* files in $(SLIDES). The intro file is special because a link is made back
# to it from every page.
INTRO=welcome.html
SLIDES=what.html why.html history.html comparison.html scripting-languages.html ksh-vs-sh.html \
basics.html wildcards.html \
variables.html special-vars.html \
arguments.html command_line_opts.html command-subs.html \
ioredirection.html stdio.html \
cond-tests.html cond-tests2.html flow-control.html flow-control-2.html flow-control-ex.html \
misc-internal.html \
variable-manipulation.html functions.html advio.html wizardio.html \
coprocesses.html \
signals.html security.html style.html examples.html \
externals.html \
references.html
# Examples - these aren't part of the main pages, but are linked to them. The printed notes
# may or may not include them inline, so separate to two sets. EXAMPLES1 are needed for print_pages.shtml
EXAMPLES1=ex0.html ex1.html ex2.html ex3.html ex4.html ex4a.html ex5.html ex6.html ex7.html \
ex8.html ex9.html ex10.html ex11.html ex12.html duplex.html \
ex13.html ex14.html ex15.html ex16.html ex17.html
EXAMPLES2=buildhtml.html buildslidelist.html buildframeset.html ksh2html.html Makefile.txt \
MailPkg.html ptree-sh.html ptree-ksh.html pickrandom.html postprint.html \
sh-httpd.html checkpath.html run-with-timeout.html
EXAMPLES=$(EXAMPLES1) $(EXAMPLES2)
# Set BASE URL for hardcopy header - need to edit this if we switch the whole set of pages to a different
# location. Passed as -b option to buildhtml. NOT needed as a BASEURL tag in index.html
# e.g. BASEURL="http://www.dartmouth.edu/~rc/classes/ksh"
BASEURL="http://www.dartmouth.edu/~rc/classes/ksh"
# Directory - used for building tarballs etc.
BASEDIR="ksh"
# Remote machine and path for syncing uploads
UPLOADPATH="richard@www.dartmouth.edu:rc/classes/ksh"
# Everything below this point is fixed.
# =====================================
# Used in print_pages - order matters
FRONTSTUFF=$(INTRO) slide_list.htinc
# Miscellaneous other parts we always need
MISC=slide_list.html slide_list_expanded.html slide_list_noframes.html slide_list_noframes_expanded.html print_pages.shtml index.html
all: slide.order $(FRONTSTUFF) $(SLIDES) $(EXAMPLES) $(MISC) examples.tar.gz $(FRC)
# The EXAMPLES list are HTML files to be included in the web pages, but we want the original .sh/.ksh etc. files
# to place into a tar file for download. This is an inelegant way to do it - there are surely better.
# We actually need some auxiliary files too, so grab all of the examples direcory instead of looking at individual
# files (but we lose some of the dependency information this way)
examples.tar.gz: $(EXAMPLES)
rm -f examples.tar.gz
tar cf - examples | gzip -c > examples.tar.gz
# tar chf - `echo $(EXAMPLES) | tr ' ' '\n' | sort | uniq | sed 's/\.html/\.*sh/'` | gzip -c > examples.tar.gz
# Actually, every .html file also has "slide.order" as a dependancy, so that the "next" and "previous"
# links can be regenerated, and also the section numbers.
$(SLIDES) : slide.order
# Just so that "make rebuild" will get these too
$(EXAMPLES) $(INTRO) : $(FRC)
# NB If we pass $(BASEURL) to buildframeset, there is a dependancy on Makefile too.
index.html: $(INTRO) $(FRC)
buildframeset $(INTRO) > index.html
# Slide list file can be built and used in multiple ways.
slide_list.html: $(SLIDES) slide.order
buildslidelist $(INTRO) $(SLIDES) > slide_list.html
slide_list_expanded.html: $(SLIDES) slide.order
buildslidelist -e $(INTRO) $(SLIDES) > slide_list_expanded.html
rm -f slide_list_expanded.shtml
ln -s slide_list_expanded.html slide_list_expanded.shtml
slide_list.htinc:$(SLIDES) slide.order
buildslidelist -n -h $(INTRO) $(SLIDES) > slide_list.htinc
slide_list_noframes.html: $(SLIDES) slide.order
buildslidelist -n $(INTRO) $(SLIDES) > slide_list_noframes.html
slide_list_noframes_expanded.html: $(SLIDES) slide.order
buildslidelist -n -e $(INTRO) $(SLIDES) > slide_list_noframes_expanded.html
rm -f slide_list_noframes_expanded.shtml
ln -s slide_list_noframes_expanded.html slide_list_noframes_expanded.shtml
# Build slide.order file, numbering from 0, any time the Makefile may have changed the slide list or ordering
slide.order: Makefile $(FRC)
echo $(INTRO) $(SLIDES) | tr ' ' '\012' | awk '{ print NR-1,$$0 }' > slide.order
# Build the all-in-one page for printing. Only the examples placed inline in the notes are dependencies
# of print_pages.shtml
print_pages.shtml: $(SLIDES) $(FRONTSTUFF) $(EXAMPLES1)
buildhtml -p -b$(BASEURL) -s $(FRONTSTUFF) $(SLIDES) > print_pages.shtml
# Dummy target, always out of date
dummy:
# Make rebuild will force a rebuild of everything.
rebuild:
make all FRC=dummy
# Clean - ASSUMES ALL HTML FILES ARE BUILT FROM SOURCES (also .htinc and .txt)
clean:
-rm *.html *.shtml *.htinc *.txt slide.order
# Tar - for copying the whole site - does not rebuild, but ensures that "all" is up to date first
# Creates tarballs in the parent directory - beware about overwriting existing files
tar: all
cd ..;rm -f $(BASEDIR).tar.Z;tar cf $(BASEDIR).tar $(BASEDIR);compress $(BASEDIR).tar
# For examples - to show how this site was built
Makefile.txt: Makefile
rm -f Makefile.txt
ln -s Makefile Makefile.txt
# Copy all pages to remote mirror
upload: slide.order $(FRONTSTUFF) $(SLIDES) $(EXAMPLES) $(MISC) examples.tar.gz
rsync --delete -ave ssh . $(UPLOADPATH)
touch upload