topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday December 12, 2024, 10:40 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Building code on Linux with non-recursive Make  (Read 5928 times)

wnitzan

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 31
    • View Profile
    • Donate to Member
Building code on Linux with non-recursive Make
« on: February 02, 2020, 05:47 PM »
Embarking on this journey, I had several objectives in mind:
1. I wanted to develop C++ programs on Linux.
2. I wanted a systematic method for building those programs using Makefiles.
3. The method should work for non-trivially sized programs, i.e. programs whose code spans multiple directories and files.
4. I intended those programs to make use of libraries, that I will write myself and also obtain from other sources.
5. I wished for a simple modular approach:
 - Adding another component to a library or a program will follow a well defined procedure, with short and simple Makefiles.
 - Likewise when one component wishes to include (make use of) another component.
6. I wished that header file dependencies are automatically discovered, instead of manually entered.
7. I wished that the method supported multiple independent build types for a given program, specifically, building both debug and release versions.
8. I wanted to call make from the source directory, and have the build performed in the appropriate directory, based on the build type.

Fortunately for me, others before me had one or more of these objectives in mind, too.
Thus, I combined ideas and code from multiple sources, and produced an example code to satisfy the above objectives.
I published the method and code on make-all.weebly.com .

In the downloadable example, I demonstrate the building of a library (tinylib), and a project (tinyproj) that uses it.
The "heavy lifting" code, that builds these items, is encapsulated in a set of common helper Makefiles, thus leaving the top-level Makefiles small and simple to understand and edit.

I hope you find it useful!
« Last Edit: September 04, 2020, 01:49 PM by wnitzan »

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,629
    • View Profile
    • Donate to Member
Re: Building code on Linux with non-recursive Make
« Reply #1 on: February 03, 2020, 01:08 AM »
 :Thmbsup:

It's been a while (~25+ years) since I used make for my Clipper (a dBase 3 compiler with many additional features) builds, so it's nice to see such a set of useful stuff. Thnx.