merged michaelld/usrp2_config [9614] into trunk. Fixes non-Linux builds
[debian/gnuradio] / config / grc_usrp2.m4
1 dnl Copyright 2008 Free Software Foundation, Inc.
2 dnl 
3 dnl This file is part of GNU Radio
4 dnl 
5 dnl GNU Radio is free software; you can redistribute it and/or modify
6 dnl it under the terms of the GNU General Public License as published by
7 dnl the Free Software Foundation; either version 3, or (at your option)
8 dnl any later version.
9 dnl 
10 dnl GNU Radio is distributed in the hope that it will be useful,
11 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 dnl GNU General Public License for more details.
14 dnl 
15 dnl You should have received a copy of the GNU General Public License
16 dnl along with GNU Radio; see the file COPYING.  If not, write to
17 dnl the Free Software Foundation, Inc., 51 Franklin Street,
18 dnl Boston, MA 02110-1301, USA.
19
20 AC_DEFUN([GRC_USRP2],[
21     GRC_ENABLE(usrp2)
22
23     dnl Don't do usrp if omnithread or gruel is skipped
24     GRC_CHECK_DEPENDENCY(usrp2, gruel)
25     GRC_CHECK_DEPENDENCY(usrp2, omnithread)
26
27     dnl USRP2 host code only works on Linux at the moment
28     AC_MSG_CHECKING([whether host_os is linux*])
29     case "$host_os" in
30       linux*)
31         AC_MSG_RESULT([yes])
32         ;;
33       *)
34         AC_MSG_RESULT([no])
35         AC_MSG_NOTICE([USRP2 currently requires Linux host OS, not found])
36         AM_CONDITIONAL([BUILDING_USRP2_FIRMWARE],[0])
37         passed="no"
38         ;;
39     esac
40
41     dnl If execution gets to here, $passed will be:
42     dnl   with : if the --with code didn't error out
43     dnl   yes  : if the --enable code passed muster and all dependencies are met
44     dnl   no   : otherwise
45     if test $passed = yes; then
46         dnl Only do firmware if mb-gcc can be found
47         AC_CHECK_PROG([MB_GCC],[mb-gcc],[yes],[no])
48         if test $MB_GCC = yes; then
49             dnl Adds usrp2/firmware to $(subdirs), hierarchical build
50             AC_CONFIG_SUBDIRS([usrp2/firmware])
51         else
52             AC_MSG_WARN([usrp2/firmware is not being built])
53         fi
54         AM_CONDITIONAL([BUILDING_USRP2_FIRMWARE],[test $MB_GCC = yes])
55
56         dnl Needed for usrp2_socket_opener
57         AC_CHECK_HEADERS(arpa/inet.h byteswap.h linux/if_packet.h sys/socket.h sys/un.h)
58         AC_CHECK_MEMBERS([struct msghdr.msg_control,
59                           struct msghdr.msg_accrights,
60                           struct cmsgcred.cmcred_uid,
61                           struct ucred.uid],
62                          [],[],
63                          [#define __USE_GNU 1
64                           #include <sys/types.h>
65                           #include <sys/socket.h>
66                           #include <sys/un.h>])
67     fi
68     if test $passed != with; then
69         dnl how and where to find INCLUDES and LA
70         USRP2_INCLUDES="-I\${abs_top_srcdir}/usrp2/host/include \
71                 -I\${abs_top_srcdir}/usrp2/firmware/include"
72         USRP2_LA="\${abs_top_builddir}/usrp2/host/lib/libusrp2.la"
73     fi
74
75     dnl Include the usrp2 INCLUDES and LA
76     AC_SUBST(USRP2_INCLUDES)
77     AC_SUBST(USRP2_LA)
78
79     AC_CONFIG_FILES([ \
80         usrp2/Makefile
81         usrp2/host/Makefile \
82         usrp2/host/usrp2.pc \
83         usrp2/host/include/Makefile
84         usrp2/host/include/usrp2/Makefile
85         usrp2/host/lib/Makefile
86         usrp2/host/apps/Makefile
87     ])
88
89     GRC_BUILD_CONDITIONAL(usrp2)
90 ])