forked from Paulxia/nmealib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
112 lines (78 loc) · 2.28 KB
/
Makefile
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
include Makefile.inc
#
# Settings
#
DESTDIR ?=
USRDIR ?= $(DESTDIR)/usr
INCLUDEDIR ?= $(DESTDIR)/usr/include
LIBDIR ?= $(USRDIR)/lib
H_FILES = $(wildcard include/nmealib/*.h)
C_FILES = $(wildcard src/*.c)
MODULES = $(C_FILES:src/%.c=%)
OBJ = $(MODULES:%=build/%.o)
LIBRARIES = -lm
INCLUDES = -I ./include
.PRECIOUS: $(OBJ)
#
# Targets
#
all: default_target
default_target: all-before lib/$(LIBNAMESTATIC) lib/$(LIBNAME)
remake: clean all
lib/$(LIBNAMESTATIC): $(OBJ)
ifeq ($(VERBOSE),0)
@echo "[AR] $@"
endif
$(MAKECMDPREFIX)ar rcs "$@" $(OBJ)
lib/$(LIBNAME): $(OBJ)
ifeq ($(VERBOSE),0)
@echo "[LD] $@"
endif
$(MAKECMDPREFIX)$(CC) $(LDFLAGS) -Wl,-soname=$(LIBNAME) -o "$@" $(LIBRARIES) $(OBJ)
build/%.o: src/%.c $(H_FILES) Makefile Makefile.inc
ifeq ($(VERBOSE),0)
@echo "[CC] $<"
endif
$(MAKECMDPREFIX)$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
full : all samples test
test: all
$(MAKECMDPREFIX)$(MAKE) -C test all
samples: all
$(MAKECMDPREFIX)$(MAKE) -C samples all
check: test samples
$(MAKECMDPREFIX)$(MAKE) -C test check
#
# Phony Targets
#
.PHONY: all-before clean doc doc-pdf doc-all doc-clean install install-headers uninstall uninstall-headers
all-before:
$(MAKECMDPREFIX)mkdir -p build lib
clean:
$(MAKECMDPREFIX)$(MAKE) -C test clean
$(MAKECMDPREFIX)$(MAKE) -C samples clean
$(MAKECMDPREFIX)$(MAKE) -C doc clean
$(MAKECMDPREFIX)rm -fr build lib
doc:
$(MAKECMDPREFIX)$(MAKE) -C doc doc
doc-pdf:
$(MAKECMDPREFIX)$(MAKE) -C doc doc-pdf
doc-all:
$(MAKECMDPREFIX)$(MAKE) -C doc all
doc-clean:
$(MAKECMDPREFIX)$(MAKE) -C doc clean
install: all
$(MAKECMDPREFIX)mkdir -v -p "$(LIBDIR)"
$(MAKECMDPREFIX)cp -v "lib/$(LIBNAME)" "$(LIBDIR)/$(LIBNAME).$(VERSION)"
$(MAKECMDPREFIX)$(STRIP) "$(LIBDIR)/$(LIBNAME).$(VERSION)"
$(MAKECMDPREFIX)/sbin/ldconfig -n "$(LIBDIR)"
install-headers: all
$(MAKECMDPREFIX)mkdir -v -p "$(INCLUDEDIR)"
$(MAKECMDPREFIX)rm -fr "$(INCLUDEDIR)/nmealib"
$(MAKECMDPREFIX)cp -rv include/nmealib "$(INCLUDEDIR)"
uninstall:
$(MAKECMDPREFIX)rm -fv "$(LIBDIR)/$(LIBNAME)" "$(LIBDIR)/$(LIBNAME).$(VERSION)"
$(MAKECMDPREFIX)/sbin/ldconfig -n "$(LIBDIR)"
$(MAKECMDPREFIX)rmdir -v -p --ignore-fail-on-non-empty "$(LIBDIR)"
uninstall-headers:
$(MAKECMDPREFIX)rm -frv "$(INCLUDEDIR)/nmealib"
$(MAKECMDPREFIX)rmdir -v -p --ignore-fail-on-non-empty "$(INCLUDEDIR)"