f65d26d4c10f663023afe6f6b30f4495a731b830
[openafs.git] / src / cf / ostype.m4
1 AC_DEFUN([OPENAFS_OSTYPE],[
2 AC_MSG_CHECKING(your OS)
3 system=$host
4 case $system in
5         *-linux*)
6
7                 MKAFS_OSTYPE=LINUX
8                 if test "x$enable_redhat_buildsys" = "xyes"; then
9                  AC_DEFINE(ENABLE_REDHAT_BUILDSYS, 1, [define if you have redhat buildsystem])
10                 fi
11                 if test "x$enable_kernel_module" = "xyes"; then
12                  if test "x$with_linux_kernel_headers" != "x"; then
13                    LINUX_KERNEL_PATH="$with_linux_kernel_headers"
14                  else
15                    for utsdir in "/lib/modules/`uname -r`/build" \
16                                  "/lib/modules/`uname -r`/source" \
17                                  "/usr/src/linux-2.4" \
18                                  "/usr/src/linux"; do
19                      LINUX_KERNEL_PATH="$utsdir"
20                      for utsfile in "include/generated/utsrelease.h" \
21                                     "include/linux/utsrelease.h" \
22                                     "include/linux/version.h" \
23                                     "include/linux/version-up.h"; do
24                        if grep "UTS_RELEASE" "$utsdir/$utsfile" >/dev/null 2>&1; then
25                          break 2
26                        fi
27                      done
28                    done
29                  fi
30                  if test "x$with_linux_kernel_build" != "x"; then
31                          LINUX_KERNEL_BUILD="$with_linux_kernel_build"
32                  else
33                    LINUX_KERNEL_BUILD=$LINUX_KERNEL_PATH
34                  fi
35                  if test -f "$LINUX_KERNEL_BUILD/include/generated/utsrelease.h"; then
36                    linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_BUILD/include/generated/utsrelease.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -n 1`
37                    LINUX_VERSION="$linux_kvers"
38                  else
39                    if test -f "$LINUX_KERNEL_BUILD/include/linux/utsrelease.h"; then
40                      linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_BUILD/include/linux/utsrelease.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -n 1`
41                      LINUX_VERSION="$linux_kvers"
42                    else
43                      if test -f "$LINUX_KERNEL_BUILD/include/linux/version.h"; then
44                        linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_BUILD/include/linux/version.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -n 1`
45                        if test "x$linux_kvers" = "x"; then
46                          if test -f "$LINUX_KERNEL_BUILD/include/linux/version-up.h"; then
47                            linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_BUILD/include/linux/version-up.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -n 1`
48                            if test "x$linux_kvers" = "x"; then
49                              AC_MSG_ERROR(Linux headers lack version definition [2])
50                              exit 1
51                            else
52                              LINUX_VERSION="$linux_kvers"
53                            fi
54                          else
55                            AC_MSG_ERROR(Linux headers lack version definition)
56                            exit 1
57                          fi
58                        else
59                          LINUX_VERSION="$linux_kvers"
60                        fi
61                      else
62                        enable_kernel_module="no"
63                      fi
64                    fi
65                  fi
66                  if test ! -f "$LINUX_KERNEL_BUILD/include/generated/autoconf.h" &&
67                     test ! -f "$LINUX_KERNEL_BUILD/include/linux/autoconf.h"; then
68                      enable_kernel_module="no"
69                  fi
70                  if test "x$enable_kernel_module" = "xno"; then
71                   if test "x$with_linux_kernel_headers" != "x"; then
72                    AC_MSG_ERROR(No usable linux headers found at $LINUX_KERNEL_PATH)
73                    exit 1
74                   else
75                    AC_MSG_WARN(No usable linux headers found at $LINUX_KERNEL_PATH so disabling kernel module)
76                   fi
77                  fi
78                  dnl do we need to determine SUBARCH from autoconf.h
79                  SUBARCH=default
80                 fi
81                 AC_MSG_RESULT(linux)
82                 GUESS_LINUX_VERSION=
83                 if test "x$enable_kernel_module" = "xyes"; then
84                  GUESS_LINUX_VERSION=${LINUX_VERSION}
85                 else
86                  GUESS_LINUX_VERSION=`uname -r`
87                 fi
88                 case "$GUESS_LINUX_VERSION" in
89                   2.2.*) AFS_SYSKVERS=22 ;;
90                   2.4.*) AFS_SYSKVERS=24 ;;
91                   [2.6.* | [3-9]* | [1-2][0-9]*]) AFS_SYSKVERS=26 ;;
92                   *) AC_MSG_ERROR(Couldn't guess your Linux version [2]) ;;
93                 esac
94                 ;;
95         *-solaris*)
96                 MKAFS_OSTYPE=SOLARIS
97                 AC_MSG_RESULT(sun4)
98                 SOLARIS_PATH_CC
99                 SOLARIS_CC_TAKES_XVECTOR_NONE
100                 AC_SUBST(SOLARIS_CC_KOPTS)
101                 SOLARIS_UFSVFS_HAS_DQRWLOCK
102                 SOLARIS_FS_HAS_FS_ROLLED
103                 SOLARIS_SOLOOKUP_TAKES_SOCKPARAMS
104                 SOLARIS_HAVE_VN_RENAMEPATH
105                 ;;
106         *-sunos*)
107                 MKAFS_OSTYPE=SUNOS
108                 enable_kernel_module=no
109                 AC_MSG_RESULT(sun4)
110                 ;;
111         *-hpux*)
112                 MKAFS_OSTYPE=HPUX
113                 AC_MSG_RESULT(hp_ux)
114                 if test -f "/usr/old/usr/include/ndir.h"; then
115                  AC_DEFINE(HAVE_USR_OLD_USR_INCLUDE_NDIR_H, 1, [define if you have old ndir.h])
116                 fi
117                 ;;
118         *-irix*)
119                 if test -d /usr/include/sys/SN/SN1; then
120                  IRIX_BUILD_IP35="IP35"
121                 fi
122                 MKAFS_OSTYPE=IRIX
123                 AC_MSG_RESULT(sgi)
124                 ;;
125         *-aix*)
126                 MKAFS_OSTYPE=AIX
127                 AC_MSG_RESULT(rs_aix)
128                 ;;
129         arm-*-darwin*)
130                 MKAFS_OSTYPE=DARWIN
131                 AC_MSG_RESULT(arm_darwin)
132                 ;;
133         powerpc-*-darwin*)
134                 MKAFS_OSTYPE=DARWIN
135                 AC_MSG_RESULT(ppc_darwin)
136                 ;;
137         i386-*-darwin*)
138                 MKAFS_OSTYPE=DARWIN
139                 AC_MSG_RESULT(x86_darwin)
140                 ;;
141         x86_64-*-darwin*)
142                 MKAFS_OSTYPE=DARWIN
143                 AC_MSG_RESULT(x86_darwin)
144                 ;;
145         i386-*-freebsd*)
146                 MKAFS_OSTYPE=FBSD
147                 AC_MSG_RESULT(i386_fbsd)
148                 ;;
149         x86_64-*-freebsd*)
150                 MKAFS_OSTYPE=FBSD
151                 AC_MSG_RESULT(amd64_fbsd)
152                 ;;
153         *-netbsd*)
154                 MKAFS_OSTYPE=NBSD
155                 AC_MSG_RESULT(nbsd)
156                 ;;
157         x86_64-*-openbsd*)
158                 MKAFS_OSTYPE=OBSD
159                 AC_MSG_RESULT(amd64_obsd)
160                 ;;
161         i386-*-openbsd*)
162                 MKAFS_OSTYPE=OBSD
163                 AC_MSG_RESULT(i386_obsd)
164                 ;;
165         *-dragonfly*)
166                 MKAFS_OSTYPE=DFBSD
167                 AC_MSG_RESULT(i386_dfbsd)
168                 ;;
169         *)
170                 AC_MSG_RESULT($system)
171                 ;;
172 esac
173 ])