[PATCH] Generate/update a version.h header file.

Dirk Hohndel dirk at hohndel.org
Tue Feb 26 09:35:59 PST 2013


"Lubomir I. Ivanov" <neolit123 at gmail.com> writes:
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -25,6 +25,12 @@ DESKTOPFILE = $(NAME).desktop
>>  MANFILES = $(NAME).1
>>  XSLTFILES = xslt/*.xslt
>>
>> +VERSION_FILE = version.h
>> +# There's only one line in $(VERSION_FILE); use the shell builtin `read'
>> +STORED_VERSION_STRING = \
>> +       $(subst ",,$(shell read ignore ignore v <$(VERSION_FILE) && echo $$v))
>> +#" workaround editor syntax highlighting quirk
>> +
>>  UNAME := $(shell $(CC) -dumpmachine 2>&1 | grep -E -o "linux|darwin|win")
>>  GET_VERSION = ./scripts/get-version
>>  VERSION_STRING := $(shell $(GET_VERSION) linux || echo "v$(VERSION)")
>> @@ -157,7 +163,13 @@ OBJS =     main.o dive.o time.o profile.o info.o equipment.o divelist.o deco.o plann
>>
>
> sorry, this a on a quick look....does it handle the "not in a git
> repository" case (e.g. tarballs) ?
> my attempt also handled the "no tags" case via "No names found" string check.

Yes, we should have a fallback for no git, and the fallback should be
the version that is in the Makefile
>>
>>  clean:
>> -       rm -f $(OBJS) *~ $(NAME) $(NAME).exe po/*~ po/subsurface-new.pot
>> +       rm -f $(OBJS) *~ $(NAME) $(NAME).exe po/*~ po/subsurface-new.pot \
>> +               $(VERSION_FILE)
>>         rm -rf share .dep
>
> a potential problem at "clean".
> we may want to keep the version file in case of tarball distributions,
> so it should not be deleted, but simply overridden i'd think.
> this way the tarball will come with a version that will not depend on
> git and the Makefile should not change it.
> or do i miss something here?

No, I think the version.h should not be distributed in the tar file -
it's not part of the git repository, either (because every time you were
to add it to the repository, adding it would change the SHA... then
it would change the next time you run make... and then re-add
it... lather, rinse, repeat...)

/D


More information about the subsurface mailing list