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
55 SRC_C
= $(wildcard src
/*.c
)
56 OS_SRC
= $(wildcard src
/$(OS
)/*.c
)
58 OBJS
= $(patsubst %.c
,%.o
,$(SRC_C
)) $(EXTRA_OBJ
)
59 HDRS
= $(wildcard src
/*.h
)
60 PUBLIC_HEADERS
= $(wildcard src
/git
/*.h
)
61 HDRS
+= $(PUBLIC_HEADERS
)
65 TEST_OBJ
= $(patsubst %.c
,%.o
,\
66 $(wildcard tests
/t
[0-9][0-9][0-9][0-9]-*.c
))
67 TEST_EXE
= $(patsubst %.o
,%.exe
,$(TEST_OBJ
))
68 TEST_RUN
= $(patsubst %.exe
,%.run
,$(TEST_EXE
))
69 TEST_VAL
= $(patsubst %.exe
,%.val
,$(TEST_EXE
))
72 EXTRA_SRC
+= src
/ppc
/sha1.c src
/ppc
/sha1ppc.S
73 EXTRA_OBJ
+= src
/ppc
/sha1.o src
/ppc
/sha1ppc.o
74 EXTRA_CFLAGS
+= -DPPC_SHA1
76 EXTRA_SRC
+= src
/block-sha1
/sha1.c
77 EXTRA_OBJ
+= src
/block-sha1
/sha1.o
82 BASIC_CFLAGS
+= -fvisibility
=hidden
85 ALL_CFLAGS
= $(CFLAGS
) $(BASIC_CFLAGS
) $(EXTRA_CFLAGS
)
93 rm -f src
/*.o src
/*/*.o
95 rm -f
*~ src
/*~ src
/git
/*~ src
/sha1
/*~ src
/unix
/*~ src
/win32
/*~
96 @
$(MAKE
) -C tests
-s
--no-print-directory
clean
97 @
$(MAKE
) -s
--no-print-directory cov-clean
100 @
$(MAKE
) -C tests
-s
--no-print-directory
clean
103 $(DOXYGEN
) api.doxygen
104 cp CONVENTIONS apidocs
/
107 @
$(MAKE
) -C tests
--no-print-directory
test
110 @
$(MAKE
) -C tests
--no-print-directory valgrind
113 cgcc
-no-compile
$(ALL_CFLAGS
) $(SPARSE_FLAGS
) $(SRC_C
)
115 install-headers
: $(PUBLIC_HEADERS
)
116 @
$(INSTALL
) -d
/tmp
/gitinc
/git
117 @for i in
$^
; do cat .HEADER
$$i > /tmp
/gitinc
/$${i
##src/}; done
119 install: $(GIT_LIB
) $(PUBLIC_HEADERS
) libgit2.
pc
120 @
$(INSTALL
) -d
$(DESTDIR
)/$(prefix)/include/git
121 @for i in
$(PUBLIC_HEADERS
); do \
122 cat .HEADER
$$i > $(DESTDIR
)/$(prefix)/include/$${i
##src/}; \
124 @
$(INSTALL
) -d
$(DESTDIR
)/$(libdir)
125 @
$(INSTALL
) $(GIT_LIB
) $(DESTDIR
)/$(libdir)/libgit2.a
126 @
$(INSTALL
) -d
$(DESTDIR
)/$(libdir)/pkgconfig
127 @
$(INSTALL
) libgit2.
pc $(DESTDIR
)/$(libdir)/pkgconfig
/libgit2.
pc
130 @
rm -f
$(DESTDIR
)/$(libdir)/libgit2.a
131 @
rm -f
$(DESTDIR
)/$(libdir)/pkgconfig
/libgit2.
pc
132 @for i in
$(PUBLIC_HEADERS
); do \
133 rm -f
$(DESTDIR
)/$(prefix)/include/$${i
##src/}; \
135 @rmdir
$(DESTDIR
)/$(prefix)/include/git
138 $(CC
) $(ALL_CFLAGS
) -c
$< $(CC_OUT
)$@
141 $(CC
) $(ALL_CFLAGS
) -c
$< $(CC_OUT
)$@
146 $(AR
) $(AR_OUT
)$(GIT_LIB
) $(OBJS
)
149 $(TEST_OBJ
) $(TEST_EXE
) $(TEST_RUN
) $(TEST_VAL
): $(GIT_LIB
)
150 @
$(MAKE
) -C tests
--no-print-directory \
151 OS
=$(OS
) NO_OPENSSL
=$(NO_OPENSSL
) $(@F
)
153 libgit2.
pc: libgit2.
pc.in
154 sed
-e
's#@prefix@#$(prefix)#' -e
's#@libdir@#$(libdir)#' $< > $@
158 .PHONY
: test $(TEST_VAL
) $(TEST_RUN
) $(TEST_EXE
) $(TEST_OBJ
)
160 .PHONY
: install-headers
161 .PHONY
: install uninstall
164 ### Test suite coverage testing
166 .PHONY
: coverage cov-clean cov-build cov-report
168 COV_GCDA
= $(patsubst %.c
,%.gcda
,$(SRC_C
))
169 COV_GCNO
= $(patsubst %.c
,%.gcno
,$(SRC_C
))
172 @
$(MAKE
) -s
--no-print-directory
clean
173 @
$(MAKE
) --no-print-directory cov-build
174 @
$(MAKE
) --no-print-directory cov-report
177 rm -f
$(COV_GCDA
) $(COV_GCNO
) *.gcov untested
179 COV_CFLAGS
= $(CFLAGS
) -O0
-ftest-coverage
-fprofile-arcs
182 $(MAKE
) CFLAGS
="$(COV_CFLAGS)" all
183 $(MAKE
) TEST_COVERAGE
=1 NO_OPENSSL
=$(NO_OPENSSL
) test
186 @echo
"--- untested files:" | tee untested
187 @
{ for f in
$(SRC_C
); do \
188 gcda
=$$(dirname
$$f)"/"$$(basename $$f .c
)".gcda"; \
189 if
test -f
$$gcda; then \
190 gcov
-b
-p
-o
$$(dirname
$$f) $$f >/dev
/null
; \
192 echo
$$f | tee
-a untested
; \
196 @echo
"--- untested functions:" | tee
-a untested
197 @grep
'^function .* called 0' *.c.gcov \
198 | sed
-e
's/\([^:]*\)\.gcov:function \([^ ]*\) called.*/\1: \2/' \
199 | sed
-e
's|#|/|g' | tee
-a untested