Build system doesn't follow best practises
This issue is related to https://github.com/MayaPosch/NymphCast/issues/90. I personally believe that all of the issues below could be easily solved by using an alternative build system such as Meson instead of Make.
NymphRPC's Makefile doesn't follow Makefile best practices defined in the GNU Make manual: https://www.gnu.org/software/make/manual/make.html#Makefile-Conventions
Problems caused by this
- cross compilation is impossible
- using custom compilers such as
clang++is impossible - NymphRPC cannot build on distributions/build environments which distribute dependencies in nonstandard ways (I have verified that NymphRPC is not buildable under Nix, I assume that it isn't buildable under GNU Guix and other systems too)
- NymphRPC hardcodes a lot of programs (which can again causes problems on Nix, GNU Guix...)
- ~
taris hardcoded, making it impossible to use other compatible archivers (bsdtar etc.)~ -
installis hardcoded, which directly violates recommendations of the GNU Make manual - and there are more hardcoded utilities
- ~
-
CXXFLAGSare ignored even thoughCFLAGShave special handling, which is peculiar for a C++-only project - user supplied
CFLAGSaren't placed last inCFLAGS(or even close to the end), which directly violates GNU Make manual's recommendations - these and other choices made in the Makefile severely hinder portability of NymphRPC, because a lot of platform dependent assumptions are made and there is no way to externally override them
Recommended course of action
- use compiler (
$CXX) from the environment instead of hardcodingg++- some platform dependent code will require further consideration if this change is implemented, like this block
- follow advice from Variables for Specifying Commands and make
tar,install,g++,arand possibly more configurable from the environment - ignore
CFLAGSand inheritCXXFLAGSfrom the environment instead - put user defined
CXXFLAGSafter all hardcoded flags (or at least near the end behind-O0and-g3)
I could whip up some PR which would fix these problems, but I don't think I have the capacity to fully test the build system, because NymphRPC seems to target many platforms.
The Makefile was switched to the use of CXX with preference for an environment variable and the use of CXXFLAGS.
Thanks for addressing this issue. I still have my WIP Makefile changes in my local checkout (I kind of forgot about this issue & there were some blockers such as #11), I could make a PR from it.