1
|
1 dnl Some handy functions
|
|
2
|
|
3 dnl Try a list of directories, set the first one found
|
|
4 dnl Usage: AC_CHECK_DIRS(DIRECTORY..., ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
|
|
5
|
|
6 AC_DEFUN(AC_CHECK_DIRS,
|
|
7 [
|
|
8 for ac_dir in $1
|
|
9 do
|
|
10 AC_MSG_CHECKING([for directory ${ac_dir}])
|
|
11 if test -d ${ac_dir}
|
|
12 then
|
|
13 AC_MSG_RESULT(yes)
|
|
14 ifelse([$2], , :, [$2])
|
|
15 break
|
|
16 else
|
|
17 AC_MSG_RESULT(no)
|
|
18 fi
|
|
19 done
|
|
20 if test ! -d ${ac_dir}
|
|
21 then
|
|
22 ifelse([$3], , :, [$3])
|
|
23 fi
|
|
24 ])
|
|
25
|
|
26 # sidplay.m4 sidplay checks
|
|
27
|
|
28 AC_DEFUN(AC_FIND_FILE,
|
|
29 [
|
|
30 $3=NO
|
|
31 for i in $2;
|
|
32 do
|
|
33 for j in $1;
|
|
34 do
|
|
35 if test -r "$i/$j"; then
|
|
36 $3=$i
|
|
37 break 2
|
|
38 fi
|
|
39 done
|
|
40 done
|
|
41 ]
|
|
42 )
|
|
43
|
|
44 AC_DEFUN(AC_PATH_LIBSIDPLAY,
|
|
45 [
|
|
46 AC_MSG_CHECKING([for SIDPLAY includes and library])
|
|
47 AC_LANG_SAVE
|
|
48 AC_LANG_CPLUSPLUS
|
|
49 ac_sidplay_cflags=NO
|
|
50 ac_sidplay_library=NO
|
|
51 sidplay_cflags=""
|
|
52 sidplay_library=""
|
|
53
|
|
54 AC_ARG_WITH(sidplay-prefix,
|
|
55 [ --with-sidplay-prefix=DIR
|
|
56 where the sidplay includes and library are located],
|
|
57 [ac_sidplay_cflags="${withval}/include"
|
|
58 ac_sidplay_library="${withval}/lib"
|
|
59 ])
|
|
60
|
|
61 AC_ARG_WITH(sidplay-includes,
|
|
62 [ --with-sidplay-includes=DIR
|
|
63 where the sidplay includes are located],
|
|
64 [ac_sidplay_cflags="$withval"
|
|
65 ])
|
|
66
|
|
67 AC_ARG_WITH(sidplay-library,
|
|
68 [ --with-sidplay-library=DIR
|
|
69 where the sidplay library is installed],
|
|
70 [ac_sidplay_library="$withval"
|
|
71 ])
|
|
72
|
|
73 if test "$ac_sidplay_cflags" = NO || test "$ac_sidplay_library" = NO; then
|
|
74 #search common locations
|
|
75
|
|
76 AC_CACHE_VAL(ac_cv_have_sidplay,
|
|
77 [
|
|
78 sidplay_incdirs="$ac_sidplay_cflags /usr/include /usr/local/include /usr/lib/sidplay/include /usr/local/lib/sidplay/include"
|
|
79 AC_FIND_FILE(sidplay/sidtune.h,$sidplay_incdirs,sidplay_foundincdir)
|
|
80 ac_sidplay_cflags=$sidplay_foundincdir
|
|
81
|
|
82 sidplay_libdirs="$ac_sidplay_library /usr/lib /usr/local/lib /usr/lib/sidplay /usr/local/lib/sidplay"
|
|
83 AC_FIND_FILE(libsidplay.so libsidplay.so.1 libsidplay.so.1.36 libsidplay.so.1.37,$sidplay_libdirs,sidplay_foundlibdir)
|
|
84 ac_sidplay_library=$sidplay_foundlibdir
|
|
85
|
|
86 if test "$ac_sidplay_cflags" = NO || test "$ac_sidplay_library" = NO; then
|
|
87 ac_cv_have_sidplay="have_sidplay=no"
|
|
88 ac_sidplay_notfound=""
|
|
89 if test "$ac_sidplay_cflags" = NO; then
|
|
90 if test "$ac_sidplay_library" = NO; then
|
|
91 ac_sidplay_notfound="(headers and library)";
|
|
92 else
|
|
93 ac_sidplay_notfound="(headers)";
|
|
94 fi
|
|
95 else
|
|
96 ac_sidplay_notfound="(library)";
|
|
97 fi
|
|
98 eval "$ac_cv_have_sidplay"
|
|
99 AC_MSG_RESULT([$have_sidplay])
|
|
100 else
|
|
101 have_sidplay=yes
|
|
102 fi
|
|
103
|
|
104 ]) dnl AC_CACHE_VAL(ac_cv_have_sidplay,
|
|
105 else
|
|
106 have_sidplay=yes
|
|
107 fi dnl if (have_to_search)
|
|
108
|
|
109 eval "$ac_cv_have_sidplay"
|
|
110
|
|
111 if test "$have_sidplay" != yes; then
|
|
112 AC_MSG_RESULT([$have_sidplay]);
|
|
113 else
|
|
114 ac_cv_have_sidplay="have_sidplay=yes \
|
|
115 ac_sidplay_cflags=$ac_sidplay_cflags ac_sidplay_library=$ac_sidplay_library"
|
|
116 AC_MSG_RESULT([library $ac_sidplay_library, headers $ac_sidplay_cflags])
|
|
117
|
|
118 sidplay_library=$ac_sidplay_library
|
|
119 sidplay_cflags=$ac_sidplay_cflags
|
|
120
|
|
121 SIDPLAY_LIBS="-L$sidplay_library -lsidplay"
|
|
122 all_libraries="$SIDPLAY_LIBS $all_libraries"
|
|
123 SIDPLAY_CFLAGS="-I$sidplay_cflags"
|
|
124 all_includes="$SIDPLAY_CFLAGS $all_includes"
|
|
125 fi
|
|
126
|
|
127 dnl Test compilation.
|
|
128
|
|
129 AC_MSG_CHECKING([whether -lsidplay works])
|
|
130 ac_cxxflags_safe=$CXXFLAGS
|
|
131 ac_ldflags_safe=$LDFLAGS
|
|
132 ac_libs_safe=$LIBS
|
|
133
|
|
134 CXXFLAGS="$CXXFLAGS -I$sidplay_cflags"
|
|
135 LDFLAGS="$LDFLAGS -L$sidplay_library"
|
|
136 LIBS="-lsidplay"
|
|
137
|
|
138 AC_CACHE_VAL(ac_cv_sidplay_works,
|
|
139 [
|
|
140 AC_TRY_LINK(
|
|
141 [#include <sidplay/sidtune.h>],
|
|
142 [sidTune* myTest;],
|
|
143 [ac_cv_sidplay_works=yes],
|
|
144 [ac_cv_sidplay_works=no]
|
|
145 )
|
|
146 ])
|
|
147
|
|
148 CXXFLAGS="$ac_cxxflags_safe"
|
|
149 LDFLAGS="$ac_ldflags_safe"
|
|
150 LIBS="$ac_libs_safe"
|
|
151
|
|
152 AC_MSG_RESULT([$ac_cv_sidplay_works])
|
|
153 if test "$ac_cv_sidplay_works" != yes; then
|
|
154 have_sidplay=no
|
|
155 fi
|
|
156
|
|
157 dnl
|
|
158
|
|
159 AC_SUBST(SIDPLAY_CFLAGS)
|
|
160 AC_SUBST(SIDPLAY_LIBS)
|
|
161
|
|
162 AC_SUBST(sidplay_library)
|
|
163 AC_SUBST(sidplay_cflags)
|
|
164
|
|
165 AC_LANG_RESTORE
|
|
166
|
|
167 ])
|