forked from markfasheh/ocfs2-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Postamble.make
186 lines (134 loc) · 4.91 KB
/
Postamble.make
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
ifdef VERSION_SRC
ifndef VERSION_FILES
$(error Need VERSION_FILES defined for version objects)
endif
ifndef VERSION_PREFIX
$(error Need VERSION_PREFIX defined for version objects)
endif
VERSION_OBJ = $(subst .c,.o,$(VERSION_SRC))
VERSION_NUM = $(VERSION_PREFIX)_BUILD_VERSION
VERSION_DATE = $(VERSION_PREFIX)_BUILD_DATE
VERSION_MD5 = $(VERSION_PREFIX)_BUILD_MD5
VERDEFS = -D$(VERSION_NUM)=\""$(VERSION)"\" \
-D$(VERSION_DATE)=\""$(shell LANG=C date)"\" \
-D$(VERSION_MD5)=\""$(shell cat stamp-md5)"\"
VERMAGIC = $(if $(filter $(VERSION_OBJ),$@),$(VERDEFS))
ifneq ($(MAKECMDGOALS),install)
VERSTAMP = stamp
endif
stamp: ;
stamp-md5: $(VERSION_FILES)
@cat $(VERSION_FILES) Makefile | md5sum | sed -e 's/ .*//' > stamp-md5
$(VERSION_OBJ): stamp-md5 $(VERSTAMP)
endif
LOCAL_CFLAGS = $($(subst /,_,$(basename $@))_CFLAGS)
LOCAL_CPPFLAGS = $($(subst /,_,$(basename $@))_CPPFLAGS)
%.o: %.c
$(CC) $(CFLAGS) $(LOCAL_CFLAGS) $(CPPFLAGS) $(LOCAL_CPPFLAGS) $(INCLUDES) $(DEFINES) $(VERMAGIC) $(CDEPFLAGS) -o $@ -c $<
%.p: %.c
$(CC) $(CFLAGS) $(LOCAL_CFLAGS) $(CPPFLAGS) $(LOCAL_CPPFLAGS) $(INCLUDES) $(DEFINES) $(VERMAGIC) -E -o $@ -c $<
%.s: %.c
$(CC) $(CFLAGS) $(LOCAL_CFLAGS) $(CPPFLAGS) $(LOCAL_CPPFLAGS) $(INCLUDES) $(DEFINES) $(VERMAGIC) -S -o $@ -c $<
.PHONY: subdirs $(SUBDIRS)
subdirs: $(SUBDIRS)
$(SUBDIRS):
$(MAKE) -C $@
.PHONY: all-rules
all-rules: subdirs $(UNINST_LIBRARIES) $(LIBRARIES) $(BIN_PROGRAMS) $(SBIN_PROGRAMS) $(UNINST_PROGRAMS) $(MODULES) $(MANS) $(ALL_RULES) $(SBIN_EXTRA) $(BIN_EXTRA)
INSTALL_SUBDIRS = $(addsuffix -install,$(SUBDIRS))
.PHONY: install-rules install-subdirs $(INSTALL_RULES) install-libraries install-headers install-bin-programs install-bin-extra install-sbin-programs install-sbin-extra
install-subdirs: $(INSTALL_SUBDIRS)
$(INSTALL_SUBDIRS):
$(MAKE) -C $(subst -install,,$@) install
install-libraries: $(LIBRARIES)
ifdef LIBRARIES
$(SHELL) $(TOPDIR)/mkinstalldirs $(DESTDIR)$(libdir)
for lib in $(LIBRARIES); do \
$(INSTALL_LIBRARY) $$lib $(DESTDIR)$(libdir)/$$lib; \
done
endif
ifeq ($(filter /%,$(HEADERS_SUBDIR)),)
Hsubdir = /$(HEADERS_SUBDIR)
else
Hsubdir = $(HEADERS_SUBDIR)
endif
ifeq ($(filter include/%,$(HEADERS)),)
Hinstall =
else
Hinstall = include/
endif
install-headers: $(HEADERS)
ifdef HEADERS
$(SHELL) $(TOPDIR)/mkinstalldirs $(DESTDIR)$(includedir)$(Hsubdir)
for hdr in $(patsubst include/%,%,$(HEADERS)); do \
$(INSTALL_HEADER) $(Hinstall)$$hdr $(DESTDIR)$(includedir)$(Hsubdir)/$$hdr; \
done
endif
install-bin-programs: $(BIN_PROGRAMS)
ifdef BIN_PROGRAMS
$(SHELL) $(TOPDIR)/mkinstalldirs $(DESTDIR)$(bindir)
for prog in $(BIN_PROGRAMS); do \
$(INSTALL_PROGRAM) $$prog $(DESTDIR)$(bindir)/$$prog; \
done
endif
install-bin-extra: $(BIN_EXTRA)
ifdef BIN_EXTRA
$(SHELL) $(TOPDIR)/mkinstalldirs $(DESTDIR)$(bindir)
for prog in $(BIN_EXTRA); do \
$(INSTALL_PROGRAM) $$prog $(DESTDIR)$(bindir)/$$prog; \
done
endif
install-sbin-programs: $(SBIN_PROGRAMS)
ifdef SBIN_PROGRAMS
$(SHELL) $(TOPDIR)/mkinstalldirs $(DESTDIR)$(sbindir)
for prog in $(SBIN_PROGRAMS); do \
$(INSTALL_PROGRAM) $$prog $(DESTDIR)$(sbindir)/$$prog; \
done
endif
install-sbin-extra: $(SBIN_EXTRA)
ifdef SBIN_EXTRA
$(SHELL) $(TOPDIR)/mkinstalldirs $(DESTDIR)$(sbindir)
for prog in $(SBIN_EXTRA); do \
$(INSTALL_PROGRAM) $$prog $(DESTDIR)$(sbindir)/$$prog; \
done
endif
install-mans: $(MANS)
ifdef MANS
$(SHELL) $(TOPDIR)/mkinstalldirs $(DESTDIR)$(mandir)
for man in $(MANS); do \
dir=`echo $$man | sed -e 's/^.*\\./man/'`; \
$(SHELL) $(TOPDIR)/mkinstalldirs $(DESTDIR)$(mandir)/$$dir; \
$(INSTALL_DATA) $$man $(DESTDIR)$(mandir)/$$dir/$$man; \
done
endif
install-rules: install-subdirs $(INSTALL_RULES) install-libraries install-headers install-bin-programs install-bin-extra install-sbin-programs install-sbin-extra install-mans
CLEAN_SUBDIRS = $(addsuffix -clean,$(SUBDIRS))
.PHONY: clean clean-subdirs $(CLEAN_RULES) $(CLEAN_SUBDIRS)
clean-subdirs: $(CLEAN_SUBDIRS)
$(CLEAN_SUBDIRS):
$(MAKE) -C $(subst -clean,,$@) clean
clean: clean-subdirs $(CLEAN_RULES)
rm -f *.o *.p .*.d core $(BIN_PROGRAMS) $(SBIN_PROGRAMS) $(LIBRARIES) $(UNINST_PROGRAMS) $(UNINST_LIBRARIES) $(SBIN_EXTRA) $(BIN_EXTRA) stamp-md5
DIST_SUBDIRS = $(addsuffix -dist,$(SUBDIRS))
.PHONY: dist-all dist-mkdir dist-copy dist-subdirs $(DIST_RULES) $(DIST_SUBDIRS)
dist-subdirs: $(DIST_SUBDIRS)
$(DIST_SUBDIRS):
$(MAKE) -C $(subst -dist,,$@) dist-all \
DIST_CURDIR=$(DIST_CURDIR)/$(subst -dist,,$@)
dist-mkdir:
$(SHELL) $(TOPDIR)/mkinstalldirs $(DIST_DIR)
DIST_ALL_FILES = Makefile $(MANS) $(VERSION_FILES) $(DIST_FILES)
dist-copy: dist-mkdir $(DIST_ALL_FILES) $(DIST_RULES)
@for file in $(DIST_ALL_FILES); do \
echo " cp -p $$file $(DIST_DIR)/$$file"; \
cp -p $$file $(DIST_DIR)/$$file; \
done
dist-all: dist-copy dist-subdirs
LOCAL_DFILES := $(wildcard .*.d)
ifneq ($(LOCAL_DFILES),)
.PHONY: $(LOCAL_DFILES)
-include $(LOCAL_DFILES)
endif
ifeq (Cscope.make,$(wildcard Cscope.make))
include Cscope.make
endif