Debian Codegraph @

internal/warpc/genwebp/deps/clib/Makefile

raw
1 CC ?= cc
2 PREFIX ?= /usr/local
3
4 BINS = clib clib-install clib-search clib-init clib-configure clib-build clib-update clib-upgrade clib-uninstall
5
6 ifdef EXE
7 BINS := $(addsuffix .exe,$(BINS))
8 endif
9
10 CP = cp -f
11 RM = rm -f
12 MKDIR = mkdir -p
13 INSTALL = install
14
15 SRC = $(wildcard src/*.c)
16 COMMON_SRC = $(wildcard src/common/*.c)
17 ALL_SRC = $(wildcard src/*.c src/*.h src/common/*.c src/common/*.h test/package/*.c test/cache/*.c)
18 SDEPS = $(wildcard deps/*/*.c)
19 ODEPS = $(SDEPS:.c=.o)
20 DEPS = $(filter-out $(ODEPS), $(SDEPS))
21 OBJS = $(DEPS:.c=.o)
22 MAKEFILES = $(wildcard deps/*/Makefile)
23 HEADERS_BINS = src/common/*.h src/version.h deps/logger/logger.h
24
25 export CC
26
27 CFLAGS += -std=c99 -Ideps -Wall -Wno-unused-function -U__STRICT_ANSI__
28
29 ifdef STATIC
30 CFLAGS += -DCURL_STATICLIB $(shell deps/curl/bin/curl-config --cflags)
31 LDFLAGS += -static $(shell deps/curl/bin/curl-config --static-libs)
32 else
33 CFLAGS += $(shell curl-config --cflags)
34 LDFLAGS += $(shell curl-config --libs)
35 endif
36
37 ifneq (0,$(PTHREADS))
38 ifndef NO_PTHREADS
39 CFLAGS += $(shell ./scripts/feature-test-pthreads && echo "-DHAVE_PTHREADS=1 -pthread")
40 endif
41 endif
42
43 ifdef DEBUG
44 CFLAGS += -g -D CLIB_DEBUG=1 -D DEBUG="$(DEBUG)"
45 endif
46
47 default: all
48
49 all: $(BINS)
50
51 build: $(BINS)
52
53 $(BINS): $(SRC) $(COMMON_SRC) $(MAKEFILES) $(OBJS) $(HEADERS_BINS)
54 $(CC) $(CFLAGS) -o $@ $(COMMON_SRC) src/$(@:.exe=).c $(OBJS) $(LDFLAGS)
55
56 $(MAKEFILES):
57 $(MAKE) -C $@
58
59 %.o: %.c
60 $(CC) $< -c -o $@ $(CFLAGS) -MMD
61
62 clean:
63 $(foreach c, $(BINS), $(RM) $(c);)
64 $(RM) $(OBJS)
65 $(RM) $(AUTODEPS)
66 cd test/cache && make clean
67 cd test/package && make clean
68
69 install: $(BINS)
70 $(MKDIR) $(PREFIX)/bin
71 $(foreach c, $(BINS), $(INSTALL) $(c) $(PREFIX)/bin/$(c);)
72
73 uninstall:
74 $(foreach c, $(BINS), $(RM) $(PREFIX)/bin/$(c);)
75
76 test: $(BINS)
77 @./test.sh
78
79 # create a list of auto dependencies
80 AUTODEPS:= $(patsubst %.c,%.d, $(DEPS)) $(patsubst %.c,%.d, $(SRC))
81
82 # include by auto dependencies
83 -include $(AUTODEPS)
84
85 # Format all source files in the repository.
86 fmt:
87 @if ! command -v clang-format &> /dev/null; then \
88 echo "clang-format not found"; \
89 exit; \
90 fi
91 clang-format -i -style=LLVM $(ALL_SRC)
92
93 # Install the commit hook.
94 commit-hook: scripts/pre-commit-hook.sh
95 cp -f scripts/pre-commit-hook.sh .git/hooks/pre-commit
96
97 .PHONY: test all clean install uninstall fmt