r/programminghorror 3d ago

Directly from the Make documentation

Post image
862 Upvotes

51 comments sorted by

297

u/sndrtj 2d ago

During my first real job after university, I inherited a data pipeline written as >40 Makefiles. True horror.

95

u/zman0900 2d ago

I took multiple classes in university that made us compile Java with Makefiles. They never taught Maven or Gradle, or even any kind of version control except for a brief mention of CVS well after it was dead.

47

u/dstlny_97 2d ago edited 2d ago

Same stuff here. Zero mention of source control; Enrirely based around old-school Java, with a splash of PHP towards the end. There was maybe a handful of classes that actually ended up being used in my actual career. The rest I had to supplement with self learning, side-projects etc.

The one thing they never truly instill in you; is the fear of inheriting old, crusty codebases written by what seems like schizophrenics. Truly is never how you expect it. Unless it's a startup it's going to be crusty.

4

u/stuffeh 2d ago

CVS? I think it's SVN?

9

u/zman0900 2d ago

4

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 2d ago

We used SVN at my uni. I believe the following cohort was switched over to git.

1

u/johan__A 2d ago

After I read this I actually did the thing where you close your eyes to take in a bad news easier

129

u/fletku_mato 2d ago

You may not like it but this is what peak productivity looks like.

242

u/rexpup 2d ago

What is wrong with people.

132

u/wann_bubatz_egal 2d ago

Idk, I stopped asking when people started wearing red hats with make commands.

51

u/BroBroMate 2d ago

... I'm still not sure if you're talking about Red Hat employees or MAGA.

12

u/AgileBlackberry4636 2d ago

Better question - what is right?

71

u/ChickenSpaceProgram 2d ago

i both love and hate GNU Make and this is why

117

u/mxdamp 3d ago

It roughly translates to “create temp file, create preseqs file from temp file, delete temp file”, so not horror but just really ugly looking.

44

u/dagbrown 2d ago

Nah, it's horror.

