Assignment 4: Build Systems Yet another important tool for development is a build…
- User
Assignment 4: Build Systems
Yet another important tool for development is a build system. A build system takes care of compiling the source code of a program to generate executables, libraries, or sometimes entire system images. If you have a single source file, you probably do not need a build system to compile it. However, modern software often has countless source files with complex dependencies, and a build system is necessary to manage them altogether.
The most basic problem of compiling many source files with dependencies is that of recompiling---often times, you change a small portion of a single file and you want to recompile your code so you can test the change. Ideally, you should be able to only recompile the source files that are impacted by your change, i.e., you shouldn't have to recompile all the other files that your change doesn't really impact at all. Build systems take care of this basic problem. Of course, they do much more than that, as you will find out.
In this assignment, you will learn the basics of the two of the most popular build systems for C, Make and CMake. Make is a popular build system that has a long history from the early Unix days. Despite the fact that it's been around for decades, it still remains a popular choice as a build system. CMake stands for Cross-platform Make and is another popular build system. As the name suggests, it aims to be cross-platform, meaning that it allows you to use a single CMake configuration to compile across different platforms. Both Make and CMake have many features but you will learn just the basics so you can use them in future assignments.
Task 0: Make
In this task, you will read through Makefile Tutorial, which is a very well-written document that is designed for beginners. As always, you need to record what you do as you follow the tutorial. But first, here are a few important points to note:
- Make sure you record what you do with
record. - Create a directory named
makeand do everything in that directory. - The tutorial uses
ccas the compiler, which defaults togcc. We do not usegccin this course. Instead, we useclang. The behavior is different, so make sure you useclanginstead ofccor .
- Make sure you record what you do with
- Assistant