Big rewrite of kos-ports' build system#165
Conversation
pcercuei
commented
Jun 23, 2026
- Ports now use a recipe.mk, that more or less contain the same as the old Makefile scripts, except that all variables are prefixed with the package's name.
- This is done so that all recipe scripts can be sourced at the same time without conflicting. This is needed so that all packages can be built in the same "make" instance without nesting instances.
- As a result, kos-ports is now fully buildable in parallel, everything is handled properly.
- The old scripts/* files are mostly gone; everything is in the top-level Makefile now.
- Lots of simplifications. SVN clone dropped, GIT clone dropped, everything is downloaded from HTTPS. This uses the fact that both gitlab and github enable downloading tarballs from a git hash.
- Downloading a tarball from a git branch is no more supported. This is because it would not allow reproductible builds.
- Custom zlib / libpng / libjpeg code moved to their own packages. This allows using the upstream cmake/autotools scripts, which will install their files properly (e.g. including the cmake scripts and the pkgconfig .pc file).
- Speaking about installing, everything is installed into a top-level sysroot/ folder. This means that regular Unix software will automatically find their dependencies through pkgconfig or cmake scripts, because the headers and libs are where they expect them to be.
- Version check is gone. Assume that the users won't downgrade from a version of kos-ports to an older version. When a package is updated to a new version, the Makefile script will automatically build the new version.
- Uninstall rule dropped. This was hacky at best.
- Support for simpler packages that don't download anything
- SHA256 hash is now stored in a variable in the recipe.mk
|
TODO:
|
bc3a24e to
d18c64d
Compare
|
Added a CI script, which will automatically build every package we have a recipe for. |
d18c64d to
5fca0b4
Compare
0c7e0b4 to
8d5bea9
Compare
|
Fixed the raylib package. I just had to use the correct git hash, lol |
|
Fixed mruby, SDL_ttf, libjimtcl and micropython. CI is all green now :) |
|
Tried to go through the different line items, it's a lot but there's a lot of change too. Fortunately almost all of the change is in stuff that should have always been mostly transparent to the user and would at worst involve users removing stuff on their side to rely on standards. So most is geared towards our own maintenance:
Regarding this while it's true and shouldn't be the norm, it would create a maintenance overhead for any port that does not follow a simple versioning scheme where we can point to a specific version. @gyrovorbis would be putting in weekly PRs to get the git hash for From what I can tell though, it works just fine within the infrastructure set up here to do this: With the exception of the rebuilding not triggering on successive makes without a clean of course.
Is there a good reason to keep
It makes sense to remove the patches, but will have to look over how it's dealt with a bit more. The biggest reason to keep such things available would be legacy support, but if they're in new packages then that kind of goes against the reason to keep them at all. For
I agree with dropping it, and mixed in with that it would seem that this would fully codify the 'build-all' behavior that the whole structure of the previous implementation was pushing against but has tended to be the norm. I'm fine with that as well, though it's something that might merit further work if we were to get to 2-3x more ports. I think I would also have a preference, as a long term goal, to support dependencies in such a way that these could merely be built on-demand rather than all at once. One thing though that I would request, despite it being much more geared towards contributors to users, would be the ability to specify the rebuilding of an individual port. |
I guess that would be OK for me as long as it does not track a master branch. @gyrovorbis could make a "stable" branch that is pulled here.
The I can move it to the top folder, no problem. I will cleanup the config.mk too.
I think adding the kos-png / kos-jpeg stuff to libimageload would make perfect sense. For zlib_getlength, honestly, I'd be in favour of dropping it and see if anybody complains :)
They can be built on-demand already; e.g.
I can add a |
d54c769 to
fa1ad08
Compare
|
Updated to use the The Makefile was updated to use per-arch build directories, so you can use one kos-ports tree for multiple KOS platforms. Finally I cleaned up setup.mk, and added |
A quick search on github had showed me that it's in use by https://github.com/ArtemioUrbina/240pTestSuite and https://github.com/Protofall/Crayon-Game-Framework/ at least. So it's not just obscure and unused unfortunately. Otherwise I would have agreed. At the very least it should be replaced in our examples (and that could happen prior to any of this going in).
That one I realized, I misstated it though as I intended to mean from the end-user application side. With all kos-ports clean, running make on a kos example for png building zlib and png. Though that's probably too many steps and not really expected by anyone. And it wouldn't be changes that would be required here but rather in tooling in the main kos repo's makefile.rules/prefab or such. One further thing that would be very useful to reduce user pain in from the update. To detect if version of kos in use has the changes in KallistiOS/KallistiOS#1458 yet, and if not to suggest either updating to |
Noted.
That should be doable pretty easily, actually. Making sure that a dependency is installed is just a matter of running
Ok, that shouldn't be too hard to do. |
Did you mean v2.2.3? |
The idea would be that the We could also try to have v2.2.3/v2.2.x ready with the updates (I do have KallistiOS/KallistiOS#1447 open and it seems quite a bit like a sufficient amount of bugs to merit a new release, though there's probably a dozen or so more commits that could be pulled in from the past week) and have kos ports update at the same time. That would reduce the impacted users to those already using stable and trying to update kos-ports rather than anyone building from the DCwiki instructions. |
c9f9579 to
9e6f41d
Compare
|
Rebased on master. |
88005e9 to
5f5ecf7
Compare
|
Force-pushed, I had to remove fbb92d7 because it caused miniaudio to fail to include |
- Ports now use a recipe.mk, that more or less contain the same as the old Makefile scripts, except that all variables are prefixed with the package's name. - This is done so that all recipe scripts can be sourced at the same time without conflicting. This is needed so that all packages can be built in the same "make" instance without nesting instances. - As a result, kos-ports is now fully buildable in parallel, everything is handled properly. - The old scripts/* files are mostly gone; everything is in the top-level Makefile now. - Lots of simplifications. SVN clone dropped, GIT clone dropped, everything is downloaded from HTTPS. This uses the fact that both gitlab and github enable downloading tarballs from a git hash. - Downloading a tarball from a git branch is no more supported. This is because it would not allow reproductible builds. - Custom zlib / libpng / libjpeg code moved to their own packages. This allows using the upstream cmake/autotools scripts, which will install their files properly (e.g. including the cmake scripts and the pkgconfig .pc file). - Speaking about installing, everything is installed into a top-level sysroot/ folder. This means that regular Unix software will automatically find their dependencies through pkgconfig or cmake scripts, because the headers and libs are where they expect them to be. - Version check is gone. Assume that the users won't downgrade from a version of kos-ports to an older version. When a package is updated to a new version, the Makefile script will automatically build the new version. - Uninstall rule dropped. This was hacky at best. - Support for simpler packages that don't download anything - SHA256 hash is now stored in a variable in the recipe.mk Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Add a CI script that will create a matrix of jobs, one per package. This will use the latest KallistiOS master along with the stable toolchain. This is extra helpful to quickly see what packages are failing and what packages build fine. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Update to the version 4.0.0. The mruby package needs host tools, so CC/RANLIB/AR are now overriden to the host compiler's tools. It also needs "rake", so install it on the CI. Drop the code to "fix" the includes. Since we use a proper sysroot now, mruby will install properly where it should be. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
And bump SDL_PORTVERSION, as autotools will typically verify the package's version against a minimal version supported. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Now that SDL installs a .pc file, it is auto-discovered by SDL_ttf. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
We don't need it, it fails linking on CI for some strange reason (complains about the LTO version of some objects), and it ICEs on recent toolchains. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Don't patch include headers, we want them to be installed where they are supposed to. One weird issue was occuring with the previous KOSMakefile.mk, is that the first object file listed in OBJS, embed_util.o, was never actually compiled but still listed as the object files to be packed in the library, causing a linking error. Address this issue by specifying that the source files, and not the object files, are generated by the embed.mk script. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
The rules in the KOSMakefile.mk did not have proper dependencies while in practice they depend on each other. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
The custom KOSMakefile.mk as well as the "$(LIB_OBJS)" mechanism were not working properly when building in parallel. Address this issue by adding a dependency on $(OBJS) to the "subdirs" rule, and populate $(OBJS) with actual object files instead of a wildcard, which cannot be evaluated before the subdirs are processed. Also remove the custom CFLAGS / CPPFLAGS. Since those were applied to object files compiled by different Makefiles in sub-folders, they were not doing anything. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Newer KallistiOS provides the ${KOS_SYSROOT} variable, use it directly.
Drop the "distclean" rule, as the sysroot is no more in kos-ports, we
delegate the responsibility to KallistiOS' scripts instead.
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Add the KOS arch (e.g. "dreamcast") as a suffix to the build folder. This will later permit building kos-ports for more than one platform without having to clean everything first. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
The packages setting the "<pkg>_ARCHS" variable in their recipe.mk will only be built when one of the strings in that variable will match the current value of $KOS_ARCH. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
These rules can be used to clean an individual package (remove its build folder), or rebuild a package. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
The CMake changes were merged there. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
It was the only script remaining inside the scripts/ folder. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Make the recipes only declare <pkg>_DOWNLOAD_URL to keep them as simple as possible. The Makefile can then get the tarball name from the URL variable. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
These repo URLs will later be used to monitor for upstream changes, so that the packages can automatically be updated to the latest version when building. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
When running 'make update-<pkg>', if this package is associated with a git repository, the Makefile script will fetch the commit ID of the latest version available, and will append it to the version_override.mk file present on the top directory. The 'make update' does the same but for all packages associated with a git repository. The Makefile will then source the version_override.mk file if present, to override the version information set in the recipes. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
When running "make" or "make all", auto-update all the packages tracking a git repository to the latest commit from these repositories. Running "make stable" will instead build all the packages without updating them to the latest version available, and instead using the known-good commit hash specified in the package's recipe. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
When the set of parameters passed to ./configure changes, which can happen when kos-ports is updated, and a cache file is used, autotool can fail. Therefore it makes sense to add the cache file to the list of the files removed in the 'distclean' rule. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
CMAKE_INSTALL_LIBDIR=lib is already the default so it does not need to be overriden. Set BUILD_SHARED_LIBS to OFF since we never want to generate shared libraries. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
libmodplug expects the headers to be included as <libmodplug/*.h>, so the HDR_INSTDIR variable in the recipe was wrong. Build and install a pkg-config .pc file, so that client applications can find libmodplug. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
miniaudio_GIT_BRANCH was not set properly to the branch that was tracked in the old kos-ports. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Convert the newly added lftpd package to the recipe file used with the new version of kos-ports. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
5f5ecf7 to
7c0ec8c
Compare
|
Rebased + wrote a recipe file for the new lftpd package. |