Whamcloud - gitweb
cc55395d5910ad91ed32b1d6e60e1d48919948aa
[fs/lustre-release.git] / ldiskfs / build / autoconf / ldiskfs-build.m4
1 #
2 # LB_DOWNSTREAM_RELEASE
3 #
4 AC_DEFUN([LB_DOWNSTREAM_RELEASE],
5 [AC_ARG_WITH([downstream-release],
6         AC_HELP_STRING([--with-downstream-release=string],
7                        [set a string in the BUILD_VERSION and RPM Release: (default is nothing)]),
8         [DOWNSTREAM_RELEASE=$with_downstream_release],
9         [
10         # if not specified, see if it's in the META file
11         if test -f META; then
12                 DOWNSTREAM_RELEASE=$(sed -ne '/^LOCAL_VERSION =/s/.*= *//p' META)
13         fi
14         ])
15 AC_SUBST(DOWNSTREAM_RELEASE)
16 ])
17
18 #
19 # LB_BUILDID
20 #
21 # Check if the source is a GA release and if not, set a "BUILDID"
22 #
23 # Currently there are at least two ways/modes of/for doing this.  One
24 # is if we are in a valid git repository, the other is if we are in a
25 # non-git source tree of some form.  Building the latter from the former
26 # will be handled here.
27 AC_DEFUN([LB_BUILDID],
28 [
29 AC_MSG_CHECKING([for buildid])
30 BUILDID=""
31 if git branch >/dev/null 2>&1; then
32         ffw=0
33         hash=""
34         ver=$(git describe --match v[[0-9]]_*_[[0-9]]* --tags)
35         if [[[ $ver = *-*-* ]]]; then
36                 hash=${ver##*-}
37                 ffw=${ver#*-}
38                 ffw=${ffw%-*}
39                 ver=${ver%%-*}
40         fi
41         # it's tempting to use [[ $ver =~ ^v([0-9]+_)+([0-9]+|RC[0-9]+)$ ]]
42         # here but the portability of the regex on the right is dismal
43         # (thanx suse)
44         if echo "$ver" | egrep -q "^v([[0-9]]+_)+([[0-9]]+|RC[[0-9]]+)$"; then
45                 ver=$(echo $ver | sed -e 's/^v\(.*\)/\1/' \
46                                       -e 's/_RC[[0-9]].*$//' -e 's/_/./g')
47         fi
48
49         # a "lustre fix" value of .0 should be truncated
50         if [[[ $ver = *.*.*.0 ]]]; then
51                 ver=${ver%.0}
52         fi
53         # ditto for a "lustre fix" value of _0
54         if [[[ $ver = v*_*_*_0 ]]]; then
55                 ver=${ver%_0}
56         fi
57         if [[[ $ver = v*_*_* ]]]; then
58                 ver=${ver#v}
59                 ver=${ver//_/.}
60         fi
61
62         if test "$ffw" != "0"; then
63                 BUILDID="$hash"
64                 msg="$BUILDID (ahead by $ffw commits)"
65                 AC_MSG_RESULT([$msg])
66         else
67                 AC_MSG_RESULT([none... congratulations, you must be on a tag])
68         fi
69 elif test -f META; then
70         BUILDID=$(sed -ne '/^BUILDID =/s/.*= *//p' META)
71         msg="$BUILDID (from META file)"
72         AC_MSG_RESULT([$msg])
73 else
74         AC_MSG_WARN([FIXME: I don't know how to deal with source trees outside of git that don't have a META file.  Not setting a buildid.])
75 fi
76 AC_SUBST(BUILDID)
77 ])
78
79 #
80 # LB_CHECK_FILE
81 #
82 # Check for file existance even when cross compiling
83 #
84 AC_DEFUN([LB_CHECK_FILE],
85 [AS_VAR_PUSHDEF([lb_File], [lb_cv_file_$1])dnl
86 AC_CACHE_CHECK([for $1], lb_File,
87 [if test -r "$1"; then
88         AS_VAR_SET(lb_File, yes)
89 else
90         AS_VAR_SET(lb_File, no)
91 fi])
92 AS_IF([test AS_VAR_GET(lb_File) = yes], [$2], [$3])[]dnl
93 AS_VAR_POPDEF([lb_File])dnl
94 ])# LB_CHECK_FILE
95
96 #
97 # LB_CONFIG_HEADERS
98 #
99 # add -include config.h
100 #
101 AC_DEFUN([LB_CONFIG_HEADERS],[
102         AC_CONFIG_HEADERS([config.h])
103         CPPFLAGS="-include $PWD/config.h $CPPFLAGS"
104         EXTRA_KCFLAGS="-include $PWD/config.h $EXTRA_KCFLAGS"
105         AC_SUBST(EXTRA_KCFLAGS)
106 ])
107
108 #
109 # LB_INCLUDE_RULES
110 #
111 # defines for including the toplevel Rules
112 #
113 AC_DEFUN([LB_INCLUDE_RULES],[
114         INCLUDE_RULES="include $PWD/Rules"
115         AC_SUBST(INCLUDE_RULES)
116 ])
117
118 #
119 # LB_PROG_CC
120 #
121 # checks on the C compiler
122 #
123 AC_DEFUN([LB_PROG_CC],
124 [AC_PROG_RANLIB
125
126 # ---------  unsigned long long sane? -------
127 AC_CHECK_SIZEOF(unsigned long long, 0)
128 echo "---> size SIZEOF $SIZEOF_unsigned_long_long"
129 echo "---> size SIZEOF $ac_cv_sizeof_unsigned_long_long"
130 if test $ac_cv_sizeof_unsigned_long_long != 8 ; then
131         AC_MSG_ERROR([** we assume that sizeof(long long) == 8.])
132 fi
133
134 if test $target_cpu == "powerpc64"; then
135         AC_MSG_WARN([set compiler with -m64])
136         CFLAGS="$CFLAGS -m64"
137         CC="$CC -m64"
138 fi
139
140 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
141 AC_SUBST(LLCPPFLAGS)
142
143 # Add _GNU_SOURCE for strnlen on linux
144 LLCFLAGS="-g -Wall -fPIC -D_GNU_SOURCE"
145 AC_SUBST(LLCFLAGS)
146
147 CCASFLAGS="-Wall -fPIC -D_GNU_SOURCE"
148 AC_SUBST(CCASFLAGS)
149 ])
150
151 #
152 # LB_CONFIG_FILES
153 #
154 # build-specific config files
155 #
156 AC_DEFUN([LB_CONFIG_FILES],
157 [
158         AC_CONFIG_FILES([
159                 Makefile
160                 autoMakefile]
161                 [Rules:build/Rules.in]
162                 AC_PACKAGE_TARNAME[.spec]
163         )
164 ])