Remove unused variable prefix
[git-cheetah/kirill.git] / common / Makefile
blob282cc276fe4552001d310e18937e0379a78a6239
1 ifneq (,$(W64))
2 cross = /src/mingw-w64/sysroot/bin/x86_64-w64-mingw32-
3 CC = $(cross)gcc.exe
4 endif
6 MODULES=debug.c exec.c menuengine.c cheetahmenu.c date.c \
7 sha1_file.c strbuf.c usage.c wrapper.c
8 OBJECTS=${MODULES:%.c=%.o} version.h
10 # transform descriptions of the form v1.0-124-g12345 into 1,0
11 # regex to limit the number of groups to four
12 UPTO_FOUR_WORDS=\([0-9]*\),\([0-9]*\),\([0-9]*\),\([0-9]*\).*
14 # sed args to transform 0.1.2.3.4 to 0,1,2,3
15 SED_REPLACE=-e 's/\./,/g' \
16 -e 's/$(UPTO_FOUR_WORDS)/\1,\2,\3,\4/' \
17 -e 's/\(.*\),$$/\1/'
19 DESCRIBE=$(shell git describe)
20 ifeq ($(DESCRIBE),)
21 VERSION="0,0,0,0"
22 else
23 VERSION=$(shell echo $(DESCRIBE) | \
24 sed -e 's/v\([0-9.]*\).*/\1/' \
25 $(SED_REPLACE))
26 endif
28 # transform git version of the form 1.6.4.msysgit.0.597.gcd48 into 1,0
29 GIT_VERSION_STR=$(shell git version)
30 ifeq ($(GIT_VERSION_STR),)
31 GIT_VERSION="0,0,0,0"
32 else
33 GIT_VERSION=$(shell echo $(GIT_VERSION_STR) | \
34 sed -e 's/git version \([0-9.]*\).*/\1/' \
35 $(SED_REPLACE))
36 endif
38 all: $(OBJECTS)
40 %.o : %.c
41 $(CC) $(CFLAGS) $< -c -o $@
43 deps: $(MODULES)
44 $(CC) $(CFLAGS) -MM $(MODULES) > deps
46 -include deps
48 clean:
49 -rm -f $(OBJECTS) deps
51 .PHONY: version.h
52 version.h:
53 # make sure that there are exactly 4 numbers, separated by commas
54 # otherwise you'll receive "windres.exe: cheetah.rc:68: syntax error"
55 @case "$(VERSION)" in \
56 *,*,*,*) VERSION=$(VERSION) ;; \
57 *,*,*) VERSION=$(VERSION),0 ;; \
58 *,*) VERSION=$(VERSION),0,0 ;; \
59 *) VERSION=$(VERSION),0,0,0 ;; \
60 esac ; \
61 case "$(GIT_VERSION)" in \
62 *,*,*,*) GIT_VERSION=$(GIT_VERSION) ;; \
63 *,*,*) GIT_VERSION=$(GIT_VERSION),0 ;; \
64 *,*) GIT_VERSION=$(GIT_VERSION),0,0 ;; \
65 *) GIT_VERSION=$(GIT_VERSION),0,0,0 ;; \
66 esac ; \
67 sed -e "s/@@GIT_CHEETAH_VERSION@@/$$VERSION/" \
68 -e "s/@@GIT_CHEETAH_COMMENTS@@/$(DESCRIBE)/" \
69 -e "s/@@GIT_VERSION@@/$$GIT_VERSION/" \
70 -e "s/@@GIT_VERSION_COMMENTS@@/$(GIT_VERSION_STR)/" \
71 version.in > version.h