Any qmake experts out there?

Lubomir I. Ivanov neolit123 at gmail.com
Thu Jan 29 08:21:53 PST 2015


On 29 January 2015 at 16:20, Jef Driesen <jef at libdivecomputer.org> wrote:
> FORCE:
> $(top_srcdir)/revision: FORCE
>         @if (test -d $(top_srcdir)/.git && cd $(top_srcdir) \
>              && git rev-parse --verify HEAD) > revision-t 2>/dev/null \
>           && ! cmp -s revision-t $@; then \
>           mv -f revision-t $@; \
>         else \
>           rm -f revision-t; \
>           if ! test -f $@; then touch $@; fi; \
>         fi
>

here is my very simple take on the the different scenarios:
- not having .git
- git command is not installed
- version.h does not exists even if tarballed (if so fill it it a
hardcoded version)

---------------
DEFAULT_VERSION=4.4

GIT_ERROR=0
GIT_DIR_ERROR=$(shell ls .git 2> /dev/null)
GIT_CMD_ERROR=$(shell git --version 2> /dev/null)
ifeq ($(GIT_DIR_ERROR),)
    GIT_ERROR=1
endif
ifeq ($(GIT_CMD_ERROR),)
    GIT_ERROR=1
endif

all: main.exe

.PHONY: persist

version.h: persist
    ifeq ($(GIT_ERROR),0)
        @echo GIT OK
        cat $@ 2> /dev/null || git rev-parse HEAD > $@
        git rev-parse HEAD > $@.tmp
        diff -q $@ $@.tmp || cp $@.tmp $@
        rm -f $@.tmp
else
        @echo GIT ERROR
        cat $@ 2> /dev/null || echo $(DEFAULT_VERSION) > $@
endif

main.o: main.c version.h
    gcc -c main.c -o main.o

main.exe: main.o
    gcc main.o -o main.exe
---------------

i'm not using "if, then;, fi" inside the rule, because never go these
to work with my MSYS /bin/sh and MINGW's make.

lubomir
--


More information about the subsurface mailing list