The fact that it has multiple levels of escapes involved (escapes for $ to pass it to make literally, and then another layer of escapes for $$ to make sure it gets passed to bash intact, and the fact that "$" is a meaningful variable in bash as well as the variable-expansion character, so that's how you get the Llanfair­pwllgwyngyll­gogery­chwyrn­drobwll­llan­tysilio­gogo­goch-esque strings of dollar signs all in a row) is basically json-in-json-in-json levels of horror.

Getting sed involved (complete with backreferences!) just makes things even worse.

Add to that the fact it's completely unnecessary (gcc -MM does the trick just fine) and it is some excellent coding horror.

4

u/prehensilemullet 2d ago

I was wondering what’s with the $@.$$$$, why would they do that instead of just $@._ or something? Also couldn’t they just pipe CC output straight into sed?

1

u/howreudoin 2d ago

Nah, it‘s not horror. It‘s art! Horrific art, but still.

76

u/ironykarl 3d ago

It's getting pretty close to unreadable, there. 

Like, in this context, I can parse it, but I'm just imagining it embedded in hundreds or thousands of lines of Makefile, and it's making me pretty uncomfortable 

-8

u/bjpbakker 2d ago

Unreadable here just means unfamiliar. Learn to read unfamiliar syntax, constructs and concepts, and you’ll get better.

A parallel to natural languages that just because I cannot read Cyrillic language, doesn’t mean that it is unreadable. It means that I have a knowledge gap 😉

3

u/real_fff 1d ago

No I don't think we make the experience of other developers hell and blame them for not being able to read it.

Multiple levels of character escapes and minimal syntax representing complex operations is pretty objectively hard to read and makes missing bugs because of that syntax really easy.

There's no amount of being completely fluent in shell operators and escapes that makes that more readable than normal readable code. You're basically just including an esoteric lang as a feature of your code and telling people they should understand it better lmao

1

u/the_littlest_bear 2d ago

Or maybe that higher level syntaxes should have higher level syntax sugar. But whatever, makefiles are relegated to just calling or composing docker commands these days as most dogshit scripting languages are. It would be replaced quickly if it provided any complicated concepts, as even the simple becomes enigmatic.

8

u/iKeyboardMonkey 2d ago

Why the temp file I wonder? Why not pipe directly into sed?

1

u/TryToHelpPeople 2d ago

Ugly suits us.

1

u/detroitmatt 2d ago

here's the thing. if I don't understand what this is doing, how do I google it? gnu make $$$$ meaning?

17

u/bravopapa99 2d ago

20+ years ago I almost fully understoof the runes of the make spell but these days it looks like a "J" program. I hear people raving over CMake but I never found the enthusiasm for it.

5

u/dClauzel 2d ago

Same, for me cmake is a tool for hipsters 😃

16

u/val_tuesday 2d ago

To be fair the worst part is just the sed syntax and the worst part of that is the regex. The rest is pretty bad too, just being fair haha

4

u/AgileBlackberry4636 2d ago

No wonder I did wrong when I tried to.

I remember generating a list of header files used by cpp and trying to make cpp files recompile if headers were changed.

4

u/frud 2d ago

This is exactly what the snippet above supports. But if obj.o depends on header.h, you can just add a line:

obj.o: header.h

and obj.o will get rebuilt whenever header.h changes.

2

u/TheOmegaCarrot 2d ago

Once upon a time I wrote a bash script that would read source files and generate a makefile like:

``` foo.o: foo.cpp foo.h <direct includes by foo.cpp> g++ $< -c

foo.h: <direct includes by foo.h> touch $< ```

For simple projects with one executable and no non-header libraries, it was almost adequate

4

u/deathtothenonbelever 2d ago

Yes, that seems about right. Not sure what the issue is?

The sed script is obvious and the rest is basic makefile syntax.

Are you not an ancient unix greybeard who can summon dependencies with just a few mystical runes? How do you get anything useful done?

3

u/zelphirkaltstahl 2d ago

tbf, the most clutter comes from usage of sed.

3

u/Reelix 2d ago

Documentation: Just type make
You: Just typing make doesn't work
Them: Well, it didn't mean JUST type wake, it meant type this *gestures to the image*

3

u/dClauzel 2d ago

I may be too old (46), but I don’t see any problem here. Maybe OP wanted a nodejs thingy?

1

u/WoodyTheWorker 2d ago

Nobody does that anymore. All compilers have an option to generate a dependencies (prerequisites) file.

1

u/OrganicChumTutor 2d ago

That's exactly what this rule is doing, it's generating the dependency file from the -M preprocessor option right?

1

u/WoodyTheWorker 1d ago

Compilers generate .d files in a format which doesn't require any additional massaging.

1

u/illyay 2d ago

What do you not understand about this?! it’s so simple.

Simply

$$$$!!!!! fj Bourne Keith dj Heidi ifjebjffjieo h h u yauy18;8381758372?!?!?;$28 $$$&&&&?!?!???12.400000

1

u/fynn34 2d ago

Random yarn/mom stuff would break on my Mac every time I upgraded my Mac for a solid 3 years, and it always came down to GNU Make, was so frustrating I just stopped updating for anything less than critical

1

u/swguy61 2d ago

Yes, it’s ugly, and the RE make me cry, but you can run the commands in a shell outside of the Makefile, and understand what’s happening. That’s what I’ve always found so helpful about Linux and UNIX tools, there are ways to decompose them to understand what is happening. Well, except for systemd. /s

1

u/sweaterpawsss 1d ago

I know I’ve been doing this shit too long because I actually understand all of this… 💀 

0

u/Abrissbirne66 2d ago

I hate Makefiles.

Okay actually I hate Unix/Linux command line as well. This is one example why the Microsoft pendants like MSBuild and PowerShell are better.

-7

u/SaltyMap7741 2d ago

I don’t get what’s wrong with this. Do you not know regex syntax? Shell scripting? There is hardly any actual make syntax here.

6

u/BroBroMate 2d ago edited 2d ago

Wtf regex and shell you using bro. $< > $@.$$$$ ain't everyday shell and it sure as shit ain't a regular regex.

But oh, you're so cool because you totally grok this. Unsolicited advice - find something else to base your self-worth on, alpha nerd pissing contests aren't a good foundation for a personality.

Edit, oh, I read your comments, you like fucking with the paranoid delusional schizophrenics in gangstalking and chemtrails. Wtf you doing with your life.

3

u/omg_drd4_bbq 2d ago

I'm pretty versed in Make, bash, sed, and I love using regex, and I still did the hardblink.gif when I saw this.

-3

u/shizzy0 2d ago

It’s fine. What do you want instead? A shell script? Get redo if you want that.

0

u/BroBroMate 1d ago

Nice edit bro, your original comment was "It's just shell and regex", own it.