File: setup.sh

package info (click to toggle)
wit 3.01a-5.1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 9,468 kB
  • sloc: ansic: 109,416; pascal: 2,205; sh: 1,972; makefile: 770
file content (124 lines) | stat: -rw-r--r-- 2,854 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/env bash

revision=0

if [[ -d .svn ]] && which svn >/dev/null 2>&1
then
    revision="$( svn info . | awk '$1=="Revision:" {print $2}' )"
    if which svnversion >/dev/null 2>&1
    then
	rev="$(svnversion|sed 's/.*://')"
	(( ${revision//[!0-9]/} < ${rev//[!0-9]/} )) && revision=$rev
    fi
fi

revision_num="${revision//[!0-9]/}"
revision_next=$revision_num
[[ $revision = $revision_num ]] || let revision_next++

tim=($(date --utc --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" '+%s %Y-%m-%d %T'))
defines=
: "${CC:=cc}"

have_fuse=0
[[ $NO_FUSE != 1 ]] && echo '#include <fuse.h>' | "$CC" $(pkg-config --cflags fuse) -E - >/dev/null 2>&1 \
	&& have_fuse=1

have_zlib=0
if [[ $NO_ZLIB != 1 ]] && echo '#include <zlib.h>' | "$CC" -E - >/dev/null 2>&1
then
    have_zlib=1
    defines="$defines -DHAVE_ZLIB=1"
fi

if [[ $M32 = 1 ]]
then
    force_m32=1
    have_fuse=0
    xflags="-m32"
    defines="$defines -DFORCE_M32=1"
else
    force_m32=0
    xflags=
fi

echo '#include <fcntl.h>' | "$CC" -E - >/dev/null 2>&1 \
	&& echo '#include <fcntl.h>' | "$CC" -E - 2>/dev/null | grep -qw fallocate \
	&& defines="$defines -DHAVE_FALLOCATE=1"

echo '#include <fcntl.h>' | "$CC" -E - >/dev/null 2>&1 \
	&& echo '#include <fcntl.h>' | "$CC" -E - 2>/dev/null | grep -qw posix_fallocate \
	&& defines="$defines -DHAVE_POSIX_FALLOCATE=1"

echo '#include <linux/fiemap.h>' | "$CC" -E - >/dev/null 2>&1 \
	&& echo '#include <linux/fiemap.h>' | "$CC" -E - 2>/dev/null | grep -qw fiemap_extent \
	&& defines="$defines -DHAVE_FIEMAP=1"

[[ $STATIC = 1 ]] || STATIC=0

#--------------------------------------------------

INSTALL_PATH=/usr/local

if [[ -d $INSTALL_PATH/bin ]]
then
    HAVE_INSTBIN=1
    INSTBIN=$INSTALL_PATH/bin
else
    HAVE_INSTBIN=0
    INSTBIN=/tmp
fi

if [[ -d $INSTALL_PATH/bin32 ]]
then
    HAVE_INSTBIN_32=1
    INSTBIN_32=$INSTALL_PATH/bin32
else
    HAVE_INSTBIN_32=0
    INSTBIN_32=/tmp
fi

if [[ -d $INSTALL_PATH/bin64 ]]
then
    HAVE_INSTBIN_64=1
    INSTBIN_64=$INSTALL_PATH/bin64
elif [[ -d $INSTALL_PATH/bin-x86_64 ]]
then
    HAVE_INSTBIN_64=1
    INSTBIN_64=$INSTALL_PATH/bin-x86_64
else
    HAVE_INSTBIN_64=0
    INSTBIN_64=/tmp
fi

#--------------------------------------------------

cat <<- ---EOT--- >Makefile.setup
	REVISION	:= $revision
	REVISION_NUM	:= $revision_num
	REVISION_NEXT	:= $revision_next
	BINTIME		:= ${tim[0]}
	DATE		:= ${tim[1]}
	TIME		:= ${tim[2]}

	FORCE_M32	:= $force_m32
	HAVE_FUSE	:= $have_fuse
	HAVE_ZLIB	:= $have_zlib
	STATIC		:= $STATIC
	XFLAGS		+= $xflags
	DEFINES1	:= $defines

	HAVE_INSTBIN	:= $HAVE_INSTBIN
	HAVE_INSTBIN_32	:= $HAVE_INSTBIN_32
	HAVE_INSTBIN_64	:= $HAVE_INSTBIN_64

	INSTALL_PATH	:= $INSTALL_PATH
	INSTBIN		:= $INSTBIN
	INSTBIN_32	:= $INSTBIN_32
	INSTBIN_64	:= $INSTBIN_64

	---EOT---

gcc $xflags system.c -o system.tmp && ./system.tmp >>Makefile.setup
rm -f system.tmp