Permalink
Browse files

Added support for .PHONY, and tests for .PHONY and .ONESHELL

  • Loading branch information...
ihh committed Dec 24, 2016
1 parent d477a4f commit b07b3e6ba7698cd6e367e20b07daa3f30661f745
View
@@ -8,6 +8,8 @@ datadir = $(prefix)/share
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
.PHONY: all clean test symlink install uninstall
all: clean test
test:
View
@@ -407,6 +407,7 @@ Biomake supports most of the functionality of GNU Make, including
- [conditional syntax](https://www.gnu.org/software/make/manual/html_node/Conditionals.html) and [conditional functions](https://www.gnu.org/software/make/manual/html_node/Conditional-Functions.html)
- the [include](https://www.gnu.org/software/make/manual/html_node/Include.html) directive
- [wildcards in dependency lists](https://www.gnu.org/software/make/manual/html_node/Wildcards.html)
- [phony targets](https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html)
- various other quirks of GNU Make syntax e.g. single-line recipes, forced rebuilds
Currently unsupported features of GNU Make
@@ -416,8 +417,8 @@ The following features of GNU Make are not (yet) implemented:
- [Order-only prerequisites](https://www.gnu.org/software/make/manual/html_node/Prerequisite-Types.html)
- [Directory search](https://www.gnu.org/software/make/manual/html_node/Directory-Search.html)
- [Phony targets](https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html)
- Most of the [special built-in targets](https://www.gnu.org/software/make/manual/html_node/Special-Targets.html)
- `.PHONY` is implemented
- `.NOTPARALLEL` is implemented
- `.ONESHELL` is implemented
- `.SECONDARY` is implicit and `.INTERMEDIATE` is unsupported: Biomake never removes intermediate files
@@ -44,7 +44,8 @@
normalize_pattern/3,
unwrap_t/2,
flatten_trim/2,
rule_target/3,
rule_dependencies/3,
rule_execs/3,
@@ -303,6 +304,11 @@
% The interactions between the various options are a little tricky...
% Essentially (simplifying a little): MD5 overrides timestamps, except when queues are used.
rebuild_required(T,_,SL,Opts) :-
member(phony_targets(PT),Opts),
member(T,PT),
!,
verbose_report('Target ~w is phony - build required',[T],SL,Opts).
rebuild_required(T,DL,SL,Opts) :-
member(what_if(D),Opts),
member(D,DL),
@@ -347,6 +347,12 @@
makefile_special_target(oneshell(true),Lines) -->
makefile_recipe(rule([".ONESHELL"],_,_),Lines).
makefile_special_target(phony_targets(XDL),Lines) -->
makefile_recipe(rule([".PHONY"],DL,_),Lines),
{maplist(expand_vars,DL,XDL1),
maplist(split_spaces,XDL1,XDL2),
flatten_trim(XDL2,XDL)}.
makefile_recipe(rule(Head,Deps,Exec,{HeadGoal},{DepGoal},VNs),Lines) -->
makefile_targets(Head),
whitespace_or_linebreak,
View
@@ -77,6 +77,12 @@
run_test("-f Makefile.targetexpr","slash_var_in_deplist"),
run_test("-f Makefile.targetexpr","var_slash_var_in_deplist"),
announce("SPECIAL TARGETS"),
run_test("-f Makefile.oneshell","oneshell"),
run_test("ref","target",["echo untouched by biomake > oneshell_control"],[],"-f Makefile.oneshell_control","oneshell_control"),
run_test("ref","target",["echo empty > test.phony","echo empty > test2.phony"],[],"-f Makefile.phony1","phony_target"),
run_test("ref","target",["echo empty > test.phony","echo empty > test2.phony"],[],"-f Makefile.phony2","expanded_phony_target"),
announce("AUTOMATIC VARIABLES"),
run_test("stem.echo"),
run_test("first_dep"),
@@ -106,7 +112,6 @@
run_test("shell_assign"),
announce("CONDITIONAL SYNTAX"),
run_test("-f Makefile.cond","ifdef_true"),
run_test("-f Makefile.cond","ifdef_false"),
run_test("-f Makefile.cond","ifeq_true"),
@@ -224,7 +229,6 @@
run_test("ref","target",["rm test_file"],["sleep 2"],"-d -f Makefile.queue -Q sge --qsub-exec ../sge/fake_qsub --qdel-exec ../sge/fake_qdel","your-own-personal-jesus"),
announce("COMMAND-LINE OPTIONS"),
run_test("--file=Makefile.argval","arg_equals_val"),
run_test("-f Makefile.subdir.include -I subdir","include_dir"),
run_test("ref","target",["touch what_if_dep","sleep 1","echo Pre-update >what_if"],[],"-W what_if_dep","what_if"),
@@ -0,0 +1,3 @@
test.phony test2.phony
Updated test.phony
Updated test2.phony
View
@@ -0,0 +1 @@
hello from subdir
View
@@ -0,0 +1 @@
untouched by biomake
View
@@ -0,0 +1,3 @@
test.phony test2.phony
Updated test.phony
Updated test2.phony
@@ -0,0 +1,7 @@
# -*- makefile-gmake -*-
.ONESHELL:
oneshell:
cd subdir
echo hello from subdir >../$@
@@ -0,0 +1,5 @@
# -*- makefile-gmake -*-
oneshell_control:
cd subdir
echo hello from subdir >../$@
View
@@ -0,0 +1,9 @@
# -*- makefile-gmake -*-
.PHONY: test.phony test2.phony
phony_target: test.phony test2.phony
(echo $^; cat $^) >$@
test.phony test2.phony:
echo Updated $@ >$@
View
@@ -0,0 +1,11 @@
# -*- makefile-gmake -*-
PHONIES = test.phony test2.phony
.PHONY: $(PHONIES)
expanded_phony_target: test.phony test2.phony
(echo $^; cat $^) >$@
test.phony test2.phony:
echo Updated $@ >$@
@@ -1,3 +1,4 @@
# -*- makefile-gmake -*-
include_dir:
echo Found subdir >$@

0 comments on commit b07b3e6

Please sign in to comment.