3 # Define NO_VISIBILITY if your compiler does not support symbol
4 # visibility in general (and the -fvisibility switch in particular).
15 uname_S
:= $(shell sh
-c
'uname -s 2>/dev/null || echo no')
18 # avoid the MinGW and Cygwin configuration sections
30 CC_OUT
=-o
# add a space
32 # Platform specific tweaks
34 ifeq ($(uname_S
),Windows
)
39 CFLAGS
= -TC
-W3
-RTC1
-Zi
-DWIN32
-D_DEBUG
-D_LIB
42 NO_VISIBILITY
=YesPlease
45 ifneq (,$(findstring CYGWIN
,$(uname_S
)))
46 NO_VISIBILITY
=YesPlease
49 ifneq (,$(findstring MINGW
,$(uname_S
)))
51 NO_VISIBILITY
=YesPlease
52 SPARSE_FLAGS
=-Wno-one-bit-signed-bitfield
57 SRC_C
= $(wildcard src
/*.c
)
58 OS_SRC
= $(wildcard src
/$(OS
)/*.c
)
59 SRC_C
+= $(OS_SRC
) $(EXTRA_SRC
)
60 OBJS
= $(patsubst %.c
,%.o
,$(SRC_C
)) $(EXTRA_OBJ
)
61 HDRS
= $(wildcard src
/*.h
)
62 PUBLIC_HEADERS
= $(wildcard src
/git
/*.h
)
63 HDRS
+= $(PUBLIC_HEADERS
)
67 TEST_OBJ
= $(patsubst %.c
,%.o
,\
68 $(wildcard tests
/t
[0-9][0-9][0-9][0-9]-*.c
))
69 TEST_EXE
= $(patsubst %.o
,%.exe
,$(TEST_OBJ
))
70 TEST_RUN
= $(patsubst %.exe
,%.run
,$(TEST_EXE
))
71 TEST_VAL
= $(patsubst %.exe
,%.val
,$(TEST_EXE
))
74 EXTRA_SRC
+= src
/ppc
/sha1.c
75 EXTRA_OBJ
+= src
/ppc
/sha1ppc.o
76 EXTRA_CFLAGS
+= -DPPC_SHA1
78 EXTRA_SRC
+= src
/block-sha1
/sha1.c
83 BASIC_CFLAGS
+= -fvisibility
=hidden
86 ALL_CFLAGS
= $(CFLAGS
) $(BASIC_CFLAGS
) $(EXTRA_CFLAGS
)
94 rm -f src
/*.o src
/*/*.o
96 rm -f
*~ src
/*~ src
/*/*~
97 @
$(MAKE
) -C tests
-s
--no-print-directory
clean
98 @
$(MAKE
) -s
--no-print-directory cov-clean
101 @
$(MAKE
) -C tests
-s
--no-print-directory
clean
104 $(DOXYGEN
) api.doxygen
105 cp CONVENTIONS apidocs
/
108 @
$(MAKE
) -C tests
--no-print-directory
test
111 @
$(MAKE
) -C tests
--no-print-directory valgrind
114 cgcc
-no-compile
$(ALL_CFLAGS
) $(SPARSE_FLAGS
) $(SRC_C
)
116 install-headers
: $(PUBLIC_HEADERS
)
117 @
$(INSTALL
) -d
/tmp
/gitinc
/git
118 @for i in
$^
; do cat .HEADER
$$i > /tmp
/gitinc
/$${i
##src/}; done
120 install: $(GIT_LIB
) $(PUBLIC_HEADERS
) libgit2.
pc
121 @
$(INSTALL
) -d
$(DESTDIR
)/$(prefix)/include/git
122 @for i in
$(PUBLIC_HEADERS
); do \
123 cat .HEADER
$$i > $(DESTDIR
)/$(prefix)/include/$${i
##src/}; \
125 @
$(INSTALL
) -d
$(DESTDIR
)/$(libdir)
126 @
$(INSTALL
) $(GIT_LIB
) $(DESTDIR
)/$(libdir)/libgit2.a
127 @
$(INSTALL
) -d
$(DESTDIR
)/$(libdir)/pkgconfig
128 @
$(INSTALL
) libgit2.
pc $(DESTDIR
)/$(libdir)/pkgconfig
/libgit2.
pc
131 @
rm -f
$(DESTDIR
)/$(libdir)/libgit2.a
132 @
rm -f
$(DESTDIR
)/$(libdir)/pkgconfig
/libgit2.
pc
133 @for i in
$(PUBLIC_HEADERS
); do \
134 rm -f
$(DESTDIR
)/$(prefix)/include/$${i
##src/}; \
136 @rmdir
$(DESTDIR
)/$(prefix)/include/git
139 $(CC
) $(ALL_CFLAGS
) -c
$< $(CC_OUT
)$@
142 $(CC
) $(ALL_CFLAGS
) -c
$< $(CC_OUT
)$@
147 $(AR
) $(AR_OUT
)$(GIT_LIB
) $(OBJS
)
150 $(TEST_OBJ
) $(TEST_EXE
) $(TEST_RUN
) $(TEST_VAL
): $(GIT_LIB
)
151 @
$(MAKE
) -C tests
--no-print-directory \
154 libgit2.
pc: libgit2.
pc.in
155 sed
-e
's#@prefix@#$(prefix)#' -e
's#@libdir@#$(libdir)#' $< > $@
159 .PHONY
: test $(TEST_VAL
) $(TEST_RUN
) $(TEST_EXE
) $(TEST_OBJ
)
161 .PHONY
: install-headers
162 .PHONY
: install uninstall
165 ### Test suite coverage testing
167 .PHONY
: coverage cov-clean cov-build cov-report
169 COV_GCDA
= $(patsubst %.c
,%.gcda
,$(SRC_C
))
170 COV_GCNO
= $(patsubst %.c
,%.gcno
,$(SRC_C
))
173 @
$(MAKE
) -s
--no-print-directory
clean
174 @
$(MAKE
) --no-print-directory cov-build
175 @
$(MAKE
) --no-print-directory cov-report
178 rm -f
$(COV_GCDA
) $(COV_GCNO
) *.gcov untested
180 COV_CFLAGS
= $(CFLAGS
) -O0
-ftest-coverage
-fprofile-arcs
183 $(MAKE
) CFLAGS
="$(COV_CFLAGS)" all
184 $(MAKE
) TEST_COVERAGE
=1 test
187 @echo
"--- untested files:" | tee untested
188 @
{ for f in
$(SRC_C
); do \
189 gcda
=$$(dirname
$$f)"/"$$(basename $$f .c
)".gcda"; \
190 if
test -f
$$gcda; then \
191 gcov
-b
-p
-o
$$(dirname
$$f) $$f >/dev
/null
; \
193 echo
$$f | tee
-a untested
; \
197 @echo
"--- untested functions:" | tee
-a untested
198 @grep
'^function .* called 0' *.c.gcov \
199 | sed
-e
's/\([^:]*\)\.gcov:function \([^ ]*\) called.*/\1: \2/' \
200 | sed
-e
's|#|/|g' | tee
-a untested