diff --git a/code/06-variables-challenge/Makefile b/code/06-variables-challenge/Makefile index d09a2fed..7f006d2e 100644 --- a/code/06-variables-challenge/Makefile +++ b/code/06-variables-challenge/Makefile @@ -1,7 +1,8 @@ +LANGUAGE=python COUNT_SRC=wordcount.py -COUNT_EXE=python $(COUNT_SRC) +COUNT_EXE=$(LANGUAGE) $(COUNT_SRC) ZIPF_SRC=zipf_test.py -ZIPF_EXE=python $(ZIPF_SRC) +ZIPF_EXE=$(LANGUAGE) $(ZIPF_SRC) # Generate summary table. results.txt : $(ZIPF_SRC) isles.dat abyss.dat last.dat diff --git a/code/06-variables/config.mk b/code/06-variables/config.mk index 14580b26..350f5238 100644 --- a/code/06-variables/config.mk +++ b/code/06-variables/config.mk @@ -1,7 +1,8 @@ # Count words script. +LANGUAGE=python COUNT_SRC=wordcount.py -COUNT_EXE=python $(COUNT_SRC) +COUNT_EXE=$(LANGUAGE) $(COUNT_SRC) # Test Zipf's rule ZIPF_SRC=zipf_test.py -ZIPF_EXE=python $(ZIPF_SRC) +ZIPF_EXE=$(LANGUAGE) $(ZIPF_SRC) diff --git a/code/07-functions/config.mk b/code/07-functions/config.mk index 14580b26..350f5238 100644 --- a/code/07-functions/config.mk +++ b/code/07-functions/config.mk @@ -1,7 +1,8 @@ # Count words script. +LANGUAGE=python COUNT_SRC=wordcount.py -COUNT_EXE=python $(COUNT_SRC) +COUNT_EXE=$(LANGUAGE) $(COUNT_SRC) # Test Zipf's rule ZIPF_SRC=zipf_test.py -ZIPF_EXE=python $(ZIPF_SRC) +ZIPF_EXE=$(LANGUAGE) $(ZIPF_SRC) diff --git a/code/08-self-doc/config.mk b/code/08-self-doc/config.mk index 14580b26..350f5238 100644 --- a/code/08-self-doc/config.mk +++ b/code/08-self-doc/config.mk @@ -1,7 +1,8 @@ # Count words script. +LANGUAGE=python COUNT_SRC=wordcount.py -COUNT_EXE=python $(COUNT_SRC) +COUNT_EXE=$(LANGUAGE) $(COUNT_SRC) # Test Zipf's rule ZIPF_SRC=zipf_test.py -ZIPF_EXE=python $(ZIPF_SRC) +ZIPF_EXE=$(LANGUAGE) $(ZIPF_SRC) diff --git a/code/09-conclusion-challenge-1/config.mk b/code/09-conclusion-challenge-1/config.mk index 594259d4..4682f6b3 100644 --- a/code/09-conclusion-challenge-1/config.mk +++ b/code/09-conclusion-challenge-1/config.mk @@ -1,11 +1,12 @@ # Count words script. +LANGUAGE=python COUNT_SRC=wordcount.py -COUNT_EXE=python $(COUNT_SRC) +COUNT_EXE=$(LANGUAGE) $(COUNT_SRC) # Plot word counts script. PLOT_SRC=plotcount.py -PLOT_EXE=python $(PLOT_SRC) +PLOT_EXE=$(LANGUAGE) $(PLOT_SRC) # Test Zipf's rule ZIPF_SRC=zipf_test.py -ZIPF_EXE=python $(ZIPF_SRC) +ZIPF_EXE=$(LANGUAGE) $(ZIPF_SRC) diff --git a/code/09-conclusion-challenge-2/config.mk b/code/09-conclusion-challenge-2/config.mk index c1434e70..067609d9 100644 --- a/code/09-conclusion-challenge-2/config.mk +++ b/code/09-conclusion-challenge-2/config.mk @@ -1,11 +1,12 @@ # Count words script. +LANGUAGE=python COUNT_SRC=wordcount.py -COUNT_EXE=python $(COUNT_SRC) +COUNT_EXE=$(LANGUAGE) $(COUNT_SRC) # Plot word counts script. PLOT_SRC=plotcount.py -PLOT_EXE=python $(PLOT_SRC) +PLOT_EXE=$(LANGUAGE) $(PLOT_SRC) # Test Zipf's rule. ZIPF_SRC=zipf_test.py -ZIPF_EXE=python $(ZIPF_SRC) +ZIPF_EXE=$(LANGUAGE) $(ZIPF_SRC) diff --git a/episodes/06-variables.md b/episodes/06-variables.md index af9c4fca..b7076b1f 100644 --- a/episodes/06-variables.md +++ b/episodes/06-variables.md @@ -29,11 +29,12 @@ This is a variable [assignment]({{ page.root }}/reference#assignment) - `COUNT_SRC` is assigned the value `wordcount.py`. `wordcount.py` is our script and it is invoked by passing it to -`python`. We can introduce another variable to represent this +`python`. We can introduce another couple of variables to represent this execution: ~~~ -COUNT_EXE=python $(COUNT_SRC) +LANGUAGE=python +COUNT_EXE=$(LANGUAGE) $(COUNT_SRC) ~~~ {: .make} @@ -42,8 +43,9 @@ is run. This is a variable [reference]({{ page.root }}/reference#reference). At any place where we want to use the value of a variable we have to write it, or reference it, in this way. -Here we reference the variable `COUNT_SRC`. This tells Make to -replace the variable `COUNT_SRC` with its value `wordcount.py`. When +Here we reference the variables `LANGUAGE` and `COUNT_SRC`. This tells Make to +replace the variable `LANGUAGE` with its value `python`, +and to replace the variable `COUNT_SRC` with its value `wordcount.py`. When Make is run it will assign to `COUNT_EXE` the value `python wordcount.py`. @@ -74,12 +76,13 @@ the original makefile). Let us create `config.mk`: ~~~ # Count words script. +LANGUAGE=python COUNT_SRC=wordcount.py -COUNT_EXE=python $(COUNT_SRC) +COUNT_EXE=$(LANGUAGE) $(COUNT_SRC) # Test Zipf's rule ZIPF_SRC=zipf_test.py -ZIPF_EXE=python $(ZIPF_SRC) +ZIPF_EXE=$(LANGUAGE) $(ZIPF_SRC) ~~~ {: .make} diff --git a/episodes/07-functions.md b/episodes/07-functions.md index ac9b1de5..f62bf24f 100644 --- a/episodes/07-functions.md +++ b/episodes/07-functions.md @@ -245,12 +245,13 @@ Remember, the `config.mk` file contains: ~~~ # Count words script. +LANGUAGE=python COUNT_SRC=wordcount.py -COUNT_EXE=python $(COUNT_SRC) +COUNT_EXE=$(LANGUAGE) $(COUNT_SRC) # Test Zipf's rule ZIPF_SRC=zipf_test.py -ZIPF_EXE=python $(ZIPF_SRC) +ZIPF_EXE=$(LANGUAGE) $(ZIPF_SRC) ~~~ {: .make}