9 BASIC_CFLAGS
+= -fvisibility
=hidden
10 ALL_CFLAGS
= $(CFLAGS
) $(BASIC_CFLAGS
)
12 SRC_C
= $(wildcard src
/*.c
)
13 OBJS
= $(patsubst %.c
,%.o
,$(SRC_C
))
14 HDRS
= $(wildcard src
/*.h
)
15 PUBLIC_HEADERS
= $(wildcard src
/git
/*.h
)
16 HDRS
+= $(PUBLIC_HEADERS
)
20 TEST_OBJ
= $(patsubst %.c
,%.o
,\
21 $(wildcard tests
/t
[0-9][0-9][0-9][0-9]-*.c
))
22 TEST_EXE
= $(patsubst %.o
,%.exe
,$(TEST_OBJ
))
23 TEST_RUN
= $(patsubst %.exe
,%.run
,$(TEST_EXE
))
30 rm -f tests
/*.o tests
/*.exe tests
/*.toc
31 rm -f src
/git
/config.h
35 $(DOXYGEN
) api.doxygen
36 cp CONVENTIONS apidocs
/
41 cgcc
-no-compile
$(ALL_CFLAGS
) $(SPARSE_FLAGS
) $(SRC_C
)
43 install-headers
: $(PUBLIC_HEADERS
)
44 @mkdir
-p
/tmp
/gitinc
/git
45 @for i in
$^
; do cat .HEADER
$$i > /tmp
/gitinc
/$${i
##src/}; done
48 $(CC
) $(ALL_CFLAGS
) -c
$< -o
$@
53 $(AR
) cr
$(GIT_LIB
) $(OBJS
)
55 T_HDR
= tests
/test_lib.h
56 T_LIB
= tests
/test_lib.o
57 T_MAIN_C
= tests
/test_main.c
59 $(T_LIB
): $(T_HDR
) $(HDRS
)
60 $(TEST_OBJ
): $(T_HDR
) $(HDRS
)
62 $(patsubst %.exe
,%.toc
,$(TEST_EXE
)): tests
/%.toc
: tests
/%.c
63 grep BEGIN_TEST
$< >$@
+
66 $(TEST_OBJ
): tests
/%.o
: tests
/%.c
67 $(CC
) $(ALL_CFLAGS
) -c
$< -o
$@
69 $(patsubst %.exe
,%_main.o
,$(TEST_EXE
)): tests
/%_main.o
: $(HDRS
)
70 $(patsubst %.exe
,%_main.o
,$(TEST_EXE
)): tests
/%_main.o
: $(T_MAIN_C
)
71 $(patsubst %.exe
,%_main.o
,$(TEST_EXE
)): tests
/%_main.o
: tests
/%.toc
72 $(CC
) -Isrc
-I.
'-DTEST_TOC="$<"' \
76 $(TEST_EXE
): tests
/%.exe
: $(T_LIB
) $(GIT_LIB
)
77 $(TEST_EXE
): tests
/%.exe
: tests
/%.o tests
/%_main.o
79 $(patsubst %.exe
,%_main.o
,$@
) \
80 $(patsubst %.exe
,%.o
,$@
) \
83 $(TEST_RUN
): tests
/%.run
: tests
/%.exe
88 .PHONY
: test $(TEST_RUN
)
90 .PHONY
: install-headers