News for hackers. Stuff that matters.
Re:I Like Makefiles by ReleaseCandidat on Saturday September 21, 2024 @02:30AM (#41607934)
Good luck writing Makefiles for Fortran, OCaml or (whenever they will really, actually work) C++ modules.

There aren't many widely used build systems that can handle such dynamic dependencies without some special "magic" for these, the only one that I know of (with a significant number of users, so not Shake) is Buck 2 (Bazel and all C++ build systems use "special magic", you can't write in user rules).

Re:I Like Makefiles by instig007 on Saturday September 21, 2024 @07:46AM (#41609366)
> Good luck writing Makefiles for OCaml

So what's the problem exactly? https://mmottl.github.io/ocaml-makefile/

Oh look, it even builds a project faster than Dune: https://discuss.ocaml.org/t/dune-build-vs-makefile/11394

Re:I Like Makefiles by ReleaseCandidat on Saturday September 21, 2024 @11:27AM (#41610599)
> So what's the problem exactly?

They all have the samé problem: that you don't know the name (or even the number) of modules (module files) being generated without reading the source. And as a bonus, that every compiler uses a sligthly different naming scheme for the generated mofule file (this is of course no problém for OCaml ;).

Re:I Like Makefiles by overanalytcl on Saturday September 21, 2024 @09:03AM (#41609700)
> Good luck writing Makefiles for Fortran, OCaml or (whenever they will really, actually work) C++ modules.

I've successfully written Makefiles for Fortran and they worked with ifort/ifx and gfort. In my experiments I've also made GNU Cobol, GNU Modula-2 and Vishap Oberon fit within the Makefile paradigm without much trouble. You have failed to provide reasons as to why those languages in particular (or more likely any language that's not of C heritage) can't be used with Makefiles. For instance, you can definitely couple OCaml with Makefiles, just use ocamlopt and treat .cmx files as object files, generated beforehand by ocamlopt -c (like you'd do with GCC). I am not familiar with C++ modules and as such I didn't experiment with them.

Re:I Like Makefiles by ReleaseCandidat on Saturday September 21, 2024 @11:17AM (#41610526)
> I've successfully written Makefiles for Fortran and they worked with ifort/ifx and gfort.

Did the samé (I'm not sure if gfortran did exist at all at the time, I guess it had been g95), plus they worked with Absoft, PGI and Pathscale too (yes, that has been some time ago). And it was a great PITA. Not the least because at the time no Fortran compiler did generate the dependency description, so you either had to parse the Fortran sources by yourself or use makedepf90, which didn't work with all sources.

> You have failed to provide reasons as to why those languages in particular [...] can't be used with Makefiles.

I have obviously badly worded that. I didn't mean it is impossible, just that is a great PITA.

> I am not familiar with C++ modules and as such I didn't experiment with them.

They have the same problem, you don't know the name of the module that is going to be produced.

Re:I Like Makefiles by alextingle on Saturday September 21, 2024 @10:21PM (#41614187)
I've written Makefile for FORTRAN. Dealing with modules added about 6 extra lines. That was one of the more complex rules. Does that count as "special magic"?
Re:I Like Makefiles by ReleaseCandidat on Sunday September 22, 2024 @02:51AM (#41615104)
If you've got your rule working for arbitrary named (i.e. not the name of the file) modules and submodules and an arbitrary number of modules and submodules generated by a single source file which uses FPP (whatever program that actually is ;) or CPP as preprocessor, then yes. And with "working" I mean adding each module file as a single target which is able to trigger a rebuild of the module. You should be able to get that to work easier with GNU Make 4.3 and later, as that now supports grouped targets - which I have learned elsewhere in this forum. Now the only problém is getting your module dependencies without first compiling all files to generate the modules, as `gfortran -M` (and any other compiler that generates dependency information) AFAIK still doesn't "know" which file produces which module without actually generating the module files.