Make

This is a README.adoc file. The original repository is located here.

Task Make

Branch: make
Fenrir ID: make
Points: 90

You have to create a Makefile for this project.

  • All intermediate build files must be in build

  • The resulting binary must be in bin

  • The libraries must be in lib

Final project structure:

 pta-...
├─  make
│  ├─  bin
│  ├─  build
│  ├─  c-lib
│  ├─  cc-lib
│  ├─  lib
│  └─  Makefile
└─  .git

General requirements

  • Use pattern rules: explicit full paths are forbidden (e.g. c-lib/src/directorium/regularis.c is not allowed)

  • Use variables to define the locations (e.g. use $(BUILD_DIR) instead of bin)

  • Each target must be responsible for only one action (e.g. you mustn’t compile and link during the same target)

  • Use PHONY targets

  • The compiled code must be "production-ready": use appropriate optimisations

Static library (25 points)

Create a static library gladiator from c-lib.

Implement gladiator target so that the static library is present in the lib directory after command make gladiator was executed.

The library uses MAGIC macro: without providing the compiler with its value, the build won’t succeed. Its default value is (empty string). However, you must provide a way to override the default value with build args: make MAGIC="…​".

Shared library (30 points)

cc-lib directory provides two different implementations of the Lanista class:

As shared libraries are linked during the execution, we will create two libludus.so libraries: one from the Pompeian implementation and one from the Roman one.

The Pompeian library must be saved to lib/pompeian directory.

The Roman library must be saved to lib/roman directory.

Use pattern rules to reduce code duplication!

Do not use rpath: the LD_LIBRARY_PATH will be set correctly when executing the binary.

Both libraries must be created after the ludus target was run.

Binary (15 points)

Compile main.cpp into colosseum and put it into the bin directory. This binary uses both libraries: gladiator and ludus.

make command will be used to create the binary.

Clean (5 points)

Implement clean target: it must clean all build artifacts.

Install (15 points)

Implement install target: it must install the binary and the implementations of ludus library to the DESTDIR directory. Follow the FHS conventions.

When installing the shared libraries, make sure they have soname=libludus.so. The roman must have version 1 and the pompeian  —  2. The libludus.so library must point to the pompeian implementation.

This target will be executed via [sudo] make install DESTDIR=DIRNAME
Do not use sudo inside your scripts!

Questions

  • Why is it necessary to split targets into atomic ones?

  • What are the default install paths? Which one exactly have you chosen? Why?

  • How to access the default C/C++ compiler?

  • What are the PHONY targets?

  • How can we detect that optimisation options have been used?

  • What happens to Make’s wildcard when dealing with recursive subdirectories?

  • Why shouldn’t you use sudo in Makefile for the installation?

The project is licensed under the terms of the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

© 2026-present Iwan Kalinin <koefic.cien@gmail.com>