3 # Define NO_VISIBILITY if your compiler does not support symbol
4 # visibility in general (and the -fvisibility switch in particular).
6 # Define NO_OPENSSL if you do not have OpenSSL, or if you simply want
7 # to use the bundled (Mozilla) SHA1 routines. (The bundled SHA1
8 # routines are reported to be faster than OpenSSL on some platforms)
19 uname_S
:= $(shell sh
-c
'uname -s 2>/dev/null || echo no')
27 # Platform specific tweaks
29 ifneq (,$(findstring CYGWIN
,$(uname_S
)))
30 NO_VISIBILITY
=YesPlease
33 SRC_C
= $(wildcard src
/*.c
)
34 OS_SRC
= $(wildcard src
/$(OS
)/*.c
)
36 OBJS
= $(patsubst %.c
,%.o
,$(SRC_C
))
37 HDRS
= $(wildcard src
/*.h
)
38 PUBLIC_HEADERS
= $(wildcard src
/git
/*.h
)
39 HDRS
+= $(PUBLIC_HEADERS
)
43 TEST_OBJ
= $(patsubst %.c
,%.o
,\
44 $(wildcard tests
/t
[0-9][0-9][0-9][0-9]-*.c
))
45 TEST_EXE
= $(patsubst %.o
,%.exe
,$(TEST_OBJ
))
46 TEST_RUN
= $(patsubst %.exe
,%.run
,$(TEST_EXE
))
47 TEST_VAL
= $(patsubst %.exe
,%.val
,$(TEST_EXE
))
50 SHA1_HEADER
= <openssl
/sha.h
>
52 SHA1_HEADER
= "sha1/sha1.h"
53 EXTRA_SRC
+= src
/sha1
/sha1.c
54 EXTRA_OBJ
+= src
/sha1
/sha1.o
57 BASIC_CFLAGS
:= -Isrc
-DSHA1_HEADER
='$(SHA1_HEADER)'
59 BASIC_CFLAGS
+= -fvisibility
=hidden
62 ALL_CFLAGS
= $(CFLAGS
) $(BASIC_CFLAGS
)
71 rm -f src
/*.o src
/sha1
/*.o src
/unix
/*.o
73 rm -f
*~ src
/*~ src
/git
/*~ src
/sha1
/*~ src
/unix
/*~ src
/win32
/*~
74 @
$(MAKE
) -C tests
-s
--no-print-directory
clean
75 @
$(MAKE
) -s
--no-print-directory cov-clean
78 @
$(MAKE
) -C tests
-s
--no-print-directory
clean
81 $(DOXYGEN
) api.doxygen
82 cp CONVENTIONS apidocs
/
85 @
$(MAKE
) -C tests
--no-print-directory
test
88 @
$(MAKE
) -C tests
--no-print-directory valgrind
91 cgcc
-no-compile
$(ALL_CFLAGS
) $(SPARSE_FLAGS
) $(SRC_C
)
93 install-headers
: $(PUBLIC_HEADERS
)
94 @
$(INSTALL
) -d
/tmp
/gitinc
/git
95 @for i in
$^
; do cat .HEADER
$$i > /tmp
/gitinc
/$${i
##src/}; done
97 install: $(GIT_LIB
) $(PUBLIC_HEADERS
) libgit2.
pc
98 @
$(INSTALL
) -d
$(DESTDIR
)/$(prefix)/include/git
99 @for i in
$(PUBLIC_HEADERS
); do \
100 cat .HEADER
$$i > $(DESTDIR
)/$(prefix)/include/$${i
##src/}; \
102 @
$(INSTALL
) -d
$(DESTDIR
)/$(libdir)
103 @
$(INSTALL
) $(GIT_LIB
) $(DESTDIR
)/$(libdir)/libgit2.a
104 @
$(INSTALL
) -d
$(DESTDIR
)/$(libdir)/pkgconfig
105 @
$(INSTALL
) libgit2.
pc $(DESTDIR
)/$(libdir)/pkgconfig
/libgit2.
pc
108 @
rm -f
$(DESTDIR
)/$(libdir)/libgit2.a
109 @
rm -f
$(DESTDIR
)/$(libdir)/pkgconfig
/libgit2.
pc
110 @for i in
$(PUBLIC_HEADERS
); do \
111 rm -f
$(DESTDIR
)/$(prefix)/include/$${i
##src/}; \
113 @rmdir
$(DESTDIR
)/$(prefix)/include/git
116 $(CC
) $(ALL_CFLAGS
) -c
$< -o
$@
121 $(AR
) $(GIT_LIB
) $(OBJS
)
124 $(TEST_OBJ
) $(TEST_EXE
) $(TEST_RUN
) $(TEST_VAL
):
125 @
$(MAKE
) -C tests
--no-print-directory \
126 OS
=$(OS
) NO_OPENSSL
=$(NO_OPENSSL
) $(@F
)
128 libgit2.
pc: libgit2.
pc.in
129 sed
-e
's#@prefix@#$(prefix)#' -e
's#@libdir@#$(libdir)#' $< > $@
133 .PHONY
: test $(TEST_VAL
) $(TEST_RUN
) $(TEST_EXE
) $(TEST_OBJ
)
135 .PHONY
: install-headers
136 .PHONY
: install uninstall
139 ### Test suite coverage testing
141 .PHONY
: coverage cov-clean cov-build cov-report
143 COV_GCDA
= $(patsubst %.c
,%.gcda
,$(SRC_C
))
144 COV_GCNO
= $(patsubst %.c
,%.gcno
,$(SRC_C
))
147 @
$(MAKE
) -s
--no-print-directory
clean
148 @
$(MAKE
) --no-print-directory cov-build
149 @
$(MAKE
) --no-print-directory cov-report
152 rm -f
$(COV_GCDA
) $(COV_GCNO
) *.gcov untested
154 COV_CFLAGS
= $(CFLAGS
) -O0
-ftest-coverage
-fprofile-arcs
157 $(MAKE
) CFLAGS
="$(COV_CFLAGS)" all
158 $(MAKE
) TEST_COVERAGE
=1 NO_OPENSSL
=$(NO_OPENSSL
) test
161 @echo
"--- untested files:" | tee untested
162 @
{ for f in
$(SRC_C
); do \
163 gcda
=$$(dirname
$$f)"/"$$(basename $$f .c
)".gcda"; \
164 if
test -f
$$gcda; then \
165 gcov
-b
-p
-o
$$(dirname
$$f) $$f >/dev
/null
; \
167 echo
$$f | tee
-a untested
; \
171 @echo
"--- untested functions:" | tee
-a untested
172 @grep
'^function .* called 0' *.c.gcov \
173 | sed
-e
's/\([^:]*\)\.gcov:function \([^ ]*\) called.*/\1: \2/' \
174 | sed
-e
's|#|/|g' | tee
-a untested