-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
191 lines (157 loc) · 5.87 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
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
187
188
189
190
# Edit to adapt
PKGNAME = mariadb
LIBNAME = mariadb
KNOCONFIG = knoconfig
KNOBUILD = knobuild
prefix ::= $(shell ${KNOCONFIG} prefix)
libsuffix ::= $(shell ${KNOCONFIG} libsuffix)
CMODULES ::= $(DESTDIR)$(shell ${KNOCONFIG} cmodules)
KNO_VERSION ::= $(shell ${KNOCONFIG} version)
KNO_MAJOR ::= $(shell ${KNOCONFIG} major)
KNO_MINOR ::= $(shell ${KNOCONFIG} minor)
PKG_VERSION ::= $(shell u8_gitversion etc/knomod_version)
PKG_MAJOR ::= $(shell echo ${PKG_VERSION} | cut -d. -f1)
PKG_MINOR ::= $(shell echo ${PKG_VERSION} | cut -d. -f2)
PKG_PATCHLEVEL ::= $(shell echo ${PKG_VERSION} | cut -d. -f3)
FULL_VERSION ::= ${KNO_MAJOR}.${PKG_VERSION}
INIT_CFLAGS ::= ${CFLAGS}
INIT_LDFLAGS ::= ${LDFLAGS}
KNO_CFLAGS ::= -I. -fPIC $(shell ${KNOCONFIG} cflags)
KNO_LDFLAGS ::= -fPIC $(shell ${KNOCONFIG} ldflags)
KNO_LIBS ::= $(shell ${KNOCONFIG} libs)
MODULE_CFLAGS ::= $(shell ./etc/getcflags $(LIBNAME))
MODULE_LDFLAGS ::= $(shell ./etc/getlibflags $(LIBNAME))
SUDO ::= $(shell which sudo)
CFLAGS = ${INIT_CFLAGS} ${MODULE_CFLAGS} ${KNO_CFLAGS} ${XCFLAGS}
LDFLAGS = ${INIT_LDFLAGS} ${MODULE_LDFLAGS} ${KNO_LDFLAGS} ${XLDFLAGS}
MKSO = $(CC) -shared $(CFLAGS) $(LDFLAGS) $(LIBS)
SYSINSTALL = /usr/bin/install -c
MSG = echo
MACLIBTOOL = $(CC) -dynamiclib -single_module -undefined dynamic_lookup \
$(LDFLAGS)
# Meta targets
default: ${LIBNAME}.${libsuffix}
build: ${LIBNAME}.${libsuffix}
mariadb.o: mariadb.c makefile
@$(CC) $(CFLAGS) -D_FILEINFO="\"$(shell u8_fileinfo ./$< $(dirname $(pwd))/)\"" -o $@ -c $<
@$(MSG) CC "(MARIADB)" $@
mariadb.so: mariadb.o
$(MKSO) $(LDFLAGS) -o $@ mariadb.o ${LDFLAGS}
@$(MSG) MKSO $@ $<
@ln -sf $(@F) $(@D)/$(@F).${KNO_MAJOR}
mariadb.dylib: mariadb.c makefile
@$(MACLIBTOOL) -install_name \
`basename $(@F) .dylib`.${KNO_MAJOR}.dylib \
${CFLAGS} ${LDFLAGS} -o $@ $(DYLIB_FLAGS) \
mariadb.c
@$(MSG) MACLIBTOOL $@ $<
TAGS: mariadb.c
etags -o TAGS mariadb.c
# Other targets
${CMODULES}:
install -d $@
install: build ${CMODULES}
${SUDO} u8_install_shared ${LIBNAME}.${libsuffix} ${CMODULES} ${FULL_VERSION} "${SYSINSTALL}"
embed-install update: ${PKGNAME}.${libsuffix}
@if test -d ../../../lib/kno; then \
cp ${PKGNAME}.${libsuffix} ../../../lib/kno; \
echo "Updated $(abspath ../../../lib/kno/${PKGNAME}.${libsuffix})"; \
else echo "Not embedded in KNO build"; fi
suinstall doinstall:
sudo make install
clean:
rm -f *.o *.${libsuffix}
fresh:
make clean
make default
gitup gitup-trunk:
git checkout trunk && git pull
buildinfo:
@echo "PKGNAME=$(PKGNAME) LIBNAME=$(LIBNAME)";
@echo " PKG_VERSION=$(PKG_VERSION)";
@echo " FULL_VERSION=$(FULL_VERSION)";
@echo " CFLAGS=$(CFLAGS)";
@echo " LDFLAGS=$(LDFLAGS)";
@echo " libsuffix=$(libsuffix)";
@echo " prefix=$(prefix)";
@echo " MKSO=$(MKSO)";
@echo " MACLIBTOOL=$(MACLIBTOOL)";
@echo " SYSINSTALL=$(SYSINSTALL)";
all_buildinfo: buildinfo
@echo "FULL_VERSION=$(FULL_VERSION)";
@echo " PKG_VERSION=$(PKG_VERSION)";
@echo " KNO_VERSION=$(KNO_VERSION)";
@echo " PKG_MAJOR=$(PKG_MAJOR)";
@echo " PKG_MINOR=$(PKG_MINOR)";
@echo " PKG_PATCHLEVEL=$(PKG_PATCHLEVEL)";
@echo " KNO_MAJOR=$(KNO_MAJOR)";
@echo " KNO_MINOR=$(KNO_MINOR)";
@echo "KNOCONFIG=$(KNOCONFIG)";
@echo " KNOBUILD=$(KNOBUILD)";
@echo " CMODULES=$(CMODULES)";
@echo " INIT_CFLAGS=$(INIT_CFLAGS)";
@echo " INIT_LDFLAGS=$(INIT_LDFLAGS)";
@echo " KNO_CFLAGS=$(KNO_CFLAGS)";
@echo " KNO_LDFLAGS=$(KNO_LDFLAGS)";
@echo " KNO_LIBS=$(KNO_LIBS)";
@echo " MODULE_CFLAGS=$(MODULE_CFLAGS)";
@echo " MODULE_LDFLAGS=$(MODULE_LDFLAGS)";
@echo " SUDO=$(SUDO)";
# RPM packaging
dist/kno-${PKGNAME}.spec: dist/kno-${PKGNAME}.spec.in makefile
u8_xsubst dist/kno-${PKGNAME}.spec dist/kno-${PKGNAME}.spec.in \
"VERSION" "${FULL_VERSION}" \
"PKG_NAME" "${PKGNAME}" && \
touch $@
kno-${PKGNAME}.tar: dist/kno-${PKGNAME}.spec
git archive -o $@ --prefix=kno-${PKGNAME}-${FULL_VERSION}/ HEAD
tar -f $@ -r dist/kno-${PKGNAME}.spec
dist/rpms.ready: kno-${PKGNAME}.tar
rpmbuild $(RPMFLAGS) \
--define="_rpmdir $(RPMDIR)" \
--define="_srcrpmdir $(RPMDIR)" \
--nodeps -ta \
kno-${PKGNAME}.tar && \
touch dist/rpms.ready
dist/rpms.done: dist/rpms.ready
@if (test "$(GPGID)" = "none" || test "$(GPGID)" = "" ); then \
touch dist/rpms.done; \
else \
echo "Enter passphrase for '$(GPGID)':"; \
rpm --addsign --define="_gpg_name $(GPGID)" \
--define="__gpg_sign_cmd $(RPMGPG)" \
$(RPMDIR)/kno-${PKGNAME}-${FULL_VERSION}*.src.rpm \
$(RPMDIR)/*/kno*-@KNO_VERSION@-*.rpm; \
fi && touch dist/rpms.done;
@ls -l $(RPMDIR)/kno-${PKGNAME}-${FULL_VERSION}-*.src.rpm \
$(RPMDIR)/*/kno*-${FULL_VERSION}-*.rpm;
rpms: dist/rpms.done
cleanrpms:
rm -rf dist/rpms.done dist/rpms.ready kno-${PKGNAME}.tar dist/kno-${PKGNAME}.spec
rpmupdate update-rpms freshrpms: cleanrpms
make cleanrpms
make -s dist/rpms.done
dist/rpms.installed: dist/rpms.done
sudo rpm -Uvh ${RPMDIR}/*.rpm && sudo rpm -Uvh ${RPMDIR}/${ARCH}/*.rpm && touch $@
installrpms install-rpms: dist/rpms.installed
# Alpine packaging
staging/alpine:
@install -d $@
staging/alpine/APKBUILD: dist/alpine/APKBUILD staging/alpine
cp dist/alpine/APKBUILD staging/alpine
staging/alpine/kno-${PKGNAME}.tar: staging/alpine
git archive --prefix=kno-${PKGNAME}/ -o staging/alpine/kno-${PKGNAME}.tar HEAD
dist/alpine.setup: staging/alpine/APKBUILD makefile ${STATICLIBS} \
staging/alpine/kno-${PKGNAME}.tar
if [ ! -d ${APK_ARCH_DIR} ]; then mkdir -p ${APK_ARCH_DIR}; fi && \
( cd staging/alpine; \
abuild -P ${APKREPO} clean cleancache cleanpkg && \
abuild checksum ) && \
touch $@
dist/alpine.done: dist/alpine.setup
( cd staging/alpine; abuild -P ${APKREPO} ) && touch $@
dist/alpine.installed: dist/alpine.setup
( cd staging/alpine; abuild -i -P ${APKREPO} ) && touch dist/alpine.done && touch $@
alpine: dist/alpine.done
install-alpine: dist/alpine.done
.PHONY: alpine