diff options
author | Freeyorp <TheFreeYorp+git@gmail.com> | 2024-06-05 13:27:51 +0000 |
---|---|---|
committer | Freeyorp <TheFreeYorp+git@gmail.com> | 2024-06-05 19:09:16 +0000 |
commit | 2ff7077ab900cca73e6dc3a256a67caff5d447f8 (patch) | |
tree | cf42e02fc469a624ff415427d58d9d1dfaf07907 | |
parent | 0bba87a4851ac1e0aae059802bf6d739f8123bd9 (diff) | |
download | tmwa-2ff7077ab900cca73e6dc3a256a67caff5d447f8.tar.gz tmwa-2ff7077ab900cca73e6dc3a256a67caff5d447f8.tar.bz2 tmwa-2ff7077ab900cca73e6dc3a256a67caff5d447f8.tar.xz tmwa-2ff7077ab900cca73e6dc3a256a67caff5d447f8.zip |
Generate {install,version}.hpp through attoconf
Or more specifically, in the attoconf buildchain. attoconf itself directly
generates src/conf/install.hpp alongside Makefile, but version inforation
is only available later.
To generate version.hpp, I extended version.mk slightly to provide the recipe.
It's not anywhere near as generic as real.make tends to be, but with any luck
we'll soon be doing all builds through cmake going forward.
The template for install.hpp has been changed to use variables actually
provided by attoconf. PACKAGE{SYSCONF,LOCALSTATE}DIR are actually only defined
in real.make, and then only in terms of SYSCONFDIR and LOCALSTATEDIR, adding
`/tmwa`. It's simpler to just use the attoconf variable and adjust the
template, which conveniently also simplifies the construction in
CMakeLists.txt, too.
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rw-r--r-- | Makefile.in | 1 | ||||
-rwxr-xr-x | configure | 4 | ||||
-rw-r--r-- | src/conf/install.hpp.in | 4 | ||||
-rw-r--r-- | version.mk | 23 |
5 files changed, 31 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index dd99bf2..5981636 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,8 +98,8 @@ set(VERSION_DOTS "${PROJECT_VERSION}.${VENDOR_POINT}") include(GNUInstallDirs) set(PACKAGEDATADIR "${CMAKE_INSTALL_FULL_DATAROOTDIR}/tmwa") -set(PACKAGELOCALSTATEDIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/tmwa") -set(PACKAGESYSCONFDIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/tmwa") +set(LOCALSTATEDIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}") +set(SYSCONFDIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}") # Generate the install.hpp and version.hpp files in the source directory. # TODO: Is there a nicer way to handle this so we're still able to make fully diff --git a/Makefile.in b/Makefile.in index 75f91f7..df8a2df 100644 --- a/Makefile.in +++ b/Makefile.in @@ -386,6 +386,7 @@ vpath include/%.hpp ${SRC_DIR} vpath src/%.tcc ${SRC_DIR} vpath tools/% ${SRC_DIR} vpath src/%.py ${SRC_DIR} +vpath src/%.in ${SRC_DIR} .DELETE_ON_ERROR: .DEFAULT_GOAL := all @@ -112,7 +112,9 @@ def main(): srcdir = os.path.dirname(sys.argv[0]) proj = Configuration( srcdir=srcdir, - template_files=['Makefile'], + # Note that src/conf/version.hpp is made later, by Makefile. + # See version.mk (included by Makefile). + template_files=['Makefile', 'src/conf/install.hpp'], ) proj.set_package('tmwa', 'The Mana World (Athena server)'); proj.jiggle() diff --git a/src/conf/install.hpp.in b/src/conf/install.hpp.in index c44f026..e63164a 100644 --- a/src/conf/install.hpp.in +++ b/src/conf/install.hpp.in @@ -20,8 +20,8 @@ // just mention "fwd.hpp" to make formatter happy -#define PACKAGESYSCONFDIR "@PACKAGESYSCONFDIR@"_s -#define PACKAGELOCALSTATEDIR "@PACKAGELOCALSTATEDIR@"_s +#define PACKAGESYSCONFDIR "@SYSCONFDIR@/tmwa"_s +#define PACKAGELOCALSTATEDIR "@LOCALSTATEDIR@/tmwa"_s #define PACKAGEDATADIR "@PACKAGEDATADIR@"_s namespace tmwa @@ -50,6 +50,29 @@ SO_SHORT := so.${ABI_VERSION} SO_LONG := ${SO_SHORT}.${VERSION_DOTS} # and thanks for all the fish +# Fully generate version.hpp here, where we have all the relevant information. +# version.mk is included by the top level Makefile, so simply explaning how to +# make it here will let it be built later, when needed. +# Note that some variable substitutions are slightly different here to use the +# name used by standard CMake macros, such as PROJECT_VERSION_TWEAK instead of +# VERSION_DEVEL. +src/conf/version.hpp: src/conf/version.hpp.in + sed -e 's/@VERSION_FULL@/${VERSION_FULL}/g' \ + -e 's/@VERSION_HASH@/${VERSION_HASH}/g' \ + -e 's/@VERSION_STRING@/${VERSION_STRING}/g' \ + -e 's/@PROJECT_VERSION_MAJOR@/${VERSION_MAJOR}/g' \ + -e 's/@PROJECT_VERSION_MINOR@/${VERSION_MINOR}/g' \ + -e 's/@PROJECT_VERSION_PATCH@/${VERSION_PATCH}/g' \ + -e 's/@PROJECT_VERSION_TWEAK@/${VERSION_DEVEL}/g' \ + -e 's/@VENDOR_NAME@/${VENDOR_NAME}/g' \ + -e 's/@VENDOR_POINT@/${VENDOR_POINT}/g' \ + -e 's|@VENDOR_SOURCE@|${VENDOR_SOURCE}|g' \ + -e 's/@ABI_VERSION@/${ABI_VERSION}/g' \ + -e 's/@SO_SHORT@/${SO_SHORT}/g' \ + -e 's/@SO_LONG@/${SO_LONG}/g' \ + $< > $@ + + version: @echo version '${VERSION_STRING}' @echo based on commit ${VERSION_FULL} aka ${VERSION_HASH} |