PDP-10 / klh10

Community maintained version of Kenneth L. Harrenstien's PDP-10 emulator.
Other
59 stars 8 forks source link

"make" compiles targets three times #57

Closed bictorv closed 3 years ago

bictorv commented 3 years ago

If you e.g. do "make base-ks-its", it would suffice to create kn10-ks-its once, but the Makefile created by mk/bld.mk repeats the "make base-ks-its" in all subdirectories, i.e. in bld-kl, bld-ks, and in bld-ks-its.

It would seem more reasonable to only do "make base-kl" in bld-kl, "make base-ks" in bld-ks, and "make base-ks-its" in bld-ks-its. Saves time, at least.

Rhialto commented 3 years ago

Yeah, the makefile just recurses to all subdirectories with the same target that you give it. It is basically set up for targets like "all" or "clean".

In each subdirectory the Makefile is tuned for the target that is supposed to be built there, by concatenating some fragments. From configure.ac:

 # -------------------------------------------------------------------------
# Output section. State which files are going to be constructed.
# -------------------------------------------------------------------------

AC_CONFIG_FILES([bld-kl/Makefile:mk/top.mk:mk/top-kl.mk:src/Makefile.mk
                 bld-ks/Makefile:mk/top.mk:mk/top-ks.mk:src/Makefile.mk
                 bld-ks-its/Makefile:mk/top.mk:mk/top-ks-its.mk:src/Makefile.mk
                 Makefile:mk/bld.mk
                ])

Maybe the bld-*/Makefiles can be set up such that only the "intended" targets work and others do nothing or fail. Maybe it can be done by splitting / recombining the Makefiles in a different way.

Rhialto commented 3 years ago

Another strategy could be to add extra targets to the top Makefile. For example, make base-ks-its could cd ks-its; make base-ks-its. But then you would need to add a LOT of targets to make things regular. What if you wanted to do a "make clean" in just one directory? make ks-its-clean is ugly. For the majority of cases, make -C ks-its clean would make more sense.

Which you can do now already, of course: make -C ks-its. It is even shorter than make base-ks-its. (Oops, it is bld-ks-its and then it isn't shorter any more)

bictorv commented 3 years ago

I'm no Makefile wizard, but maybe it suffices to move the base-ks-its, base-ks, base-kl (and lint-X) from Makefile.mk to top-ks-its.mk, top-ks.mk, top-kl.mk? (And perhaps empty rules for the "mismatched" targets in each top-X.mk?) Then recursion would still work, right?

Rhialto commented 3 years ago

Yes I'm moving stuff around like that. See merge request #58.

While doing it, I started to wonder why you're using the base-ks-its target in the first place. It's probably because the Makefile tells you to do that since forever. And since, so far, I kept src/Makefile.mk relatively untouched, it still tells you that.

But the target is a kind of weird one, since it does another recursive make, and it overrides all the configuration variables, with potentially different values. They seem to be the same as the defaults, but I only checked once (not three times).

The default all target builds (more or less) the same things, with the intended options.

So actually I'd like to propose to remove those base-* targets and all references to them. Or at least make them equivalent to the default all target, without the extra indirection.

bictorv commented 3 years ago

I've used base-ks-its (and base-kl) since forever (the previous millenium for base-kl), and while I have some understanding for the seeing it as weird, I don't see a big point in changing it? But if you do, please make it backwards compatible, of course, and update the docs as necessary.

Rhialto commented 3 years ago

Ok, that would be option 2. I'll make a separate branch so you can see what it would look like.

Rhialto commented 3 years ago

@bictorv Can you have a look at branch rhialto/remove-some-old-build-stuff or merge request #59 ? I think it should fit with your use of your favourite make targets, but in addition to that I have removed them from the documentation and also removed the remains of the old build system in the "old" directory.