-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
160 lines (131 loc) · 4.82 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
PKGNAME = archivetools # Edit to adapt
LIBNAME = archivetools
KNOCONFIG = knoconfig
KNOBUILD = knobuild
prefix ::= $(shell ${KNOCONFIG} prefix)
libsuffix ::= $(shell ${KNOCONFIG} libsuffix)
CMODULES ::= $(DESTDIR)$(shell ${KNOCONFIG} cmodules)
INSTALLMODS ::= $(DESTDIR)$(shell ${KNOCONFIG} installmods)
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}.${KNO_MINOR}.${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 libarchive)
MODULE_LDFLAGS ::= $(shell ./etc/getlibflags libarchive)
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 -m a+r,ug+w
MSG = echo
MACLIBTOOL = $(CC) -dynamiclib -single_module -undefined dynamic_lookup \
$(LDFLAGS)
# Meta targets
# .buildmode contains the default build target (standard|debugging)
# debug/normal targets change the buildmode
# module build targets depend on .buildmode
default build: .buildmode
make $(shell cat .buildmode)
module: ${LIBNAME}.${libsuffix}
standard:
make module
debugging:
make XCFLAGS="-O0 -g3" module
.buildmode:
echo standard > .buildmode
debug:
echo debugging > .buildmode
make
normal:
echo standard > .buildmode
make
# Basic targets (Edit to adapt)
archivetools.o: archivetools.c makefile
@$(CC) $(CFLAGS) -D_FILEINFO="\"$(shell u8_fileinfo ./$< $(dirname $(pwd))/)\"" -o $@ -c $<
@$(MSG) CC "(ARCHIVETOOLS)" $@
archivetools.so: archivetools.o
@$(MKSO) $(LDFLAGS) -o $@ archivetools.o ${LDFLAGS}
@$(MSG) MKSO $@ $<
@ln -sf $(@F) $(@D)/$(@F).${KNO_MAJOR}
archivetools.dylib: archivetools.c makefile
@$(MACLIBTOOL) -install_name \
`basename $(@F) .dylib`.${KNO_MAJOR}.dylib \
${CFLAGS} ${LDFLAGS} -o $@ $(DYLIB_FLAGS) \
archivetools.c
@$(MSG) MACLIBTOOL $@ $<
TAGS: archivetools.c
etags -o TAGS archivetools.c
# Other targets
${CMODULES} ${INSTALLMODS} ${INSTALLMODS}/io:
install -d $@
install: build ${CMODULES} ${INSTALLMODS}/io
${SUDO} u8_install_shared "${LIBNAME}.${libsuffix}" "${CMODULES}" "${FULL_VERSION}" "${SYSINSTALL}"
${SUDO} $(SYSINSTALL) io/filestream.scm $(INSTALLMODS)/io/filestream.scm
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)";
# 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