On 2018-03-15 15:42 +0000, Wookey wrote:
On 2018-03-15 15:21 +0000, Mike Leach wrote:
Strictly speaking, the current version of OpenCSD is 0.8.1 (as of 26/01/2018), so when any patches for adjusting makefiles for packaging purposes are added in, then the release number will increment to 0.8.2.
Right. I'll update to 0.8.1 so at least my patches are uptodate. I started with 0.8.0 because something pointed me at it when I started, but there is no good reason for that SFAIK.
So you are OK with the idea that release versioning from here in will follow the GNU library compitibility rules, and thus we can use the release number for the library versioning, right? I thnk that's sensible.
OK. I'm working from 0.8.1 now.
I put in some slightly scary make/shell to fish the version numbers out of the version header file, so that it doesn't need maintaining in two places.
The whole updated soname patch is attached, but this is the changed bit: Index: libopencsd-0.8.1/decoder/build/linux/makefile =================================================================== --- libopencsd-0.8.1.orig/decoder/build/linux/makefile +++ libopencsd-0.8.1/decoder/build/linux/makefile @@ -104,6 +104,14 @@ export LIB_TARGET_DIR=$(OCSD_LIB_ROOT)/$ export LIB_TEST_TARGET_DIR=$(OCSD_TESTS)/lib/$(PLAT_DIR) export BIN_TEST_TARGET_DIR=$(OCSD_TESTS)/bin/$(PLAT_DIR)
+# Fish version out of header file (converting from hex) +getver:=printf "%d" $$(awk '/#define VARNAME/ { print $$3 }' $(OCSD_ROOT)/include/ocsd_if_version.h) +export SO_MAJOR_VER := $(shell $(subst VARNAME,OCSD_VER_MAJOR,$(getver))) +SO_MINOR_VER := $(shell $(subst VARNAME,OCSD_VER_MINOR,$(getver))) +SO_PATCH_VER := $(shell $(subst VARNAME,OCSD_VER_PATCH,$(getver))) +export SO_VER := $(SO_MAJOR_VER).$(SO_MINOR_VER).$(SO_PATCH_VER) + + ########################################################### # build targets
This is trickier than one would like because the numbers in the header file are C defines in hex (0x0), and need converting to unadorned decimal.
There are probably various ways of doing this. Above is the neatest I could come up with, but it's still a bit cryptic due to nestedness, escaping, and putting it into a function to avoid repeating it 3 times (and it took me a while to get right). So I'll explain.
awk '/#define OCSD_VER_MAJOR/ { print $3 }' $(OCSD_ROOT)/include/ocsd_if_version.h pulls the '0x0' number out of the file. printf "%d" 0x0 turns it into decimal. I can't see a way to pipe this, so two shell substitutions are used: awk reult into print command and print command into SO_ variable.
When the awk bit is put into a subshell the # needs escaping otherwise rest of line turns into a comment (and terminating bracket gets lost) Both the subshell call '$(' and the '$3' need the dollars escaping because this is make.
It's a bit ugly to repeat 3 times for different defines, so I put it in a 'getver' fn, then used $(subst to replace VARNAME for each define.
Wookey