-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
133 lines (107 loc) · 4.36 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
# Edit to adapt
PKGNAME = ziptools
LIBNAME = ziptools
KNOCONFIG = knoconfig
KNOBUILD = knobuild
prefix ::= $(shell ${KNOCONFIG} prefix)
libsuffix ::= $(shell ${KNOCONFIG} libsuffix)
INIT_CFLAGS ::= ${CFLAGS} -I. -fPIC
INIT_LDFAGS ::= ${LDFLAGS} -fPIC
KNO_CFLAGS ::= -I. -fPIC $(shell ${KNOCONFIG} cflags)
KNO_LDFLAGS ::= -fPIC $(shell ${KNOCONFIG} ldflags)
KNO_LIBS ::= $(shell ${KNOCONFIG} libs)
LIBZIP_CFLAGS ::= $(shell INSTALLROOT=libzip-install ./etc/pkc --static --cflags libzip)
LIBZIP_LDFLAGS ::= $(shell INSTALLROOT=libzip-install ./etc/pkc --static --libs libzip)
CMODULES ::= $(DESTDIR)$(shell ${KNOCONFIG} cmodules)
INSTALLMODULES ::= $(DESTDIR)$(shell ${KNOCONFIG} installed_modules)
LIBS ::= $(shell ${KNOCONFIG} libs)
LIB ::= $(shell ${KNOCONFIG} lib)
INCLUDE ::= $(shell ${KNOCONFIG} include)
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 cat ./etc/knomod_version | cut -d. -f1)
FULL_VERSION ::= ${KNO_MAJOR}.${KNO_MINOR}.${PKG_VERSION}
PATCHLEVEL ::= $(shell u8_gitpatchcount ./etc/knomod_version)
PATCH_VERSION ::= ${FULL_VERSION}-${PATCHLEVEL}
SUDO ::= $(shell which sudo)
XCFLAGS = ${INIT_CFLAGS} ${KNO_CFLAGS} ${LIBZIP_CFLAGS}
XLDFLAGS = ${INIT_LDFLAGS} ${KNO_LDFLAGS} ${LIBZIP_LDFLAGS}
MKSO = $(CC) -shared $(LDFLAGS) $(LIBS)
MSG = echo
SYSINSTALL = /usr/bin/install -c
DIRINSTALL = /usr/bin/install -d
MACLIBTOOL = $(CC) -dynamiclib -single_module -undefined dynamic_lookup \
$(LDFLAGS)
GPGID = FE1BC737F9F323D732AA26330620266BE5AFF294
CODENAME ::= $(shell ${KNOCONFIG} codename)
REL_BRANCH ::= $(shell ${KNOBUILD} getbuildopt REL_BRANCH current)
REL_STATUS ::= $(shell ${KNOBUILD} getbuildopt REL_STATUS stable)
REL_PRIORITY ::= $(shell ${KNOBUILD} getbuildopt REL_PRIORITY medium)
ARCH ::= $(shell ${KNOBUILD} getbuildopt BUILD_ARCH || uname -m || echo x86_64)
APKREPO ::= $(shell ${KNOBUILD} getbuildopt APKREPO /srv/repo/kno/apk)
APK_ARCH_DIR = ${APKREPO}/staging/${ARCH}
RPMDIR = dist
default build:
make ziptools.${libsuffix}
ziptools.o: ziptools.c makefile libzip.a
$(CC) $(XCFLAGS) -D_FILEINFO="\"$(shell u8_fileinfo ./$< $(dirname $(pwd))/)\"" -o $@ -c $<
@$(MSG) CC "(ZIPTOOLS)" $@
ziptools.so: ziptools.o makefile
$(MKSO) -o $@ ziptools.o -Wl,-soname=$(@F).${FULL_VERSION} \
-Wl,--allow-multiple-definition \
-Wl,--whole-archive libzip.a -Wl,--no-whole-archive \
${XLDFLAGS}
@$(MSG) MKSO "(ZIPTOOLS)" $@
ziptools.dylib: ziptools.o
@$(MACLIBTOOL) -install_name \
`basename $(@F) .dylib`.${KNO_MAJOR}.dylib \
$(XLDFLAGS) $(DYLIB_FLAGS) $(LIBZIP_LDFLAGS) \
-o $@ ziptools.o
@$(MSG) MACLIBTOOL "(ZIPTOOLS)" $@
${CMODULES}:
@install -d ${CMODULES}
install: install-cmodule install-scheme
install-cmodule: build ${CMODULES}
${SUDO} u8_install_shared ${LIBNAME}.${libsuffix} ${CMODULES} ${FULL_VERSION} "${SYSINSTALL}"
install-scheme:
${SUDO} install -D scheme/gpath/ziptools.scm ${INSTALLMODULES}/gpath/ziptools.scm
clean:
rm -f *.o *.${libsuffix} *.${libsuffix}*
deepclean deep-clean: clean
rm -rf libzip-build libzip-install
fresh: clean
make
deep-fresh: deep-clean
make
gitup gitup-trunk:
git checkout trunk && git pull
# Building libzip.a
libzip-source/THANKS:
git submodule init
git submodule update
libzip.a: libzip-source/THANKS
./build_libzip $@
.PRECIOUS: libzip.a
# Alpine packaging
staging/alpine:
@install -d $@
staging/alpine/APKBUILD: dist/alpine/APKBUILD staging/alpine
cp dist/alpine/APKBUILD staging/alpine
staging/alpine/kno-${PKG_NAME}.tar: staging/alpine
git archive --prefix=kno-${PKG_NAME}/ -o staging/alpine/kno-${PKG_NAME}.tar HEAD
dist/alpine.setup: staging/alpine/APKBUILD makefile ${STATICLIBS} \
staging/alpine/kno-${PKG_NAME}.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