Live data from Hacker News

A Simple Makefile for Medium-Sized C/C++ Projects

spin.atomicobject.com

111–120 of 120 posts

Re: A Simple Makefile for Medium-Sized C/C++ Projects

#111
post #16

It always annoys me that we don't have better solutions for building C and C++ projects by now. My own take on the generic drop-in makefile[1] has over 1000 stars on github, which says pretty loudly to me that this is a common pain point for many people. Alas I haven't had a brilliant idea for a solution (yet). [1]: https://github.com/mbcrawfo/GenericMakefile

We do. We have decent tooling (Visual Studio, Xcode) which let us set options and let us run compilers from the commandline using the options in the project and solution files (nmake, msbuild, xcodebuild) to save us having to use a hand-written Makefile. If you're still writing small projects and insisting on running a build in a command window, or writing code in a simple editor then I can perhaps understand the com…

Usually if you're distributing a Makefile with a project, it's for portability. Insisting that your Linux users of a C/C++ library install Visual Studio or Xcode is a complete non-starter. It's different at a company - every company I've been at had its own proprietary wrapper around make - but then you need to be able to integrate all the open source libs you're depending on.

At least there's autotools, which has its own set of problems, but you can be reasonably confident it'll generate a portable Makefile.

Re: A Simple Makefile for Medium-Sized C/C++ Projects

#112
post #16

It always annoys me that we don't have better solutions for building C and C++ projects by now. My own take on the generic drop-in makefile[1] has over 1000 stars on github, which says pretty loudly to me that this is a common pain point for many people. Alas I haven't had a brilliant idea for a solution (yet). [1]: https://github.com/mbcrawfo/GenericMakefile

I'm a fan of qmake for my projects, even the ones that don't use Qt.

Are there any other make systems that have Project Mode like qmake does?

Re: A Simple Makefile for Medium-Sized C/C++ Projects

#113
Nice to see people spreading good practices with Make.

Too many folks don't understand good use of Make and thus are doomed to re-invent it badly.

I've had to use too many build systems that are, basically, big and flat lists of variables you can set. And yes I'm pointing at everything from esoteric in house systems to mainstream ones. Make's system of overrides is something especially useful.

Re: A Simple Makefile for Medium-Sized C/C++ Projects

#114
I feel like the only person in the world that uses Boost Bjam (for a proprietary project). I feel like I should switch but every time I look into it and read comments it's not at all clear that Bjam was a bad decision - even if it feels like I was the only one to choose it :-) It's simple, seems pretty fast but it is very hard to integrate custom build steps.

Re: A Simple Makefile for Medium-Sized C/C++ Projects

#115
post #113

Nice to see people spreading good practices with Make. Too many folks don't understand good use of Make and thus are doomed to re-invent it badly. I've had to use too many build systems that are, basically, big and flat lists of variables you can set. And yes I'm pointing at everything from esoteric in house systems to mainstream ones. Make's system of overrides is something especially useful.

This. Make is highly underrated. It's old so it's probably clunky, has a weird syntax and dog slow. Well no. So many examples of people reinventing the wheel, it's just sad.

Re: A Simple Makefile for Medium-Sized C/C++ Projects

#116
post #60

This is not simple. I haven't made my own Makefiles, because when I see them, they are complex and not easy to understand. That's why I chose CMake for my projects. If this is simple, I chose the right build tool. This build file of a large project is easier to understand than the "Simple Makefile" https://gitlab.kitware.com/vtk/vtk/blob/master/CMakeLists.tx...

> they are complex and not easy to understand.

Makefiles are declarative, which is a bit strange at first. If you start with a simple one you pick it up really fast.

Re: A Simple Makefile for Medium-Sized C/C++ Projects

#118
post #62
post #30

Earlier quoted context omitted.

Yep, that's exactly what happened. Thanks for the explications. I actually did know that once, but forgot. Make definitely has its hidden traps.

I’ve made a comment to that effect on the original blog post. Hopefully they’ll be able to fix it.

Now fixed!

Re: A Simple Makefile for Medium-Sized C/C++ Projects

#119
post #32

Earlier quoted context omitted.

Would you write an article detailing your experience? It sounds fun to read.

Honestly, I don't think I could afford the therapy that I would need to re-live that part of my career in the detail that it would take to do a proper write-up. To this day, I still have no idea how an Android project actually winds up getting built, and their build system philosophy seems to boil down to "keep adding layers of magic, each making lower levels of magic harder to hand-edit and understand". Most of the…

I've had a similar experience getting shit to work on multiple platforms. I decided not to use cmake for mobile targets. While the NDK in general sucks to build, if you follow certain patterns you can get a system that works and is fairly straightforward. The path to get there is not easy though, I'll give you that.

Re: A Simple Makefile for Medium-Sized C/C++ Projects

#120

Earlier quoted context omitted.

The LibreOffice build system (which is plain GNU Make, without generated unreadable intermediate build files) does all these and more. Doing the same with autotools would be a nightmare.

We do however have some serious gnu make gurus to make that tractable.

... as we would have needed for CMake or Autotools. It might have worked with the former for something as complex as LibreOffice, but GNU make being so simple/basic and stable over the years was a big plus: Im sure even with CMake LibreOffice would have had fun with lots of small cornercase regressions.
Post reply on HN