forked from Rizer/libdeep
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
88 lines (85 loc) · 3.42 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
APP=libdeep
VERSION=1.00
RELEASE=1
SONAME=${APP}.so.0
LIBNAME=${APP}-${VERSION}.so.0.0.${RELEASE}
ARCH_TYPE=`uname -m`
PREFIX?=/usr/local
LIBDIR=lib
ARCH_BUILD_DIR=${HOME}/abs/${APP}
CURR_DIR=$(shell pwd)
SELF_DIR=$(shell basename $(CURR_DIR))
SOURCEFILE?=backprop.c
DATE_FMT = %Y-%m-%d
ifdef SOURCE_DATE_EPOCH
BUILD_DATE ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "+$(DATE_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "+$(DATE_FMT)" 2>/dev/null || date -u "+$(DATE_FMT)")
else
BUILD_DATE ?= $(shell date "+$(DATE_FMT)")
endif
ifeq ($(shell if [ -d /usr/lib64 ]; then echo "found"; fi;), "found")
LIBDIR = lib64
endif
all:
rm -f src/flycheck*
gcc -shared -Wl,-soname,${SONAME} -std=c99 -pedantic -fPIC -O3 -o ${LIBNAME} src/*.c -Isrc -lm -fopenmp
debug:
rm -f src/flycheck*
gcc -shared -Wl,-soname,${SONAME} -std=c99 -pedantic -fPIC -g -o ${LIBNAME} src/*.c -Isrc -lm -fopenmp
debugstack:
rm -f src/flycheck*
gcc -shared -Wl,-soname,${SONAME} -std=c99 -pedantic -fsanitize=address -fPIC -g -o ${LIBNAME} src/*.c -Isrc -lm -fopenmp
graph:
rm -f src/flycheck*
gcc -shared -Wl,-soname,${SONAME} -std=c99 -pedantic -fPIC -g -o ${LIBNAME} src/*.c -Isrc -lm -fopenmp -fdump-rtl-expand
egypt ${SOURCEFILE}.*.expand | xdot -
rm *.expand
source:
tar -cvf ../${APP}_${VERSION}.orig.tar --exclude-vcs ../$(SELF_DIR)
gzip -f9n ../${APP}_${VERSION}.orig.tar
arch:
rm -f ${APP} *.xz *.sig
@if [ ! -d ${ARCH_BUILD_DIR} ]; then\
mkdir -p ${ARCH_BUILD_DIR};\
fi
rm -rf ${ARCH_BUILD_DIR}/*
tar cvf ${ARCH_BUILD_DIR}/${APP}-${VERSION}.tar --exclude-vcs .
gzip -f9n ${ARCH_BUILD_DIR}/${APP}-${VERSION}.tar
cp PKGBUILD ${ARCH_BUILD_DIR}
gpg -ba ${ARCH_BUILD_DIR}/${APP}-${VERSION}.tar.gz
sed -i "s|arch=()|arch=('${ARCH_TYPE}')|g" ${ARCH_BUILD_DIR}/PKGBUILD
cd ${ARCH_BUILD_DIR}; updpkgsums; makepkg -f -c -s; makepkg --printsrcinfo > .SRCINFO
unxz ${ARCH_BUILD_DIR}/${APP}-${VERSION}-${RELEASE}-${ARCH_TYPE}.pkg.tar.xz
tar vf ${ARCH_BUILD_DIR}/${APP}-${VERSION}-${RELEASE}-${ARCH_TYPE}.pkg.tar --delete .BUILDINFO
xz ${ARCH_BUILD_DIR}/${APP}-${VERSION}-${RELEASE}-${ARCH_TYPE}.pkg.tar
gpg -ba ${ARCH_BUILD_DIR}/${APP}-${VERSION}-${RELEASE}-${ARCH_TYPE}.pkg.tar.xz
install:
mkdir -p ${DESTDIR}/usr
mkdir -p ${DESTDIR}${PREFIX}/${LIBDIR}/${APP}
mkdir -p ${DESTDIR}${PREFIX}/include/${APP}
cp src/*.h ${DESTDIR}${PREFIX}/include/${APP}
install -m 755 ${LIBNAME} ${DESTDIR}${PREFIX}/${LIBDIR}
ln -sf ${DESTDIR}${PREFIX}/${LIBDIR}/${LIBNAME} ${DESTDIR}${PREFIX}/${LIBDIR}/${SONAME}
ln -sf ${DESTDIR}${PREFIX}/${LIBDIR}/${LIBNAME} ${DESTDIR}/${LIBDIR}/${SONAME}
ln -sf ${DESTDIR}${PREFIX}/${LIBDIR}/${LIBNAME} ${DESTDIR}${PREFIX}/${LIBDIR}/${APP}.so
ldconfig
mkdir -m 755 -p ${DESTDIR}${PREFIX}/share/man/man1
install -m 644 man/${APP}.1.gz ${DESTDIR}${PREFIX}/share/man/man1
uninstall:
rm -f ${PREFIX}/share/man/man1/${APP}.1.gz
rm -f ${PREFIX}/${LIBDIR}/${LIBNAME}
rm -f ${PREFIX}/${LIBDIR}/${APP}.so
rm -f ${PREFIX}/${LIBDIR}/${SONAME}
rm -f /${LIBDIR}/${SONAME}
rm -rf ${PREFIX}/include/${APP}
ldconfig
instlib:
mkdir -p ${DESTDIR}/usr
mkdir -p ${DESTDIR}${PREFIX}/${LIBDIR}/${APP}
mkdir -p ${DESTDIR}${PREFIX}/include/${APP}
cp src/*.h ${DESTDIR}${PREFIX}/include/${APP}
install -m 755 ${LIBNAME} ${DESTDIR}${PREFIX}/${LIBDIR}
mkdir -m 755 -p ${DESTDIR}${PREFIX}/share/man/man1
install -m 644 man/${APP}.1.gz ${DESTDIR}${PREFIX}/share/man/man1
clean:
rm -f ${LIBNAME} \#* \.#* gnuplot* *.png src/*.plist *.expand
rm -f unittests/*.plist unittests/tests