4 ms·
I do like simple makefiles. I adopted a C++-project without having much C++-knowledge, and simplifying the build setup was a big step in making it mine. Thinki
by onli 10y ago
I do like simple makefiles. I adopted a C++-project without having much C++-knowledge, and simplifying the build setup was a big step in making it mine.
Thinking that it might be nice, I tried this one instead of my own approach at a simple makefile (https://github.com/onli/simdock/blob/master/Makefile https://github.com/onli/simdock/blob/master/Makefile) and I get this error:
> Makefile:16: * missing separator. Stop.
Which raises kind of an important point: Simple means understanding what is happening. I have no idea why `$(CC) $(OBJS) -o $@ $(LDFLAGS)` does raise that error - and just like that it is not simple for me anymore.
Edit: Now with the tab-error out of the way, it of course does not find the dependencies. That might be caused by a strange project organization (like said, it is an adopted project) or maybe the makefile is just not complete – I'm not sure how far the auto-generation is supposed to go. Played a bit with it, but that just removes the simplicity. For now, I think that the pkg-config way is nice and explicit, and would recommend to take a look at the linked makefile if a simple one is searched. Though I still would be happy about optimizations for that file!
I of course just might miss the point. Well, after all that supports mine: Not that simple after all.
- stevekemp 10y agoSadly you're bitten by the biggest misfeature in Make - You must use TABs not spaces.
- revelation 10y agoYour editor probably automatically converted tabs into spaces. And just like that, the Makefile stops working. Which proves the point: Makefiles are at a point in life where they should be exclusively automatically generated. The only exception are throwaway projects where you and only you use it.
- mbrock 10y agoI strongly disagree. The tab requirement for Make is very well known and less strange than custom Makefile generation. Simple Makefiles work extremely well in lots of projects.
- revelation 10y agoSomebody listed a number of common build system requirements below, but of course there are usually many many more like custom compilers, cross-compilation, any number of things that your "simple makefile" can't work with. By the time the Makefile has grown to support all these things it no longer has the properties that made it useful in the first place (parsimonious, understandable, small).
- anjbe 10y agoSupporting custom compilers and cross‐compilation is as simple as using ${CC} in the Makefile instead of gcc…
- revelation 10y agoThis is how we got into this mess in the first place. "Surely it can't be very difficult, let me just add this.."
- anjbe 10y agoPerhaps, but I suspect writing a portable Makefile is not as difficult as you think. Speaking as a packager, I have to patch many CMake build systems for portability issues. And don’t even get me started on SCons. Autotools is better in that regard, but has many flaws of its own. Here’s an example of a portable Makefile I’ve contributed to a project which handles the common packaging issues (staging directories, cross‐compilation, parallel builds): https://github.com/sinamas/gambatte/pull/6/commits/8d6fffc2b3614f3753aae30bf78e66626a88d428 https://github.com/sinamas/gambatte/pull/6/commits/8d6fffc2b... Compared to the original build system (two SConstructs): https://github.com/sinamas/gambatte/blob/master/gambatte_sdl/SConstruct https://github.com/sinamas/gambatte/blob/master/gambatte_sdl... https://github.com/sinamas/gambatte/blob/master/libgambatte/SConstruct https://github.com/sinamas/gambatte/blob/master/libgambatte/...
- Tyr42 10y agoI mean, if you're going to be generating it anyways, just generate ninja files. They are faster, but the downside is just that you need to generate them, as opposed to being generic.
- aeruder 10y agoMake unfortunately depends on hard-tabs for the recipes. Your editor probably switched it to spaces.
- pja 10y agoIf you cut & paste the makefile in the blogpost, you’ll discover that the blog itself has converted the tabs in the makefile to spaces. Not very helpful to any confused newbies out there!
- pja 10y agoThe tabs in the makefile have been converted to spaces by the blog-posting software. The commands for implementing rules are always indented by a tab. This is a classic makefile newbie make gotcha & everyone gets bitten by it at some point or other.
- steveklabnik 10y agoI recently tried to improve this error, but it looks like the maintainers aren't interested: https://savannah.gnu.org/bugs/index.php?48276 https://savannah.gnu.org/bugs/index.php?48276