COP 3344-01 Introduction to Unix: Lecture 7
Learning objectives
After this class, you should be able to:
- Write simple makefiles, and use
make
to build targets.- Given a makefile, timestamps on the files, and the
make
command, give the commands executed bymake
.
Reading assignment
- JEA: Appendix G, Make tutorial.
- Lecture slides: Lecture 7.
Exercises and review questions
- Questions on current lecture's material
- Modify the first makefile example from Lecture 7 so that it has an additional rule to backup a file named
file3
. Try updatingfile3
and see howmake
backs it up. Try runningmake
without updatingfile3
, and see the action performed bymake
.- Modify the above makefile so that a default target called
all
backs upfile1
,file2
, andfile3
when necessary.- Modify the above makefile so that the name of the program that performs the backup is given as a macro.
- Modify the above makefile so that the backup files are also backed up. That is, if
file1
is modified, thenfile1.bak
is backed up in a file calledfile1.bak.bak
, andfile1
is backed up infile1.bak
. Similarly, if the user updatesfile1.bak
directly, thenfile1.bak
should be backed up in the filefile1.bak.bak
.- (Optional) Read about the
crontab
command and see how you can have your files backed up automatically, say, every day.- Questions on next lecture's material
- Create a few text files which include a few lines containing the word
program
. Usegrep
to search for all lines containing the wordprogram
in all files that end in.txt
in the current working directory.