-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
130 lines (104 loc) · 4.3 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
PKGNAME = readstat
LIBNAME = creadstat
KNOCONFIG = knoconfig
KNOBUILD = knobuild
prefix ::= $(shell ${KNOCONFIG} prefix)
libsuffix ::= $(shell ${KNOCONFIG} libsuffix)
KNO_CFLAGS ::= -I. -fPIC $(shell ${KNOCONFIG} cflags)
KNO_LDFLAGS ::= -fPIC $(shell ${KNOCONFIG} ldflags)
KNO_LIBS ::= $(shell ${KNOCONFIG} libs)
CMODULES ::= $(DESTDIR)$(shell ${KNOCONFIG} cmodules)
INSTALLMODS ::= $(DESTDIR)$(shell ${KNOCONFIG} installmods)
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}
INSTALLS ::= "$(shell pwd)/installs"
SUDO ::= $(shell which sudo)
INIT_CFLAGS ::= ${CFLAGS} -Iinstalls/include
INIT_LDFAGS ::= ${LDFLAGS} -Linstalls/lib
XCFLAGS = ${INIT_CFLAGS} ${READSTAT_CFLAGS} ${KNO_CFLAGS} ${DEBUG_CFLAGS}
XLDFLAGS = ${INIT_LDFLAGS} ${KNO_LDFLAGS} ${BSON_LDFLAGS} ${READSTAT_LDFLAGS}
MKSO = $(CC) -shared $(LDFLAGS) $(LIBS)
SYSINSTALL = /usr/bin/install -c
DIRINSTALL = /usr/bin/install -d
MODINSTALL = /usr/bin/install -m 0664
USEDIR = /usr/bin/install -d
MSG = echo
MACLIBTOOL = $(CC) -dynamiclib -single_module -undefined dynamic_lookup \
$(LDFLAGS)
GPGID ::= ${OVERRIDE_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)
APKREPO ::= $(shell ${KNOBUILD} getbuildopt APKREPO /srv/repo/kno/apk)
APK_ARCH_DIR = ${APKREPO}/staging/${ARCH}
RPMDIR = dist
STATICLIBS=installs/lib/libcsv.a installs/lib/libreadstat.a
default:
@make ${STATICLIBS}
@make creadstat.${libsuffix}
creadstat.o: creadstat.c makefile ${STATICLIBS}
@echo XCFLAGS=${XCFLAGS}
@$(CC) --save-temps $(XCFLAGS) -fPIC -D_FILEINFO="\"$(shell u8_fileinfo ./$< $(dirname $(pwd))/)\"" -o $@ -c $<
@$(MSG) CC "(CREADSTAT)" $@
creadstat.so: creadstat.o makefile
@$(MKSO) -o $@ creadstat.o -Wl,-soname=$(@F).${FULL_VERSION} \
-Wl,--allow-multiple-definition \
-Wl,--whole-archive ${STATICLIBS} -Wl,--no-whole-archive \
$(XLDFLAGS)
@$(MSG) MKSO "(CREADSTAT)" $@
creadstat.dylib: creadstat.o makefile ${STATICLIBS}
@$(MACLIBTOOL) -install_name \
`basename $(@F) .dylib`.${KNO_MAJOR}.dylib \
$(DYLIB_FLAGS) $(BSON_LDFLAGS) $(READSTAT_LDFLAGS) \
-o $@ creadstat.o
@$(MSG) MACLIBTOOL "(CREADSTAT)" $@
debug: clean
make DEBUG_CFLAGS='-O0 -g3' default
# Components
installs/lib/libcsv.a: libcsv/Makefile.am
./build_libcsv $(INSTALLS)
installs/lib/libreadstat.a: libreadstat/Makefile.am installs/lib/libcsv.a
./build_libreadstat $(INSTALLS)
libcsv/Makefile.am libreadstat/Makefile.am:
git submodule update --init
staticlibs: ${STATICLIBS}
readstat.dylib readstat.so: staticlibs
scheme/readstat.zip: scheme/readstat/*.scm
cd scheme; zip readstat.zip readstat -x "*~" -x "#*" -x "*.attic/*" -x ".git*"
install: install-cmodule install-scheme
suinstall doinstall:
sudo make install
${CMODULES}:
@${DIRINSTALL} ${CMODULES}
install-cmodule: ${CMODULES}
${SUDO} u8_install_shared ${LIBNAME}.${libsuffix} ${CMODULES} ${FULL_VERSION} "${SYSINSTALL}"
${INSTALLMODS}/readstat:
${SUDO} ${DIRINSTALL} $@
install-scheme: ${INSTALLMODS}/readstat
${SUDO} ${MODINSTALL} scheme/readstat/*.scm ${INSTALLMODS}/readstat
clean:
rm -f *.o *.${libsuffix} *.${libsuffix}*
deepclean deep-clean: clean
if [ -f libreadstat/Makefile ]; then cd libreadstat; make clean; fi
if [ -f librdata/Makefile ]; then cd librdata; make clean; fi
if [ -f libcsv/Makefile ]; then cd libcsv; make clean; fi
rm -rf build_*
fresh: clean
make
deep-fresh: deep-clean
make
gitup gitup-trunk:
git checkout trunk && git pull
TAGS: creadstat.c scheme/readstat/*.scm
etags -o $@ $^