Skip to content

Commit

Permalink
feat: introduce MAKEFILE4LATEX_WAIT_COMMAND (#30)
Browse files Browse the repository at this point in the history
MAKEFILE4LATEX_WAIT_COMMAND selects the command to be used to wait some
time in "make watch". Its default value is (effectively) "sleep 1".

Close #30
  • Loading branch information
tueda committed Aug 9, 2021
1 parent eb86a38 commit a671aa3
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1277,8 +1277,9 @@ watch:
$(ensure_build_dir); \
touch $(addprefix $(build_prefix),$(srctexfiles:.tex=.log)); \
$(print_watching_message); \
$(define_wait_command); \
while :; do \
sleep 1; \
$$MAKEFILE4LATEX_WAIT_COMMAND; \
if $(MAKE) -q -s BUILDDIR=$(BUILDDIR) $(addprefix $(build_prefix),$(srctexfiles:.tex=.log)); then :; else \
$(call set_title,running); \
if time $(MAKE) -s BUILDDIR=$(BUILDDIR) $(addprefix $(build_prefix),$(srctexfiles:.tex=.log)); then \
Expand All @@ -1299,6 +1300,23 @@ print_watching_message = $(call colorize, \
echo "Watching for $(srctexfiles:.tex=.$(default_target)). Press Ctrl+C to quit" \
)

# $(call define_wait_command) defines $MAKEFILE4LATEX_WAIT_COMMAND in
# the current shell as follows:
# (1) If $(MAKEFILE4LATEX_WAIT_COMMAND) is defined at the level of
# Makefile (from the configuration files or command line options),
# then use it.
# (2) If $MAKEFILE4LATEX_WAIT_COMMAND is defined at the level of
# the shell (i.e., as the environment variable), then use it.
# (3) Otherwise, provide the default command "sleep 1".
define_wait_command = \
$(if $(MAKEFILE4LATEX_WAIT_COMMAND), \
MAKEFILE4LATEX_WAIT_COMMAND="$(MAKEFILE4LATEX_WAIT_COMMAND)" \
, \
if [ -z "$$MAKEFILE4LATEX_WAIT_COMMAND" ]; then \
MAKEFILE4LATEX_WAIT_COMMAND="sleep 1"; \
fi \
)

# Upgrade files in the setup. (Be careful!)
# Files to be upgraded must have a tag like
#
Expand Down

0 comments on commit a671aa3

Please sign in to comment.