3 # Define NO_VISIBILITY if your compiler does not support symbol
4 # visibility in general (and the -fvisibility switch in particular).
6 # Define OPENSSL_SHA1 if you want use the SHA1 routines from the
7 # OpenSSL crypto library, rather than the built-in C versions.
9 # Define PPC_SHA1 if you want to use the bundled SHA1 routines that
10 # are optimized for PowerPC, rather than the built-in C versions.
21 uname_S
:= $(shell sh
-c
'uname -s 2>/dev/null || echo no')
24 # avoid the MinGW and Cygwin configuration sections
28 CFLAGS
= -g
-O2
-Wall
-Wextra
36 CC_OUT
=-o
# add a space
38 # Platform specific tweaks
40 ifeq ($(uname_S
),Windows
)
45 CFLAGS
= -TC
-W4
-RTC1
-Zi
-DWIN32
-D_DEBUG
-D_LIB
48 NO_VISIBILITY
=YesPlease
51 ifneq (,$(findstring CYGWIN
,$(uname_S
)))
52 NO_VISIBILITY
=YesPlease
55 ifneq (,$(findstring MINGW
,$(uname_S
)))
57 NO_VISIBILITY
=YesPlease
58 SPARSE_FLAGS
=-Wno-one-bit-signed-bitfield
63 SRC_C
= $(wildcard src
/*.c
)
64 OS_SRC
= $(wildcard src
/$(OS
)/*.c
)
65 SRC_C
+= $(OS_SRC
) $(EXTRA_SRC
)
66 OBJS
= $(patsubst %.c
,%.o
,$(SRC_C
)) $(EXTRA_OBJ
)
67 HDRS
= $(wildcard src
/*.h
)
68 PUBLIC_HEADERS
= $(wildcard src
/git
/*.h
)
69 HDRS
+= $(PUBLIC_HEADERS
)
73 TEST_OBJ
= $(patsubst %.c
,%.o
,\
74 $(wildcard tests
/t
[0-9][0-9][0-9][0-9]-*.c
))
75 TEST_EXE
= $(patsubst %.o
,%.exe
,$(TEST_OBJ
))
76 TEST_RUN
= $(patsubst %.exe
,%.run
,$(TEST_EXE
))
77 TEST_VAL
= $(patsubst %.exe
,%.val
,$(TEST_EXE
))
80 EXTRA_SRC
+= src
/ppc
/sha1.c
81 EXTRA_OBJ
+= src
/ppc
/sha1ppc.o
82 EXTRA_CFLAGS
+= -DPPC_SHA1
85 EXTRA_CFLAGS
+= -DOPENSSL_SHA1
87 EXTRA_SRC
+= src
/block-sha1
/sha1.c
93 BASIC_CFLAGS
+= -fvisibility
=hidden
96 ALL_CFLAGS
= $(CFLAGS
) $(BASIC_CFLAGS
) $(EXTRA_CFLAGS
)
104 rm -f src
/*.
[oi
] src
/*/*.
[oi
]
106 rm -f
*~ src
/*~ src
/*/*~
107 @
$(MAKE
) -C tests
-s
--no-print-directory
clean
108 @
$(MAKE
) -s
--no-print-directory cov-clean
111 @
$(MAKE
) -C tests
-s
--no-print-directory
clean
114 $(DOXYGEN
) api.doxygen
115 cp CONVENTIONS apidocs
/
118 @
$(MAKE
) -C tests
--no-print-directory
test
121 @
$(MAKE
) -C tests
--no-print-directory valgrind
124 cgcc
-no-compile
$(ALL_CFLAGS
) $(SPARSE_FLAGS
) $(SRC_C
)
126 install-headers
: $(PUBLIC_HEADERS
)
127 @
$(INSTALL
) -d
/tmp
/gitinc
/git
128 @for i in
$^
; do cat .HEADER
$$i > /tmp
/gitinc
/$${i
##src/}; done
130 install: $(GIT_LIB
) $(PUBLIC_HEADERS
) libgit2.
pc
131 @
$(INSTALL
) -d
$(DESTDIR
)/$(prefix)/include/git
132 @for i in
$(PUBLIC_HEADERS
); do \
133 cat .HEADER
$$i > $(DESTDIR
)/$(prefix)/include/$${i
##src/}; \
135 @
$(INSTALL
) -d
$(DESTDIR
)/$(libdir)
136 @
$(INSTALL
) $(GIT_LIB
) $(DESTDIR
)/$(libdir)/libgit2.a
137 @
$(INSTALL
) -d
$(DESTDIR
)/$(libdir)/pkgconfig
138 @
$(INSTALL
) libgit2.
pc $(DESTDIR
)/$(libdir)/pkgconfig
/libgit2.
pc
141 @
rm -f
$(DESTDIR
)/$(libdir)/libgit2.a
142 @
rm -f
$(DESTDIR
)/$(libdir)/pkgconfig
/libgit2.
pc
143 @for i in
$(PUBLIC_HEADERS
); do \
144 rm -f
$(DESTDIR
)/$(prefix)/include/$${i
##src/}; \
146 @rmdir
$(DESTDIR
)/$(prefix)/include/git
149 $(CC
) $(ALL_CFLAGS
) -c
$< $(CC_OUT
)$@
152 $(CC
) $(ALL_CFLAGS
) -c
$< $(CC_OUT
)$@
155 $(CC
) $(ALL_CFLAGS
) -E
$< >$*.i
160 $(AR
) $(AR_OUT
)$(GIT_LIB
) $(OBJS
)
163 $(TEST_OBJ
) $(TEST_EXE
) $(TEST_RUN
) $(TEST_VAL
): $(GIT_LIB
)
164 @
$(MAKE
) -C tests
--no-print-directory \
167 libgit2.
pc: libgit2.
pc.in
168 sed
-e
's#@prefix@#$(prefix)#' -e
's#@libdir@#$(libdir)#' $< > $@
172 .PHONY
: test $(TEST_VAL
) $(TEST_RUN
) $(TEST_EXE
) $(TEST_OBJ
)
174 .PHONY
: install-headers
175 .PHONY
: install uninstall
179 ### Test suite coverage testing
181 .PHONY
: coverage cov-clean cov-build cov-report
183 COV_GCDA
= $(patsubst %.c
,%.gcda
,$(SRC_C
))
184 COV_GCNO
= $(patsubst %.c
,%.gcno
,$(SRC_C
))
187 @
$(MAKE
) -s
--no-print-directory
clean
188 @
$(MAKE
) --no-print-directory cov-build
189 @
$(MAKE
) --no-print-directory cov-report
192 rm -f
$(COV_GCDA
) $(COV_GCNO
) *.gcov untested
194 COV_CFLAGS
= $(CFLAGS
) -O0
-ftest-coverage
-fprofile-arcs
197 $(MAKE
) CFLAGS
="$(COV_CFLAGS)" all
198 $(MAKE
) TEST_COVERAGE
=1 test
201 @echo
"--- untested files:" | tee untested
202 @
{ for f in
$(SRC_C
); do \
203 gcda
=$$(dirname
$$f)"/"$$(basename $$f .c
)".gcda"; \
204 if
test -f
$$gcda; then \
205 gcov
-b
-p
-o
$$(dirname
$$f) $$f >/dev
/null
; \
207 echo
$$f | tee
-a untested
; \
211 @echo
"--- untested functions:" | tee
-a untested
212 @grep
'^function .* called 0' *.c.gcov \
213 | sed
-e
's/\([^:]*\)\.gcov:function \([^ ]*\) called.*/\1: \2/' \
214 | sed
-e
's|#|/|g' | tee
-a untested