COP 3344-01 Introduction to Unix: Lecture 7
Learning objectives
After this class, you should be able to:
- Write simple makefiles, and use
maketo build targets.- Given a makefile, timestamps on the files, and the
makecommand, 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 updatingfile3and see howmakebacks it up. Try runningmakewithout updatingfile3, and see the action performed bymake.- Modify the above makefile so that a default target called
allbacks upfile1,file2, andfile3when 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
file1is modified, thenfile1.bakis backed up in a file calledfile1.bak.bak, andfile1is backed up infile1.bak. Similarly, if the user updatesfile1.bakdirectly, thenfile1.bakshould be backed up in the filefile1.bak.bak.- (Optional) Read about the
crontabcommand 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. Usegrepto search for all lines containing the wordprogramin all files that end in.txtin the current working directory.