commit 4794e255c933621be3a11b11a37a8348ea9c2b74
parent c501e0299bba8e31cb19f9a49968924a7fb71ec4
Author: Kyle Milz <krwmilz@gmail.com>
Date: Tue, 20 Jul 2021 20:51:22 +0000
mk: move html.mk to root
Diffstat:
10 files changed, 180 insertions(+), 181 deletions(-)
diff --git a/html.mk b/html.mk
@@ -0,0 +1,172 @@
+#
+# html.mk
+# This file must be included by all Makefiles.
+#
+
+#
+# These variables shoud not be modified here but set in Makefiles instead.
+# - TOP: Directory containing the `mk' directory
+# - SRCS: List of source files to transform into HTML documents
+#
+TOP ?= .
+SRCS ?= index.in
+INCLUDE = ${.CURDIR}/${TOP}/include
+
+
+# Clear existing suffixes.
+.SUFFIXES:
+
+
+# Check SRCS array for nonexisting files.
+.for src in ${SRCS}
+. if !exists(${.CURDIR}/${src})
+all:
+ @>&2 echo "html.mk: file '${src}' in SRCS array does not exist."
+.else
+all: ${src:.in=.html}
+. endif
+.endfor
+
+
+all: _SUBDIRUSE
+
+#
+# Use the C preprocessor to turn input source files into HTML.
+#
+# -I: global files and targets generated in object directory can be included
+# -P: the files being preprocessed are not C
+# -o: the final HTML files are written in the object directory
+#
+.SUFFIXES: .in .html
+.in.html:
+ cpp -I${INCLUDE} -I${.OBJDIR} -P -o ${.OBJDIR}/$@ $<
+
+
+#
+# Use the C preprocessor to generate dependency files from input source
+# files.
+#
+# -I: XXX
+# -M: generate Makefile dependency target instead of preprocessing
+# -MG: assume missing files are generated files
+# -MF: write dependency list to .depend file where make will look for it
+# -MT: override target name
+#
+.SUFFIXES: .depend
+.in.depend:
+ cpp -I${INCLUDE} -M -MG -MF $@ -MT ${@:.depend=.html} $<
+
+# Create the final `.depend' file from all of the individual dependency files.
+.if !empty(SRCS)
+depend: ${SRCS:.in=.depend} _SUBDIRUSE
+ cat ${.ALLSRC} > .depend
+.endif
+
+
+#
+# Generate HTML fragments that contain <a><img> links to images.
+#
+.SUFFIXES: .img_html
+.SUFFIXES: .jpeg
+.SUFFIXES: .jpg
+.SUFFIXES: .png
+.jpeg.img_html .jpg.img_html .png.img_html:
+ mkdir -p ${.OBJDIR}/_img
+ cp $? ${.OBJDIR}/_img/
+
+ @# Generate thumbnail of image with `_thumb' appended to file name.
+ convert -resize 800x $? ${.OBJDIR}/_img/${<F:R}_thumb.${<F:E}
+
+ @#
+ @# Create HTML fragment that uses the thumbnail as a base image
+ @# that is a link to the full size (copied) image, like this:
+ @#
+ @# <a href="pic_cp.jpg"><img loading='lazy' src="pic_thumb.jpg"
+ @#
+ @# NOTE: The <img> tag is not closed! You must close it, maybe with:
+ @# alt="description of image for blind people" /></a>
+ @#
+ echo "\t<a href='_img/${<F}'><img loading='lazy' src='_img/${<F:R}_thumb.${<F:E}' " > $@
+
+#
+# Generate `*_html' html fragments that link to videos using <video> tag.
+#
+.SUFFIXES: .mp4 .mp4_html
+.SUFFIXES: .mov .mov_html
+.mp4.mp4_html .mov.mov_html:
+ @# Copy video from source to object directory.
+ cp $? ${.OBJDIR}/
+
+ @# Generate html code snippet using HTML5 video tag to show video.
+ echo "\t<video controls>" > $@
+ echo "\t\t<source src='${<F}' type='video/mp4'>" >> $@
+ echo "\t\tYour browser does not support the video tag." >> $@
+ echo "\t</video>" >> $@
+
+
+#
+# Transliterate the contents of various file types when they coincidentally
+# (not purposefully) contain HTML markup or C preprocessor directives.
+#
+# - turn '<' and '>' into HTML named character references so they are
+# displayed and not parsed
+# - turn '\' line continuation into HTML named character reference so they
+# do not get removed by the HTML parser
+# - turn '#' into HTML named character reference so the preprocessor doesn't
+# try and operate on it.
+#
+# Note dependency file names must be unique for this inference because all
+# target files will have .xliterate suffix.
+#
+.SUFFIXES: .c .html .in .txt
+.SUFFIXES: .xliterate
+.c.xliterate .html.xliterate .in.xliterate .txt.xliterate:
+ sed \
+ -e "s/</\</g" \
+ -e "s/>/\>/g" \
+ -e "s/\\\/\\/" \
+ -e "s/#/\#/g" \
+ $< > $@
+
+
+#
+# Make an HTML time attribute for direct inclusion in HTML. Populate the
+# "datetime" property with an appropriatly formatted date.
+# Use full names for day of week and month instead of default abbreviated ones.
+#
+FMT="+%A %B %e %H:%M:%S %Z %Y"
+_timestamp.gen: index.in
+ echo "<time datetime='`date +%Y-%m-%d`'>`date ${FMT}`</time>" > $@
+
+#
+# Generate a banner of the current directory for inclusion in HTML.
+#
+_dirbanner_html:
+ @echo " <pre class='small'>" > ${.OBJDIR}/$@
+ here=`cd ${.CURDIR}; basename $$PWD`; \
+ banner $$here >> ${.OBJDIR}/$@;
+ @echo "</pre>" >> ${.OBJDIR}/$@
+
+#
+# Plain file copy.
+#
+.for file in ${CP_OBJ}
+.if !exists(${.CURDIR}/${file})
+all:
+ @>&2 echo "html.mk: file '${file}' in CP_OBJ array does not exist."
+.else
+
+#
+# We can get away with using the same file name here and make still being
+# able to distinguish the files because we use absolute paths.
+#
+${.OBJDIR}/${file}: ${.CURDIR}/${file}
+ cp ${.CURDIR}/${file} $@
+
+all: ${.OBJDIR}/${file}
+
+.endif
+.endfor
+
+.include <bsd.obj.mk>
+.include <bsd.subdir.mk>
diff --git a/mk/html.mk b/mk/html.mk
@@ -1,173 +0,0 @@
-#
-# html.mk
-# This file must be included by all Makefiles.
-#
-
-#
-# These variables shoud not be modified here but set in Makefiles instead.
-# - TOP: Directory containing the `mk' directory
-# - SRCS: List of source files to transform into HTML documents
-#
-TOP ?= .
-SRCS ?= index.in
-INCLUDE = ${.CURDIR}/${TOP}/include
-
-
-# Clear existing suffixes.
-.SUFFIXES:
-
-
-# Check SRCS array for nonexisting files.
-.for src in ${SRCS}
-. if !exists(${.CURDIR}/${src})
-all:
- @>&2 echo "html.mk: file '${src}' in SRCS array does not exist."
-.else
-all: ${src:.in=.html}
-. endif
-.endfor
-
-
-all: _SUBDIRUSE
-
-#
-# Use the C preprocessor to turn input source files into HTML.
-#
-# -I: global files and targets generated in object directory can be included
-# -P: the files being preprocessed are not C
-# -o: the final HTML files are written in the object directory
-#
-.SUFFIXES: .in .html
-.in.html:
- cpp -I${INCLUDE} -I${.OBJDIR} -P -o ${.OBJDIR}/$@ $<
-
-
-#
-# Use the C preprocessor to generate dependency files from input source
-# files.
-#
-# -I: XXX
-# -M: generate Makefile dependency target instead of preprocessing
-# -MG: assume missing files are generated files
-# -MF: write dependency list to .depend file where make will look for it
-# -MT: override target name
-#
-.SUFFIXES: .depend
-.in.depend:
- cpp -I${INCLUDE} -M -MG -MF $@ -MT ${@:.depend=.html} $<
-
-# Create the final `.depend' file from all of the individual dependency files.
-.if !empty(SRCS)
-depend: ${SRCS:.in=.depend} _SUBDIRUSE
- cat ${.ALLSRC} > .depend
-.endif
-
-
-#
-# Generate HTML fragments that contain <a><img> links to images.
-#
-.SUFFIXES: .img_html
-.SUFFIXES: .jpeg
-.SUFFIXES: .jpg
-.SUFFIXES: .png
-.jpeg.img_html .jpg.img_html .png.img_html:
- mkdir -p ${.OBJDIR}/_img
- cp $? ${.OBJDIR}/_img/
-
- @# Generate thumbnail of image with `_thumb' appended to file name.
- convert -resize 800x $? ${.OBJDIR}/_img/${<F:R}_thumb.${<F:E}
-
- @#
- @# Create HTML fragment that uses the thumbnail as a base image
- @# that is a link to the full size (copied) image, like this:
- @#
- @# <a href="pic_cp.jpg"><img loading='lazy' src="pic_thumb.jpg"
- @#
- @# NOTE: The <img> tag is not closed! You must close it, maybe with:
- @# alt="description of image for blind people" /></a>
- @#
- echo "\t<a href='_img/${<F}'><img loading='lazy' src='_img/${<F:R}_thumb.${<F:E}' " > $@
-
-#
-# Generate `*_html' html fragments that link to videos using <video> tag.
-#
-.SUFFIXES: .mp4 .mp4_html
-.SUFFIXES: .mov .mov_html
-.mp4.mp4_html .mov.mov_html:
- @# Copy video from source to object directory.
- cp $? ${.OBJDIR}/
-
- @# Generate html code snippet using HTML5 video tag to show video.
- echo "\t<video controls>" > $@
- echo "\t\t<source src='${<F}' type='video/mp4'>" >> $@
- echo "\t\tYour browser does not support the video tag." >> $@
- echo "\t</video>" >> $@
-
-
-#
-# Transliterate the contents of various file types when they coincidentally
-# (not purposefully) contain HTML markup or C preprocessor directives.
-#
-# - turn '<' and '>' into HTML named character references so they are
-# displayed and not parsed
-# - turn '\' line continuation into HTML named character reference so they
-# do not get removed by the HTML parser
-# - turn '#' into HTML named character reference so the preprocessor doesn't
-# try and operate on it.
-#
-# Note dependency file names must be unique for this inference because all
-# target files will have .xliterate suffix.
-#
-.SUFFIXES: .c .html .in .txt
-.SUFFIXES: .xliterate
-.c.xliterate .html.xliterate .in.xliterate .txt.xliterate:
- sed \
- -e "s/</\</g" \
- -e "s/>/\>/g" \
- -e "s/\\\/\\/" \
- -e "s/#/\#/g" \
- $< > $@
-
-
-#
-# Make an HTML time attribute for direct inclusion in HTML. Populate the
-# "datetime" property with an appropriatly formatted date.
-# Use full names for day of week and month instead of default abbreviated ones.
-#
-FMT="+%A %B %e %H:%M:%S %Z %Y"
-_timestamp.gen: index.in
- echo "<time datetime='`date +%Y-%m-%d`'>`date ${FMT}`</time>" > $@
-
-#
-# Generate a banner of the current directory for inclusion in HTML.
-#
-_dirbanner_html:
- @echo " <pre class='small'>" > ${.OBJDIR}/$@
- here=`cd ${.CURDIR}; basename $$PWD`; \
- banner $$here >> ${.OBJDIR}/$@;
- @echo "</pre>" >> ${.OBJDIR}/$@
-
-#
-# Plain file copy.
-#
-.for file in ${CP_OBJ}
-.if !exists(${.CURDIR}/${file})
-all:
- @>&2 echo "html.mk: file '${file}' in CP_OBJ array does not exist."
-.else
-
-#
-# We can get away with using the same file name here and make still being
-# able to distinguish the files because we use absolute paths.
-#
-${.OBJDIR}/${file}: ${.CURDIR}/${file}
- cp ${.CURDIR}/${file} $@
-
-all: ${.OBJDIR}/${file}
-
-.endif
-.endfor
-
-.include "site.mk"
-.include <bsd.obj.mk>
-.include <bsd.subdir.mk>
diff --git a/t/cp_happy.t b/t/cp_happy.t
@@ -8,7 +8,7 @@ use Test::More tests => 9;
my $cmd = Test::Cmd->new( prog => '/usr/bin/make', workdir => '' );
-my $html_mk = $cmd->here . '/mk/html.mk';
+my $html_mk = $cmd->here . '/html.mk';
$cmd->write( 'site.mk', <<EOF );
BSDSRCDIR = /tmp
diff --git a/t/cp_nodest.t b/t/cp_nodest.t
@@ -8,7 +8,7 @@ use Test::More tests => 5;
my $cmd = Test::Cmd->new( prog => '/usr/bin/make', workdir => '' );
-my $html_mk = $cmd->here . "/mk/html.mk";
+my $html_mk = $cmd->here . "/html.mk";
$cmd->write( 'cp_file.txt', 'some file contents' );
$cmd->write( 'Makefile', <<EOF );
diff --git a/t/cp_unhappy.t b/t/cp_unhappy.t
@@ -7,7 +7,7 @@ use Test::More tests => 9;
my $cmd = Test::Cmd->new( prog => '/usr/bin/make', workdir => '' );
-my $html_mk = $cmd->here . "/mk/html.mk";
+my $html_mk = $cmd->here . "/html.mk";
$cmd->write ( 'site.mk', <<EOF );
BSDSRCDIR = /tmp
diff --git a/t/dep_simple.t b/t/dep_simple.t
@@ -8,7 +8,7 @@ use Test::More tests => 19;
my $cmd = Test::Cmd->new( prog => '/usr/bin/make', workdir => '' );
-my $html_mk = $cmd->here . "/mk/html.mk";
+my $html_mk = $cmd->here . "/html.mk";
$cmd->write( 'index.in', '' );
$cmd->write( 'Makefile', <<EOF );
diff --git a/t/img_html.t b/t/img_html.t
@@ -15,7 +15,7 @@ use Test::More tests => 19;
my @sfxs = ( 'jpg', 'jpeg', 'png' );
my $cmd = Test::Cmd->new( prog => '/usr/bin/make', workdir => '' );
-my $html_mk = $cmd->here . "/mk/html.mk";
+my $html_mk = $cmd->here . "/html.mk";
# Write smallest possible image for quick processing.
my $img = Imager->new( xsize => 1, ysize => 1, channels => 4 );
diff --git a/t/srcs_missing.t b/t/srcs_missing.t
@@ -7,7 +7,7 @@ use Test::More tests => 3;
my $cmd = Test::Cmd->new( prog => '/usr/bin/make', workdir => '' );
-my $html_mk = $cmd->here . "/mk/html.mk";
+my $html_mk = $cmd->here . "/html.mk";
$cmd->write( 'Makefile', <<EOF );
.include "$html_mk"
diff --git a/t/srcs_suffix.t b/t/srcs_suffix.t
@@ -7,7 +7,7 @@ use Test::Cmd;
use Test::More tests => 12;
my $cmd = Test::Cmd->new( prog => '/usr/bin/make', workdir => '' );
-my $html_mk = $cmd->here . "/mk/html.mk";
+my $html_mk = $cmd->here . "/html.mk";
#
# 1) File with no suffix in SRCS array and does not exist
diff --git a/t/xliterate.t b/t/xliterate.t
@@ -8,7 +8,7 @@ use Test::More tests => 7;
my $cmd = Test::Cmd->new( prog => '/usr/bin/make', workdir => '' );
-my $html_mk = $cmd->here . "/mk/html.mk";
+my $html_mk = $cmd->here . "/html.mk";
$cmd->write( 'c_frag.c', '#include <stdio.h>' );
$cmd->write( 'html_frag.html', '<head><body> <img /> </body>' );