-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
141 lines (108 loc) · 4.74 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
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
#
# This Makefile requires GNU make.
#
# Do not make changes here.
# Use the included .mak files.
#
it: all
CC = $(error Please use ./configure first)
STATIC_LIBS :=
SHARED_LIBS :=
INTERNAL_LIBS :=
EXTRA_TARGETS :=
DOC_TARGETS :=
-include config.mak
include package/targets.mak
include package/deps.mak
version_m := $(basename $(version))
version_M := $(basename $(version_m))
CPPFLAGS_ALL := -iquote src/include-local -Isrc/include $(CPPFLAGS)
CFLAGS_ALL := $(CFLAGS) -pipe -Wall
CFLAGS_SHARED := -fPIC
LDFLAGS_ALL := $(LDFLAGS)
LDFLAGS_SHARED := -shared
LDLIBS_ALL := $(LDLIBS)
REALCC = $(CROSS_COMPILE)$(CC)
AR := $(CROSS_COMPILE)ar
RANLIB := $(CROSS_COMPILE)ranlib
STRIP := $(CROSS_COMPILE)strip
INSTALL := ./tools/install.sh
POD2MAN := pod2man
ALL_BINS := $(LIBEXEC_TARGETS) $(BIN_TARGETS) $(SBIN_TARGETS)
ALL_LIBS := $(SHARED_LIBS) $(STATIC_LIBS) $(INTERNAL_LIBS)
ALL_INCLUDES := $(wildcard src/include/$(package)/*.h)
ALL_SCRIPTS := $(LIBEXEC_SCRIPTS_TARGET) $(BIN_SCRIPTS_TARGET)
all: $(ALL_LIBS) $(ALL_BINS) $(ALL_SCRIPTS) $(ALL_INCLUDES) $(DOC_TARGETS)
clean:
@exec rm -f $(ALL_LIBS) $(ALL_BINS) $(ALL_SCRIPTS) $(wildcard src/*/*.o src/*/*.lo) $(EXTRA_TARGETS)
distclean: clean
@exec rm -f config.mak package/deps.mak src/include/${package}/config.h $(DOC_TARGETS)
txz: distclean $(DOC_TARGETS)
@./tools/gen-deps.sh > package/deps.mak 2> /dev/null && \
. package/info && \
rm -rf /tmp/$$package-$$version && \
cp -a . /tmp/$$package-$$version && \
cd /tmp && \
tar -Jpcv --owner=0 --group=0 --numeric-owner --exclude=.git* -f /tmp/$$package-$$version.tar.xz $$package-$$version && \
exec rm -rf /tmp/$$package-$$version
strip: $(ALL_LIBS) $(ALL_BINS)
ifneq ($(strip $(ALL_LIBS)),)
exec ${STRIP} -x -R .note -R .comment -R .note.GNU-stack $(ALL_LIBS)
endif
ifneq ($(strip $(ALL_BINS)),)
exec ${STRIP} -R .note -R .comment -R .note.GNU-stack $(ALL_BINS)
endif
install: install-dynlib install-libexec install-bin install-sbin install-lib install-include install-doc
install-dynlib: $(SHARED_LIBS:lib%.so=$(DESTDIR)$(dynlibdir)/lib%.so)
install-libexec: $(LIBEXEC_TARGETS:%=$(DESTDIR)$(libexecdir)/%) $(LIBEXEC_SCRIPTS_TARGET:%=$(DESTDIR)$(libexecdir)/%)
install-bin: $(BIN_TARGETS:%=$(DESTDIR)$(bindir)/%) $(BIN_SCRIPTS_TARGET:%=$(DESTDIR)$(bindir)/%)
install-sbin: $(SBIN_TARGETS:%=$(DESTDIR)$(sbindir)/%)
install-lib: $(STATIC_LIBS:lib%.a=$(DESTDIR)$(libdir)/lib%.a)
install-include: $(ALL_INCLUDES:src/include/$(package)/%.h=$(DESTDIR)$(includedir)/$(package)/%.h)
install-doc: $(DOC_TARGETS:%=$(DESTDIR)/usr/share/man/man1/%)
ifneq ($(exthome),)
update:
exec $(INSTALL) -l $(notdir $(home)) $(DESTDIR)$(exthome)
global-links: $(DESTDIR)$(exthome) $(SHARED_LIBS:lib%.so=$(DESTDIR)$(sproot)/library.so/lib%.so) $(BIN_TARGETS:%=$(DESTDIR)$(sproot)/command/%) $(SBIN_TARGETS:%=$(DESTDIR)$(sproot)/command/%)
$(DESTDIR)$(sproot)/command/%: $(DESTDIR)$(home)/command/%
exec $(INSTALL) -D -l ..$(subst $(sproot),,$(exthome))/command/$(<F) $@
$(DESTDIR)$(sproot)/library.so/lib%.so: $(DESTDIR)$(dynlibdir)/lib%.so
exec $(INSTALL) -D -l ..$(subst $(sproot),,$(exthome))/library.so/$(<F) $@
.PHONY: update global-links
endif
$(DESTDIR)$(dynlibdir)/lib%.so: lib%.so
$(INSTALL) -D -m 755 $< $@.$(version) && \
$(INSTALL) -l $<.$(version) $@.$(version_m) && \
$(INSTALL) -l $<.$(version_m) $@.$(version_M) && \
exec $(INSTALL) -l $<.$(version_M) $@
$(DESTDIR)$(libexecdir)/% $(DESTDIR)$(bindir)/% $(DESTDIR)$(sbindir)/%: % package/modes
exec $(INSTALL) -D -m 600 $< $@
grep -- ^$(@F) < package/modes | { read name mode owner && \
if [ x$$owner != x ] ; then chown -- $$owner $@ ; fi && \
chmod $$mode $@ ; }
$(DESTDIR)$(libdir)/lib%.a: lib%.a
exec $(INSTALL) -D -m 644 $< $@
$(DESTDIR)$(includedir)/$(package)/%.h: src/include/$(package)/%.h
exec $(INSTALL) -D -m 644 $< $@
$(DESTDIR)/usr/share/man/man1/%: %
exec $(INSTALL) -D -m 644 $< $@
%.o: %.c
exec $(REALCC) $(CPPFLAGS_ALL) $(CFLAGS_ALL) -c -o $@ $<
%.lo: %.c
exec $(REALCC) $(CPPFLAGS_ALL) $(CFLAGS_ALL) $(CFLAGS_SHARED) -c -o $@ $<
$(ALL_BINS):
exec $(REALCC) -o $@ $(CFLAGS_ALL) $(LDFLAGS_ALL) $(LDFLAGS_NOSHARED) $^ $(EXTRA_LIBS) $(LDLIBS_ALL)
lib%.a:
exec $(AR) rc $@ $^
exec $(RANLIB) $@
lib%.so:
exec $(REALCC) -o $@ $(CFLAGS_ALL) $(CFLAGS_SHARED) $(LDFLAGS_ALL) $(LDFLAGS_SHARED) -Wl,-soname,$@.$(version_M) $^
$(ALL_SCRIPTS):
exec sed -e "s/@VERSION@/$(version)/g" -e "s/@BINDIR@/$(subst /,\/,$(bindir))/g" \
-e "s/@LIBEXECDIR@/$(subst /,\/,$(libexecdir))/g" $< > $@
%.1: doc/%.pod doc/footer.pod
@exec cat $< doc/footer.pod > $(basename $@).pod
exec $(POD2MAN) --center="$(package)" --section=1 --release="$(version)" $(basename $@).pod > $@
@exec rm $(basename $@).pod
.PHONY: it all clean distclean tgz strip install install-dynlib install-bin install-sbin install-lib install-include install-doc
.DELETE_ON_ERROR: