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