04. Exercise: Create A Basic Makefile
Exercise: Create A Basic Makefile
Makefiles can be incredibly useful ways to build up a chain of commands that build, test and deploy software.
Now that you've seen an example of a Makefile, you are ready to create one of your own. Makefiles have plenty of different commands and variables that can be used - check out this page for a long list of them.
While you will start from scratch in this exercise, if you need to look at another example of a Makefile, you can check out this Makefile in the course repository. This additional example Makefile will be used in the next lesson on containerization.
Instructions
- Create an empty
Makefileusing thetouchcommand - Create two commands:
cmd1andcmd2and make thisechothe name of the command.- Note that Makefiles will normally print out each line as it goes, but here we want it to just explicitly
echothe command names. Check out the link above to figure out how you can stop a line from printing. - Makefiles have an automatic variable that contains the target name for the commands you create. You can also find this in the link above to add to your Makefile.
- Note that Makefiles will normally print out each line as it goes, but here we want it to just explicitly
- Create an
allcommand that runs bothcmd1andcmd2 - Run
make allto see the output