From 7c80d10503545cc870c084def44c0ea4a95fd290 Mon Sep 17 00:00:00 2001 From: Freeyorp Date: Tue, 4 Jun 2024 14:16:59 +0000 Subject: Rename .make to .mk .mk is more widely understood than .make, for IDE usage. --- version.mk | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 version.mk (limited to 'version.mk') diff --git a/version.mk b/version.mk new file mode 100644 index 0000000..73ecc83 --- /dev/null +++ b/version.mk @@ -0,0 +1,58 @@ +ABI_VERSION := 0 + +# These lines are automatically replaced in tarballs generated by 'make dist' +# Note so you stop forgetting: export-subst attribute can't do tag-relative +VERSION_FULL := $(shell git --git-dir=${SRC_DIR}/.git describe --tags HEAD) +VERSION_HASH := $(shell git --git-dir=${SRC_DIR}/.git rev-parse HEAD) + +version_bits := $(subst v, ,$(subst -, ,$(subst ., ,${VERSION_FULL}))) +# Note: these four numbers are limited to 255. +# Currently, my tags are yy.mm.dd instead of semantic versioning. +# The dev number is how many commits since the last tag. +VERSION_MAJOR := $(word 1,${version_bits}) +VERSION_MINOR := $(word 2,${version_bits}) +VERSION_PATCH := $(word 3,${version_bits}) +VERSION_DEVEL := $(word 4,${version_bits}) +ifeq "${VERSION_DEVEL}" "" + VERSION_DEVEL := 0 +endif + + + +# Settings for those distributing modified versions. +# +# It is strongly recommended that all distributors set these, +# but the only *requirement* is that modified versions that are run +# (semi)publicly give VENDOR_SOURCE to satisfy section 13 of the AGPLv3. + +# TODO should these be passed to configure instead? + +# Vendor Name: String (no newlines, no parentheses) +# This is usually one word, and does not (usually) change over time. +# (Examples: Gentoo, Debian, Fedora, Ubuntu) +VENDOR_NAME := Vanilla +# Vendor Point: Integer (max value 65535) +# This is intended to be the "packaging revision number", assuming that's +# an integer. At a minimum, please try to make it nonzero if you have +# any non-upstream patches (unconditionally nonzero is also okay). +# (If your revision 0 package has patches ... please be nicer to upstream) +VENDOR_POINT := 0 +# URL where the source may be found (after searching for version number). +# See AGPLv3 section 13 +VENDOR_SOURCE := https://github.com/themanaworld/tmwa + +# Convenience +VERSION_STRING := TMWA ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} dev${VERSION_DEVEL} +${VENDOR_POINT} (${VENDOR_NAME}) +VERSION_DOTS := ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_DEVEL}.${VENDOR_POINT} + +# Shared libraries +SO_SHORT := so.${ABI_VERSION} +SO_LONG := ${SO_SHORT}.${VERSION_DOTS} +# and thanks for all the fish + +version: + @echo version '${VERSION_STRING}' + @echo based on commit ${VERSION_FULL} aka ${VERSION_HASH} + @echo source ${VENDOR_SOURCE} + @echo abi version ${ABI_VERSION} + @echo 'lib so -> ${SO_SHORT} -> ${SO_LONG}' -- cgit v1.2.3-70-g09d2 From 0bba87a4851ac1e0aae059802bf6d739f8123bd9 Mon Sep 17 00:00:00 2001 From: Freeyorp Date: Wed, 5 Jun 2024 13:18:42 +0000 Subject: VENDOR_SOURCE: github.com -> git.themanaworld.org --- CMakeLists.txt | 2 +- version.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'version.mk') diff --git a/CMakeLists.txt b/CMakeLists.txt index a0587b3..dd99bf2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,7 +90,7 @@ set(VENDOR_NAME Vanilla) set(VENDOR_POINT 0) # URL where the source may be found (after searching for version number). # See AGPLv3 section 13 -set(VENDOR_SOURCE https://github.com/themanaworld/tmwa) +set(VENDOR_SOURCE https://git.themanaworld.org/legacy/tmwa) # Convenience set(VERSION_STRING "TMWA ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} dev${PROJECT_VERSION_TWEAK} +${VENDOR_POINT} (${VENDOR_NAME})") diff --git a/version.mk b/version.mk index 73ecc83..a5137ad 100644 --- a/version.mk +++ b/version.mk @@ -39,7 +39,7 @@ VENDOR_NAME := Vanilla VENDOR_POINT := 0 # URL where the source may be found (after searching for version number). # See AGPLv3 section 13 -VENDOR_SOURCE := https://github.com/themanaworld/tmwa +VENDOR_SOURCE := https://git.themanaworld.org/legacy/tmwa # Convenience VERSION_STRING := TMWA ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} dev${VERSION_DEVEL} +${VENDOR_POINT} (${VENDOR_NAME}) -- cgit v1.2.3-70-g09d2 From 2ff7077ab900cca73e6dc3a256a67caff5d447f8 Mon Sep 17 00:00:00 2001 From: Freeyorp Date: Wed, 5 Jun 2024 13:27:51 +0000 Subject: 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. --- CMakeLists.txt | 4 ++-- Makefile.in | 1 + configure | 4 +++- src/conf/install.hpp.in | 4 ++-- version.mk | 23 +++++++++++++++++++++++ 5 files changed, 31 insertions(+), 5 deletions(-) (limited to 'version.mk') 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 diff --git a/configure b/configure index 275a9c4..7a7a9ef 100755 --- a/configure +++ b/configure @@ -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 diff --git a/version.mk b/version.mk index a5137ad..39cf181 100644 --- a/version.mk +++ b/version.mk @@ -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} -- cgit v1.2.3-70-g09d2 From 08d98f6cb2255db6c92f184ecb6efcca079f706a Mon Sep 17 00:00:00 2001 From: Freeyorp Date: Wed, 5 Jun 2024 13:30:57 +0000 Subject: version.mk: make version target PHONY --- version.mk | 1 + 1 file changed, 1 insertion(+) (limited to 'version.mk') diff --git a/version.mk b/version.mk index 39cf181..6d9a7ca 100644 --- a/version.mk +++ b/version.mk @@ -79,3 +79,4 @@ version: @echo source ${VENDOR_SOURCE} @echo abi version ${ABI_VERSION} @echo 'lib so -> ${SO_SHORT} -> ${SO_LONG}' +.PHONY: version -- cgit v1.2.3-70-g09d2 From 9c829dd8290bdf97c55487a8869018b4c7103849 Mon Sep 17 00:00:00 2001 From: Freeyorp Date: Wed, 5 Jun 2024 13:31:09 +0000 Subject: version.mk: Always generate version.hpp --- Makefile.in | 3 ++- version.mk | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'version.mk') diff --git a/Makefile.in b/Makefile.in index df8a2df..587382e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -683,7 +683,8 @@ conf-raw/bool-%.h: FORCE conf-raw/str-%.h: FORCE $(MKDIR_FIRST) @echo '#define $* "$(value $*)"_s' | maybe-replace $@ -FORCE: ; + +FORCE:: ; .PHONY: FORCE override CPPFLAGS += -I . -I ${SRC_DIR}/include diff --git a/version.mk b/version.mk index 6d9a7ca..23bd071 100644 --- a/version.mk +++ b/version.mk @@ -50,13 +50,18 @@ SO_SHORT := so.${ABI_VERSION} SO_LONG := ${SO_SHORT}.${VERSION_DOTS} # and thanks for all the fish +# This is a phony target, so that it always runs. +# Targets which depend on this will always have their recipes run. +FORCE:: ; +.PHONY: FORCE + # 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 +src/conf/version.hpp: src/conf/version.hpp.in FORCE sed -e 's/@VERSION_FULL@/${VERSION_FULL}/g' \ -e 's/@VERSION_HASH@/${VERSION_HASH}/g' \ -e 's/@VERSION_STRING@/${VERSION_STRING}/g' \ -- cgit v1.2.3-70-g09d2