-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.mk
73 lines (57 loc) · 1.62 KB
/
build.mk
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
# ============================================================================
# Generic build targets and recipes for xchange.
#
# You can include this in your Makefile also.
# ============================================================================
# Regular object files
$(OBJ)/%.o: %.c $(OBJ) Makefile
$(CC) -o $@ -c $(CPPFLAGS) $(CFLAGS) $<
# Share library recipe
$(LIB)/%.so.$(SO_VERSION):
@make $(LIB)
$(CC) -o $@ $(CPPFLAGS) $(CFLAGS) $^ -shared -fPIC -Wl,-soname,$(subst $(LIB)/,,$@) $(LDFLAGS)
# Unversioned shared libs (for linking against)
$(LIB)/lib%.so:
@rm -f $@
ln -sr $< $@
# Static library: *.a
$(LIB)/%.a:
@make $(LIB)
ar -rc $@ $^
ranlib $@
# Simple binaries
$(BIN)/%: $(OBJ)/%.o
@make $(BIN)
$(CC) -o $@ $^ $(LDFLAGS)
# Create sub-directories for build targets
dep $(OBJ) $(LIB) $(BIN) apidoc:
mkdir $@
# Remove intermediate files locally
.PHONY: clean-local
clean-local:
rm -rf obj
# Remove all locally built files, effectively restoring the repo to its
# pristine state
.PHONY: distclean-local
distclean-local: clean-local
rm -rf bin lib apidoc infer-out
# Remove intermediate files (general)
.PHONY: clean
clean: clean-local
# Remove intermediate files (general)
.PHONY: distclean
distclean: distclean-local
# Static code analysis using 'cppcheck'
.PHONY: analyze
analyze:
@echo " [analyze]"
@cppcheck $(CPPFLAGS) $(CHECKOPTS) src
# Static code analysis via Facebook's infer
.PHONY: infer
infer: CC := infer run -- $(CC)
infer: distclean shared
# Doxygen documentation (HTML and man pages) under apidocs/
.PHONY: dox
dox: README.md Doxyfile apidoc $(SRC) $(INC)
@echo " [doxygen]"
@$(DOXYGEN)