Hash :
007e0753
Author :
Date :
2008-12-27T18:58:25
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
all::
DOXYGEN = doxygen
prefix=/usr/local
CFLAGS = -g -O2 -Wall
OS = unix
BASIC_CFLAGS := -Isrc
BASIC_CFLAGS += -fvisibility=hidden
ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS)
SRC_C = $(wildcard src/*.c)
OBJS = $(patsubst %.c,%.o,$(SRC_C))
HDRS = $(wildcard src/*.h)
PUBLIC_HEADERS = $(wildcard src/git/*.h)
HDRS += $(PUBLIC_HEADERS)
GIT_LIB = libgit2.a
TEST_OBJ = $(patsubst %.c,%.o,\
$(wildcard tests/t[0-9][0-9][0-9][0-9]-*.c))
TEST_EXE = $(patsubst %.o,%.exe,$(TEST_OBJ))
TEST_RUN = $(patsubst %.exe,%.run,$(TEST_EXE))
all:: $(GIT_LIB)
clean:
rm -f $(GIT_LIB)
rm -f src/*.o
rm -f tests/*.o tests/*.exe tests/*.toc
rm -rf trash-*.exe
rm -rf apidocs
apidocs:
$(DOXYGEN) api.doxygen
cp CONVENTIONS apidocs/
test: $(TEST_RUN)
sparse:
cgcc -no-compile $(ALL_CFLAGS) $(SPARSE_FLAGS) $(SRC_C)
install-headers: $(PUBLIC_HEADERS)
@mkdir -p /tmp/gitinc/git
@for i in $^; do cat .HEADER $$i > /tmp/gitinc/$${i##src/}; done
install: $(GIT_LIB) $(PUBLIC_HEADERS) libgit2.pc
@mkdir -p $(prefix)/include/git
@for i in $(PUBLIC_HEADERS); do \
cat .HEADER $$i > $(prefix)/include/$${i##src/}; \
done
@mkdir -p $(prefix)/lib
@cp -f $(GIT_LIB) $(prefix)/lib/libgit2.a
@mkdir -p $(prefix)/lib/pkgconfig
@cp -f libgit2.pc $(prefix)/lib/pkgconfig/libgit2.pc
uninstall:
@rm -f $(prefix)/lib/libgit2.a
@rm -f $(prefix)/lib/pkgconfig/libgit2.pc
@for i in $(PUBLIC_HEADERS); do \
rm -f $(prefix)/include/$${i##src/}; \
done
@rmdir $(prefix)/include/git
.c.o:
$(CC) $(ALL_CFLAGS) -c $< -o $@
$(OBJS): $(HDRS)
$(GIT_LIB): $(OBJS)
rm -f $(LIB)
$(AR) cr $(GIT_LIB) $(OBJS)
T_HDR = tests/test_lib.h
T_LIB = tests/test_lib.o
T_MAIN_C = tests/test_main.c
$(T_LIB): $(T_HDR) $(HDRS)
$(TEST_OBJ): $(T_HDR) $(HDRS)
$(patsubst %.exe,%.toc,$(TEST_EXE)): tests/%.toc: tests/%.c
grep BEGIN_TEST $< >$@+
mv $@+ $@
$(TEST_OBJ): tests/%.o: tests/%.c
$(CC) $(ALL_CFLAGS) -c $< -o $@
$(patsubst %.exe,%_main.o,$(TEST_EXE)): tests/%_main.o: $(HDRS)
$(patsubst %.exe,%_main.o,$(TEST_EXE)): tests/%_main.o: $(T_MAIN_C)
$(patsubst %.exe,%_main.o,$(TEST_EXE)): tests/%_main.o: tests/%.toc
$(CC) -Isrc -I. '-DTEST_TOC="$<"' \
-c $(T_MAIN_C) \
-o $@
$(TEST_EXE): tests/%.exe: $(T_LIB) $(GIT_LIB)
$(TEST_EXE): tests/%.exe: tests/%.o tests/%_main.o
$(CC) -o $@ \
$(patsubst %.exe,%_main.o,$@) \
$(patsubst %.exe,%.o,$@) \
$(T_LIB) -L. -lgit2 -lz -lcrypto
$(TEST_RUN): tests/%.run: tests/%.exe
@t=trash-$(<F) && \
mkdir $$t && \
if (cd $$t && ../$<); \
then rm -rf $$t; \
else rmdir $$t; exit 1; \
fi
libgit2.pc: libgit2.pc.in
sed 's#@prefix@#$(prefix)#' $< > $@
.PHONY: all
.PHONY: clean
.PHONY: test $(TEST_RUN)
.PHONY: apidocs
.PHONY: install-headers
.PHONY: install uninstall
.PHONY: sparse