summaryrefslogtreecommitdiff
path: root/m4/efl_find_x.m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4/efl_find_x.m4')
-rw-r--r--m4/efl_find_x.m4194
1 files changed, 0 insertions, 194 deletions
diff --git a/m4/efl_find_x.m4 b/m4/efl_find_x.m4
deleted file mode 100644
index 8c9f5c3..0000000
--- a/m4/efl_find_x.m4
+++ /dev/null
@@ -1,194 +0,0 @@
1# efl_find.x.m4 - Macros to locate X11. -*- Autoconf -*-
2# EFL_FIND_X(VARIABLE-PREFIX, [headers = "X11/Xlib.h"],
3# [libs-and-functions = "X11 XOpenDisplay"],
4# [action-if-found], [action-if-not-found])
5# checks for X11 using, in order:
6# 1) Xorg pkg-config files (using enviroment variables EFL_X11_CFLAGS
7# and EFL_X11_LIBS if set, but only if x11.pc exists)
8# 2) command line options: --x-includes=dir, --x-libraries=dir
9# assume there is an X11 in the given directories
10# 3) XMKMF environment variable if set
11# 4) xmkmf executable if found
12# 5) list of "standard" directories
13#
14# 2-5 is handled by A_PATH_X
15#
16# If a X11 is found, [action-if-success] is run and VARIABLE_cflags and
17# VARIABLE_libs and VARIABLE_libdirs are defined and substituted.
18# VARIABLE_libs will contain all of the libs listed in libs-and-functions.
19# VARIABLE_libdirs will contain all -Lpath:s found in VARIABLE_libs
20#
21# headers is a list of headers to look for. libs-and-functions is a list of
22# library and function pairs to look for.
23# Each lib and function is checked in pairs, example:
24# EFL_FIND_X([EVAS_X11], [X11/X.h], [X11 XCreateImage Xext XShmCreateImage])
25# will look for XCreateImage in X11 and XShmCreateImage in Xext and include
26# both -lX11 and -lXext in VARIABLE_libs
27#
28# action-if-found is only called if X11, all headers, all libraries and
29# all functions are found.
30# You can call EFL_FIND_X multiple times with different lists of headers, libs
31# and functions.
32
33AC_DEFUN([EFL_FIND_X],
34[
35 # Must print something as AC_CACHE_VAL writes (cached) if the value is cached
36 AC_MSG_CHECKING([how to find X])
37 efl_x11_need_result=1
38 AC_CACHE_VAL(efl_cv_x11_cache,
39 [
40 # this is ugly and breaks that AC_CACHE_VAL may not have side effects
41 # but I can't think of a better way right now
42 efl_x11_need_result=0
43 PKG_CHECK_EXISTS([x11],
44 [
45 AC_MSG_RESULT([use pkg-config])
46 PKG_CHECK_MODULES([EFL_X11],[x11],
47 [
48 efl_cv_have_x11=yes
49 efl_cv_x11_pkgconf=yes
50 efl_cv_x11_cflags=$EFL_X11_CFLAGS
51 efl_cv_x11_libs_pre=$EFL_X11_LIBS
52 efl_cv_x11_libs_post=
53 ])
54 ],
55 [
56 AC_MSG_RESULT([use xmkmf])
57 # Fallback to old AC_PATH_XTRA
58 AC_PATH_X
59 AC_PATH_XTRA
60 if test "$no_x" = yes; then
61 efl_cv_have_x11=no
62 else
63 efl_cv_have_x11=yes
64 efl_cv_x11_pkgconf=no
65 efl_cv_x11_cflags=$X_CFLAGS
66 efl_cv_x11_libs_pre="$X_PRE_LIBS $X_LIBS"
67 efl_cv_x11_libs_post=$X_EXTRA_LIBS
68 fi
69 ])
70 # Record where we found X for the cache.
71 if test "x$efl_cv_have_x11" = "xno"; then
72 efl_cv_x11_cache="efl_cv_have_x11=no"
73 else
74 efl_cv_x11_cache="efl_cv_have_x11=yes\
75 efl_cv_x11_pkgconf='$efl_cv_x11_pkgconf'\
76 efl_cv_x11_cflags='$efl_cv_x11_cflags'\
77 efl_cv_x11_libs_pre='$efl_cv_x11_libs_pre'\
78 efl_cv_x11_libs_post='$efl_cv_x11_libs_post'"
79 fi
80 ])
81 if test "x$efl_x11_need_result" = "x1"; then
82 AC_MSG_RESULT([already found])
83 fi
84 eval "$efl_cv_x11_cache"
85
86 if test "x$efl_cv_have_x11" = "xyes"; then
87 ELF_X11_CFLAGS_save="$CFLAGS"
88 ELF_X11_CPPFLAGS_save="$CPPFLAGS"
89 CFLAGS="$CFLAGS $efl_cv_x11_cflags"
90 CPPFLAGS="$CPPFLAGS $efl_cv_x11_cflags"
91 efl_x11_found_all=1
92 for efl_x11_header in ifelse([$2], , "X11/Xlib.h", [$2]); do
93 AC_CHECK_HEADER([$efl_x11_header],,[
94 efl_x11_found_all=0
95 break])
96 done
97 CPPFLAGS="$ELF_X11_CPPFLAGS_save"
98 CFLAGS="$ELF_X11_CFLAGS_save"
99
100 if test "x$efl_x11_found_all" = "x1"; then
101 EFL_X11_LIBS_save="$LIBS"
102 if test "x$efl_cv_x11_pkgconf" = "xyes"; then
103 efl_x11_modules="x11"
104 efl_x11_lib=""
105 for efl_x11_lib_function in ifelse([$3], , "X11 XOpenDisplay", [$3]); do
106 if test -z "$efl_x11_lib"; then
107 efl_x11_lib="$efl_x11_lib_function"
108 case $efl_x11_lib in
109 X11)
110 ;;
111 Xss)
112 efl_x11_modules="$efl_x11_modules xscrnsaver"
113 ;;
114 *)
115 efl_x11_lib=`echo $efl_x11_lib | tr '[A-Z]' '[a-z]'`
116 efl_x11_modules="$efl_x11_modules $efl_x11_lib"
117 ;;
118 esac
119 else
120 efl_x11_lib=
121 fi
122 done
123 efl_x11_modules="$efl_x11_modules x11-xcb"
124
125 PKG_CHECK_EXISTS([$efl_x11_modules],
126 [
127 PKG_CHECK_MODULES([$1],[$efl_x11_modules],
128 [
129 efl_x11_cflags=$[]$1[]_CFLAGS
130 efl_x11_libs=$[]$1[]_LIBS
131
132 LIBS="$LIBS $[]$1[]_LIBS"
133 efl_x11_lib=""
134 for efl_x11_lib_function in ifelse([$3], , "X11 XOpenDisplay", [$3]); do
135 if test -z "$efl_x11_lib"; then
136 efl_x11_lib="$efl_x11_lib_function"
137 else
138 # This is a ugly way of using AC_CHECK_FUNC with different
139 # LIBS
140 eval "unset ac_cv_func_$efl_x11_lib_function"
141 AC_CHECK_FUNC([$efl_x11_lib_function],,
142 [
143 efl_x11_found_all=0
144 break])
145 efl_x11_lib=
146 fi
147 done
148 ])
149 ],[efl_x11_found_all=0])
150 else
151 LIBS="$LIBS $efl_cv_x11_libs_pre"
152 efl_x11_libs="$efl_cv_x11_libs_pre"
153 efl_x11_lib=""
154 for efl_x11_lib_function in ifelse([$3], , "X11 XOpenDisplay", [$3]); do
155 if test -z "$efl_x11_lib"; then
156 efl_x11_lib="$efl_x11_lib_function"
157 else
158 AC_CHECK_LIB([$efl_x11_lib], [$efl_x11_lib_function],,[
159 efl_x11_found_all=0
160 break],["$efl_cv_x11_libs_post"])
161 efl_x11_libs="$efl_x11_libs -l$efl_x11_lib"
162 efl_x11_lib=
163 fi
164 done
165 if test -n "$efl_cv_x11_libs_post"; then
166 efl_x11_libs="$efl_x11_libs $efl_cv_x11_libs_post"
167 fi
168 fi
169 LIBS="$EFL_X11_LIBS_save"
170 fi
171 fi
172
173 if test "x$efl_x11_found_all" = "x1"; then
174 efl_x11_libdirs=""
175 for efl_x11_option in "$efl_x11_libs"; do
176 case $efl_x11_option in
177 -L*)
178 efl_x11_libdirs="$efl_x11_libdirs $efl_x11_option"
179 ;;
180 *)
181 ;;
182 esac
183 done
184
185 AC_SUBST([$1][_cflags],[$efl_cv_x11_cflags])
186 AC_SUBST([$1][_libs],[$efl_x11_libs])
187 AC_SUBST([$1][_libdirs],[$efl_x11_libdirs])
188
189 ifelse([$4], , :, [$4])
190 else
191 ifelse([$5], , :, [$5])
192 fi
193])
194