RTEMS: Update RTEMS thread model
[official-gcc.git] / libgomp / plugin / configfrag.ac
blob8c2a420d793338337c960edd27fc9d458edf7953
1 # Plugins for offload execution, configure.ac fragment.  -*- mode: autoconf -*-
3 # Copyright (C) 2014-2015 Free Software Foundation, Inc.
5 # Contributed by Mentor Embedded.
7 # This file is part of the GNU Offloading and Multi Processing Library
8 # (libgomp).
10 # Libgomp is free software; you can redistribute it and/or modify it
11 # under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 3, or (at your option)
13 # any later version.
15 # Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
18 # more details.
20 # Under Section 7 of GPL version 3, you are granted additional
21 # permissions described in the GCC Runtime Library Exception, version
22 # 3.1, as published by the Free Software Foundation.
24 # You should have received a copy of the GNU General Public License and
25 # a copy of the GCC Runtime Library Exception along with this program;
26 # see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
27 # <http://www.gnu.org/licenses/>.
29 offload_targets=
30 AC_SUBST(offload_targets)
31 plugin_support=yes
32 AC_CHECK_LIB(dl, dlsym, , [plugin_support=no])
33 if test x"$plugin_support" = xyes; then
34   AC_DEFINE(PLUGIN_SUPPORT, 1,
35     [Define if all infrastructure, needed for plugins, is supported.])
36 elif test "x${enable_offload_targets-no}" != xno; then
37   AC_MSG_ERROR([Can't support offloading without support for plugins])
40 # Look for the CUDA driver package.
41 CUDA_DRIVER_INCLUDE=
42 CUDA_DRIVER_LIB=
43 AC_SUBST(CUDA_DRIVER_INCLUDE)
44 AC_SUBST(CUDA_DRIVER_LIB)
45 CUDA_DRIVER_CPPFLAGS=
46 CUDA_DRIVER_LDFLAGS=
47 AC_ARG_WITH(cuda-driver,
48         [AS_HELP_STRING([--with-cuda-driver=PATH],
49                 [specify prefix directory for installed CUDA driver package.
50                  Equivalent to --with-cuda-driver-include=PATH/include
51                  plus --with-cuda-driver-lib=PATH/lib])])
52 AC_ARG_WITH(cuda-driver-include,
53         [AS_HELP_STRING([--with-cuda-driver-include=PATH],
54                 [specify directory for installed CUDA driver include files])])
55 AC_ARG_WITH(cuda-driver-lib,
56         [AS_HELP_STRING([--with-cuda-driver-lib=PATH],
57                 [specify directory for the installed CUDA driver library])])
58 if test "x$with_cuda_driver" != x; then
59   CUDA_DRIVER_INCLUDE=$with_cuda_driver/include
60   CUDA_DRIVER_LIB=$with_cuda_driver/lib
62 if test "x$with_cuda_driver_include" != x; then
63   CUDA_DRIVER_INCLUDE=$with_cuda_driver_include
65 if test "x$with_cuda_driver_lib" != x; then
66   CUDA_DRIVER_LIB=$with_cuda_driver_lib
68 if test "x$CUDA_DRIVER_INCLUDE" != x; then
69   CUDA_DRIVER_CPPFLAGS=-I$CUDA_DRIVER_INCLUDE
71 if test "x$CUDA_DRIVER_LIB" != x; then
72   CUDA_DRIVER_LDFLAGS=-L$CUDA_DRIVER_LIB
75 PLUGIN_NVPTX=0
76 PLUGIN_NVPTX_CPPFLAGS=
77 PLUGIN_NVPTX_LDFLAGS=
78 PLUGIN_NVPTX_LIBS=
79 AC_SUBST(PLUGIN_NVPTX)
80 AC_SUBST(PLUGIN_NVPTX_CPPFLAGS)
81 AC_SUBST(PLUGIN_NVPTX_LDFLAGS)
82 AC_SUBST(PLUGIN_NVPTX_LIBS)
84 # Get offload targets and path to install tree of offloading compiler.
85 offload_additional_options=
86 offload_additional_lib_paths=
87 AC_SUBST(offload_additional_options)
88 AC_SUBST(offload_additional_lib_paths)
89 if test x"$enable_offload_targets" != x; then
90   for tgt in `echo $enable_offload_targets | sed -e 's#,# #g'`; do
91     tgt_dir=`echo $tgt | grep '=' | sed 's/.*=//'`
92     tgt=`echo $tgt | sed 's/=.*//'`
93     case $tgt in
94       *-intelmic-* | *-intelmicemul-*)
95         tgt_name=intelmic
96         ;;
97       nvptx*)
98         tgt_name=nvptx
99         PLUGIN_NVPTX=$tgt
100         PLUGIN_NVPTX_CPPFLAGS=$CUDA_DRIVER_CPPFLAGS
101         PLUGIN_NVPTX_LDFLAGS=$CUDA_DRIVER_LDFLAGS
102         PLUGIN_NVPTX_LIBS='-lcuda'
104         PLUGIN_NVPTX_save_CPPFLAGS=$CPPFLAGS
105         CPPFLAGS="$PLUGIN_NVPTX_CPPFLAGS $CPPFLAGS"
106         PLUGIN_NVPTX_save_LDFLAGS=$LDFLAGS
107         LDFLAGS="$PLUGIN_NVPTX_LDFLAGS $LDFLAGS"
108         PLUGIN_NVPTX_save_LIBS=$LIBS
109         LIBS="$PLUGIN_NVPTX_LIBS $LIBS"
110         AC_LINK_IFELSE(
111           [AC_LANG_PROGRAM(
112             [#include "cuda.h"],
113               [CUresult r = cuCtxPushCurrent (NULL);])],
114           [PLUGIN_NVPTX=1])
115         CPPFLAGS=$PLUGIN_NVPTX_save_CPPFLAGS
116         LDFLAGS=$PLUGIN_NVPTX_save_LDFLAGS
117         LIBS=$PLUGIN_NVPTX_save_LIBS
118         case $PLUGIN_NVPTX in
119           nvptx*)
120             PLUGIN_NVPTX=0
121             AC_MSG_ERROR([CUDA driver package required for nvptx support])
122             ;;
123         esac
124         ;;
125       *)
126         AC_MSG_ERROR([unknown offload target specified])
127         ;;
128     esac
129     if test x"$offload_targets" = x; then
130       offload_targets=$tgt_name
131     else
132       offload_targets=$offload_targets,$tgt_name
133     fi
134     if test x"$tgt_dir" != x; then
135       offload_additional_options="$offload_additional_options -B$tgt_dir/libexec/gcc/\$(target_alias)/\$(gcc_version) -B$tgt_dir/bin"
136       offload_additional_lib_paths="$offload_additional_lib_paths:$tgt_dir/lib64:$tgt_dir/lib:$tgt_dir/lib32"
137     else
138       offload_additional_options="$offload_additional_options -B\$(libexecdir)/gcc/\$(target_alias)/\$(gcc_version) -B\$(bindir)"
139       offload_additional_lib_paths="$offload_additional_lib_paths:$toolexeclibdir"
140     fi
141   done
143 AC_DEFINE_UNQUOTED(OFFLOAD_TARGETS, "$offload_targets",
144   [Define to hold the list of target names suitable for offloading.])
145 AM_CONDITIONAL([PLUGIN_NVPTX], [test $PLUGIN_NVPTX = 1])
146 AC_DEFINE_UNQUOTED([PLUGIN_NVPTX], [$PLUGIN_NVPTX],
147   [Define to 1 if the NVIDIA plugin is built, 0 if not.])