Upstream tarball 9539
[amule.git] / acinclude.m4
blobde4daff08a8ccd2429498ec8876e7cd35e90d1ab
1 #                                                       -*- Autoconf -*-
2 # This file is part of the aMule Project.
4 # Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
6 # Any parts of this program derived from the xMule, lMule or eMule project,
7 # or contributed by third-party developers are copyrighted by their
8 # respective authors.
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA
25 dnl ---------------------------------------------------------------------------
26 dnl Helper functions
27 dnl ---------------------------------------------------------------------------
28 m4_pattern_forbid(MULE_)dnl Check for unexpanded *MULE_* macros
29 m4_pattern_allow(AMULE_)dnl Allow the *AMULE_* names
31 dnl MULE_APPEND(VARNAME, VALUE)
32 AC_DEFUN([MULE_APPEND], [$1="$$1 $2"])
34 dnl MULE_PREPEND(VARNAME, VALUE)
35 AC_DEFUN([MULE_PREPEND], [$1="$2 $$1"])
37 dnl MULE_ADDFLAG(FLAGTYPE, VALUE)
38 AC_DEFUN([MULE_ADDFLAG], [MULE_APPEND([MULE[]$1[]FLAGS], [$2])])
40 dnl MULE_ADDCCXXFLAG(VALUE)
41 AC_DEFUN([MULE_ADDCCXXFLAG],
43         MULE_ADDFLAG([C], [$1])
44         MULE_ADDFLAG([CXX], [$1])
47 dnl MULE_BACKUP(VAR)
48 AC_DEFUN([MULE_BACKUP], [mule_backup_$1="$$1"])
50 dnl MULE_RESTORE(VAR)
51 AC_DEFUN([MULE_RESTORE], [$1="$mule_backup_$1"])
53 dnl ---------------------------------------------------------------------------
54 dnl MULE_IF(CONDITION, [IF-TRUE] [, ELIF-CONDITION, [IF-TRUE]]... [, ELSE-BRANCH])
55 dnl
56 dnl Works like AS_IF(), but allows elif-branches too.
57 dnl ---------------------------------------------------------------------------
58 m4_define([__mule_if_helper],
59 [m4_if( [$#], 0,,
60         [$#], 1, [m4_ifvaln([$1], [m4_n([else])  $1])],
61         [m4_n([elif $1; then])  m4_ifvaln([$2], [$2], :)])dnl
62 m4_if(m4_eval([$# > 2]), 1, [$0(m4_shiftn(2, $@))])])
64 m4_define([MULE_IF],
65 [m4_if( [$#], 0,,
66         [$#], 1,,
67         [m4_n([if $1; then])  m4_ifval([$2],[$2], :)
68 m4_if(m4_eval([$# > 2]), 1, [__mule_if_helper(m4_shiftn(2, $@))])m4_n([fi])])])
70 dnl ---------------------------------------------------------------------------
71 dnl MULE_WARNING(MESSAGE)
72 dnl
73 dnl Works like AC_MSG_WARN(), but the warning will be reproduced at the end of
74 dnl the configure run. An empty line is prepended at the final output and a
75 dnl newline is appended for free.
76 dnl ---------------------------------------------------------------------------
77 m4_define([_MULE_WARNINGS],
78         [m4_ifdef([_m4_divert(BODY)], incr(_m4_divert(BODY)), [5000])])
79 m4_define([_MULE_WARNCOUNT], [0])
81 m4_divert_push(_MULE_WARNINGS)dnl
82 if test ${_mule_has_warnings:-no} = yes; then
83 echo ""
84 echo ""
85 echo " *** Warnings during configuration ***"
87 m4_divert_pop()dnl
89 m4_define([MULE_WARNING],
90 [AC_MSG_WARN(
91 m4_pushdef([_mule_Prefix], [        ])dnl
92 m4_foreach([_mule_Line], m4_quote(m4_split([$1], [
93 ])), [
94 m4_text_wrap(m4_defn([_mule_Line]), _mule_Prefix)])[]dnl
95 m4_popdef([_mule_Prefix])dnl
97 _mule_warning_[]_MULE_WARNCOUNT[]=yes
98 _mule_has_warnings=yes
99 m4_divert_push(_MULE_WARNINGS)dnl
100 if test ${_mule_warning_[]_MULE_WARNCOUNT[]:-no} = yes; then
101 cat <<_MULEEOT
103 m4_pushdef([_mule_Prefix1], [* ])dnl
104 m4_pushdef([_mule_Prefix], [  ])dnl
105 m4_foreach([_mule_Line], m4_quote(m4_split([$1], [
106 ])), [m4_text_wrap(m4_defn([_mule_Line]), _mule_Prefix, _mule_Prefix1)
107 m4_define([_mule_Prefix1], _mule_Prefix)dnl
108 ])[]dnl
109 m4_popdef([_mule_Prefix])dnl
110 m4_popdef([_mule_Prefix1])dnl
111 _MULEEOT
113 m4_divert_pop()dnl
114 m4_define([_MULE_WARNCOUNT], incr(_MULE_WARNCOUNT))])
116 dnl ---------------------------------------------------------------------------
117 dnl MULE_CHECK_SYSTEM
119 dnl Checks host system type, and sets system-specific flags accordingly.
120 dnl Sets $SYS to the name of the host os.
121 dnl ---------------------------------------------------------------------------
122 AC_DEFUN([MULE_CHECK_SYSTEM],
123 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
125         case "${host_os}" in
126         darwin*)
127                 SYS=darwin
128                 MULECPPFLAGS="-no-cpp-precomp -D_INTL_REDIRECT_MACROS -DNOPCH";
129                 MULELDFLAGS="-bind_at_load"
130                 touch src/Scanner.cpp
131                 ;;
132         openbsd*) 
133                 SYS=openbsd
134                 LIBS="$LIBS -L/usr/local/lib"
135                 X11LIBS="-lX11 -L/usr/X11R6/lib"
136                 MULECPPFLAGS="-D__OPENBSD__"
137                 ;;
138         *cygwin* | *mingw32*)
139                 SYS=win32
140                 MULECPPFLAGS="-DNOMINMAX"
141                 ;;
142         solaris*)
143                 SYS=solaris
144                 RESOLV_LIB="-lresolv -lnsl"
145                 X11LIBS="-lX11"
146                 LIBS="$LIBS -lrt"
147                 ;;
148         *netbsd*)
149                 SYS=netbsd
150                 # Now this is against autoconf recommendation that configure should not modify CPPFLAGS and LDFLAGS
151                 # However, these values in NetBSD are required even to run the tests, and this is the easiest way to do it.
152                 # Still, we prepend them, instead of adding, so the user may override them.
153                 MULE_PREPEND([CPPFLAGS], [-I/usr/pkg/include])
154                 MULE_PREPEND([LDFLAGS], [-R/usr/pkg/lib -L/usr/pkg/lib])
155                 ;;
156         *irix*)
157                 SYS=irix
158                 MULECPPFLAGS="-D__IRIX__"
159                 ;;
160         *)
161                 SYS=unknown
162                 ;;
163         esac
165         # -lpthread is needed by Debian but FreeBSD < 5 doesn't support it
166         AS_IF([test ${SYS:-unknown} != win32],
167         [
168                 AC_MSG_CHECKING([if this is a FreeBSD 4 or earlier system])
169                 AS_IF([test x"`uname -s`" = xFreeBSD && test 0`uname -r | cut -c 1` -lt 5],
170                 [
171                         MULE_ADDFLAG([LD], [-pthread])
172                         AC_MSG_RESULT(yes)
173                 ], [
174                         MULE_ADDFLAG([LD], [-lpthread])
175                         AC_MSG_RESULT(no)
176                 ])
177         ])
179 AC_SUBST([RESOLV_LIB])dnl
180 AC_SUBST([X11LIBS])dnl
181 AC_SUBST([MULECPPFLAGS])dnl
182 AC_SUBST([MULECFLAGS])dnl
183 AC_SUBST([MULECXXFLAGS])dnl
184 AC_SUBST([MULELDFLAGS])dnl
185 AC_SUBST([MULERCFLAGS])dnl
188 dnl ---------------------------------------------------------------------------
189 dnl _MULE_CHECK_DEBUG_FLAG
190 dnl ---------------------------------------------------------------------------
191 AC_DEFUN([_MULE_CHECK_DEBUG_FLAG],
192 [AC_REQUIRE([MULE_CHECK_GLIBCXX])dnl
194         AC_ARG_ENABLE(
195                 [debug],
196                 [AS_HELP_STRING([--disable-debug], [disable additional debugging output])],
197                 [USE_DEBUG=${enableval:-yes}], [USE_DEBUG=yes])
199         AS_IF([test $USE_DEBUG = yes],
200         [
201                 MULE_ADDFLAG([CPP], [-D__DEBUG__])
202                 MULE_ADDCCXXFLAG([-g])
203                 AS_IF([test ${GLIBCXX:-no} = yes],      [MULE_ADDFLAG([CPP], [-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC])])
204                 AS_IF([test ${GCC:-no} = yes],          [MULE_ADDCCXXFLAG([-W -Wall -Wshadow -Wundef -ggdb -fno-inline -fmessage-length=0])])
205                 AS_IF([test ${SYS:-unknown} = win32],   [MULE_ADDFLAG([RC], [-D__DEBUG__])])
206         ], [
207                 AS_IF([test ${GCC:-no} = yes], [MULE_ADDCCXXFLAG([-W -Wall -Wshadow -Wundef])])
208         ])
211 dnl ---------------------------------------------------------------------------
212 dnl _MULE_CHECK_PROFILE_FLAG
213 dnl ---------------------------------------------------------------------------
214 AC_DEFUN([_MULE_CHECK_PROFILE_FLAG],
216         AC_ARG_ENABLE(
217                 [profile],
218                 [AS_HELP_STRING([--enable-profile], [enable code profiling])],
219                 [USE_PROFILE=${enableval:-no}], [USE_PROFILE=no])
221         AS_IF([test $USE_PROFILE = yes],
222         [
223                 MULE_ADDCCXXFLAG([-pg])
224                 MULE_ADDFLAG([LD], [-pg])
225         ])
228 dnl ---------------------------------------------------------------------------
229 dnl _MULE_CHECK_OPTIMIZE_FLAG
230 dnl ---------------------------------------------------------------------------
231 AC_DEFUN([_MULE_CHECK_OPTIMIZE_FLAG],
233         AC_ARG_ENABLE(
234                 [optimize],
235                 [AS_HELP_STRING([--enable-optimize], [enable code optimization])],
236                 [USE_OPTIMIZE=${enableval:-no}], [USE_OPTIMIZE=no])
238         AS_IF([test $USE_OPTIMIZE = yes], [MULE_ADDCCXXFLAG([-O2])])
241 dnl ---------------------------------------------------------------------------
242 dnl MULE_COMPILATION_FLAGS
244 dnl Checks type of compilation requested by user, and sets various flags
245 dnl accordingly.
246 dnl ---------------------------------------------------------------------------
247 AC_DEFUN([MULE_COMPILATION_FLAGS],
249         _MULE_CHECK_DEBUG_FLAG
250         _MULE_CHECK_OPTIMIZE_FLAG
251         _MULE_CHECK_PROFILE_FLAG
253         AC_MSG_CHECKING([if the applications should be statically linked])
254         AC_ARG_ENABLE(
255                 [static],
256                 [AS_HELP_STRING([--enable-static], [produce a statically linked executable])],
257                 [AS_IF([test ${enableval:-no} = yes], [MULE_ADDFLAG([LD], [-static])])])
258         AC_MSG_RESULT(${enableval:-no})
260         MULE_ADDFLAG([CPP], [-DUSE_WX_EXTENSIONS])
263 dnl ---------------------------------------------------------------------------
264 dnl MULE_CHECK_GLIBCXX
266 dnl Checks whether we use the GNU C++ Library.
267 dnl ---------------------------------------------------------------------------
268 AC_DEFUN([MULE_CHECK_GLIBCXX],
269 [dnl
270 AC_REQUIRE([AC_PROG_EGREP])dnl
271 AC_REQUIRE([AC_PROG_CXXCPP])dnl
272 AC_LANG_ASSERT([C++])dnl
274         AC_MSG_CHECKING([if we're using the GNU C++ library])
275         AC_PREPROC_IFELSE([
276                 AC_LANG_SOURCE([[
277                         #include <string>
278                         #ifndef __GLIBCXX__
279                         #error Non-GNU C++ library found.
280                         #endif
281                 ]])
282         ], [GLIBCXX=yes], [GLIBCXX=no])
283         AC_MSG_RESULT([$GLIBCXX])
286 dnl ---------------------------------------------------------------------------
287 dnl MULE_CHECK_WX_SUPPORTS_LARGEFILE
289 dnl Test that wxWidgets is built with support for large-files. If not
290 dnl configure is terminated.
291 dnl ---------------------------------------------------------------------------
292 AC_DEFUN([MULE_CHECK_WX_SUPPORTS_LARGEFILE],
293 [AC_LANG_ASSERT([C++])dnl
295         dnl Backup current flags and setup flags for testing
296         MULE_BACKUP([CPPFLAGS])
297         MULE_APPEND([CPPFLAGS], [$WX_CPPFLAGS])
299         AC_MSG_CHECKING([that wxWidgets has support for large files])
300         AC_PREPROC_IFELSE([
301                 AC_LANG_SOURCE([[
302                         #include <wx/wx.h>
303                         #if !HAVE_LARGEFILE_SUPPORT && !defined(_LARGE_FILES) && !defined(__WXMSW__)
304                                 #error No LargeFile support!
305                         #endif
306                 ]])
307         ], [
308                 AC_MSG_RESULT([yes])
309         ], [
310                 AC_MSG_RESULT([no])
311                 AC_MSG_ERROR([
312         Support for large files in wxWidgets is required by aMule.
313         To continue you must recompile wxWidgets with support for 
314         large files enabled.])
315         ])
317         dnl Restore backup'd flags
318         MULE_RESTORE([CPPFLAGS])
322 dnl --------------------------------------------------------------------------
323 dnl MULE_CHECK_CCACHE
325 dnl Checks if ccache is requested and available, and makes use of it
326 dnl --------------------------------------------------------------------------
327 AC_DEFUN([MULE_CHECK_CCACHE],
329         AC_ARG_ENABLE([ccache],
330                 [AS_HELP_STRING([--enable-ccache], [enable ccache support for fast recompilation])])
332         AC_ARG_WITH([ccache-prefix],
333                 [AS_HELP_STRING([--with-ccache-prefix=PREFIX], [prefix where ccache is installed])])
335         AC_MSG_CHECKING([whether ccache support should be added])
336         AC_MSG_RESULT([${enable_ccache:-no}])
338         AS_IF([test ${enable_ccache:-no} = yes], [
339                 AC_MSG_CHECKING([for ccache presence])
340                 AS_IF([test -z "$with_ccache_prefix"], [
341                         ccache_full=`which ccache`
342                         with_ccache_prefix=`dirname ${ccache_full}`
343                 ])
344                 AS_IF([$with_ccache_prefix/ccache -V >/dev/null 2>&1], [
345                         AC_MSG_RESULT([yes])
346                         CC="$with_ccache_prefix/ccache $CC"
347                         CXX="$with_ccache_prefix/ccache $CXX"
348                         BUILD_CC="$with_ccache_prefix/ccache $BUILD_CC"
349                 ], [
350                         enable_ccache=no
351                         AC_MSG_RESULT([no])
352                 ])
353         ])
357 dnl ----------------------------------------------------
358 dnl MULE_CHECK_BFD
359 dnl check if bfd.h is on the system and usable
360 dnl ----------------------------------------------------
361 AC_DEFUN([MULE_CHECK_BFD],
363         AC_MSG_CHECKING([for bfd])
364         MULE_BACKUP([LIBS])
365         MULE_BACKUP([LDFLAGS])
366         MULE_PREPEND([LIBS], [-lbfd -liberty ${ZLIB_LIBS}])
367         MULE_APPEND([LDFLAGS], [${ZLIB_LDFLAGS}])
368         AC_LINK_IFELSE([
369                 AC_LANG_PROGRAM([[
370                         #include <ansidecl.h>
371                         #include <bfd.h>
372                 ]], [[
373                         char *dummy = bfd_errmsg(bfd_get_error());
374                 ]])
375         ], [
376                 AC_MSG_RESULT([yes])
377                 BFD_CPPFLAGS="-DHAVE_BFD"
378                 BFD_LIBS="-lbfd -liberty"
379         ], [
380                 AC_MSG_RESULT([no])
381                 MULE_WARNING([bfd.h not found or unusable, please install binutils development package if you are a developer or want to help testing aMule])
382         ])
383         MULE_RESTORE([LIBS])
384         MULE_RESTORE([LDFLAGS])
386 AC_SUBST([BFD_CPPFLAGS])dnl
387 AC_SUBST([BFD_LIBS])dnl
391 dnl ----------------------------------------------------
392 dnl MULE_CHECK_FLEX_EXTENDED
393 dnl check if flex can produce header files
394 dnl ----------------------------------------------------
395 AC_DEFUN([MULE_CHECK_FLEX_EXTENDED],
397         AC_MSG_CHECKING([for extended flex capabilities])
399         extended_flex=`flex --help | grep header-file`
400         AS_IF([test -n "$extended_flex"], [HAVE_FLEX_EXTENDED=yes], [HAVE_FLEX_EXTENDED=no])
401         AC_MSG_RESULT($HAVE_FLEX_EXTENDED)
403         AS_IF([test $HAVE_FLEX_EXTENDED = no], [AC_MSG_NOTICE([Your flex version doesn't support --header-file flag. This is not critical, but an upgrade is recommended])])
407 dnl ----------------------------------------------------
408 dnl MULE_CHECK_EXCEPTIONS
409 dnl Checks for broken exception-handling. This is needed
410 dnl because exception handling is broken for some archs/
411 dnl compilers.
412 dnl ----------------------------------------------------
413 AC_DEFUN([MULE_CHECK_EXCEPTIONS],
414 [AC_LANG_ASSERT([C++])dnl
416         AC_MSG_CHECKING([for exception-handling])
417         AC_RUN_IFELSE([
418                 AC_LANG_PROGRAM(, [[
419                         try {
420                                 throw 1;
421                         } catch (int) {
422                                 return 0;
423                         }
424                         return 1;
425                 ]])
426         ], [
427                 AC_MSG_RESULT([yes])
428         ], [
429                 AC_MSG_RESULT([no])
430                 AC_MSG_ERROR([Exception handling does not work. Broken compiler?])
431         ], [
432                 AC_MSG_RESULT([undeterminable])
433                 MULE_WARNING(
434                         [Cross-compilation detected, so exception handling cannot be tested.
435                         Note that broken exception handling in your compiler may lead to unexpected crashes.])
436         ])
440 dnl ---------------------------------------------------------------------------
441 dnl MULE_CHECK_REGEX([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
443 dnl This function will test the existance of a POSIX compliant regex library.
444 dnl ---------------------------------------------------------------------------
445 AC_DEFUN([MULE_CHECK_REGEX],
447         AC_CHECK_HEADERS([sys/types.h])
448         AC_MSG_CHECKING([for a POSIX compliant regex library])
449         regex_found=no
450         for REGEX_LIBS in '' -lgnurx -lregex; do
451                 MULE_BACKUP([LIBS])
452                 MULE_PREPEND([LIBS], [$REGEX_LIBS])
453                 AC_LINK_IFELSE([
454                         AC_LANG_PROGRAM([[
455                                 #ifdef HAVE_SYS_TYPES_H
456                                 #       include <sys/types.h>
457                                 #endif
458                                 #include <regex.h>
459                         ]], [[
460                                 regex_t preg;
461                                 regcomp(&preg, "", REG_EXTENDED);
462                                 regmatch_t *pmatch;
463                                 regexec(&preg, "", 0, pmatch, 0);
464                                 regfree(&preg);
465                         ]])
466                 ], [
467                         MULE_RESTORE([LIBS])
468                         regex_found=yes
469                         break;
470                 ], [MULE_RESTORE([LIBS])])
471         done
472         AC_MSG_RESULT([$regex_found])
473         AS_IF([test $regex_found = yes], [$1], [$2])
474 AC_SUBST([REGEX_LIBS])dnl
478 dnl ---------------------------------------------------------------------------
479 dnl MULE_CHECK_CXXABI
481 dnl This function will test the header <cxxabi.h> and abi::__cxa_demangle()
482 dnl ---------------------------------------------------------------------------
483 AC_DEFUN([MULE_CHECK_CXXABI],
484 [AC_LANG_ASSERT([C++])dnl
486         AC_MSG_CHECKING([for <cxxabi.h> and __cxa_demangle()])
487         AC_LINK_IFELSE([
488                 AC_LANG_PROGRAM([[
489                         #include <cxxabi.h>
490                 ]], [[
491                         int status;
492                         char * demangled = abi::__cxa_demangle("", 0, 0, &status);
493                         std::type_info *ti = abi::__cxa_current_exception_type();
494                 ]])
495         ], [
496                 AH_TEMPLATE([HAVE_CXXABI], [Define to 1 if you have the <cxxabi.h> header which declares abi::__cxa_demangle()])
497                 AC_DEFINE([HAVE_CXXABI])
498                 AC_MSG_RESULT([yes])
499         ], [
500                 AC_MSG_RESULT([no])
501         ])
505 dnl ---------------------------------------------------------------------------
506 dnl MULE_CHECK_EXECINFO
508 dnl This function will test the header <execinfo.h> and backtrace()
509 dnl ---------------------------------------------------------------------------
510 AC_DEFUN([MULE_CHECK_EXECINFO],
512         AC_MSG_CHECKING([for <execinfo.h> and backtrace()])
513         AC_LINK_IFELSE([
514                 AC_LANG_PROGRAM([[
515                         #include <execinfo.h>
516                 ]], [[
517                         void *bt[1];
518                         int n = backtrace(&bt, 1);
519                         const char **bt_syms = backtrace_symbols(bt, n);
520                 ]])
521         ], [
522                 AH_TEMPLATE([HAVE_EXECINFO], [Define to 1 if you have the <execinfo.h> header which declares backtrace()])
523                 AC_DEFINE([HAVE_EXECINFO])
524                 AC_MSG_RESULT([yes])
525         ], [
526                 AC_MSG_RESULT([no])
527         ])
531 dnl ---------------------------------------------------------------------------
532 dnl MULE_DENOISER
534 dnl Test for denoising level and add denoiser commands to config.status
535 dnl ---------------------------------------------------------------------------
536 AC_DEFUN([MULE_DENOISER],
538         AC_ARG_WITH([denoise-level],
539                 [AS_HELP_STRING([--with-denoise-level=<level>], [Specifies denoising level (0-4):])
540                 AS_HELP_STRING([], [0 - Do nothing])
541                 AS_HELP_STRING([], [4 - Suppress all normal output])
542                 AS_HELP_STRING([], [(for more information see src/utils/scripts/denoiser.rules)])
543         ])
545         AC_MSG_CHECKING([denoising level])
546         AS_IF([test ${with_denoise_level:-5} = yes], [with_denoise_level=5])
547         AS_IF([test ${with_denoise_level:-5} = no], [with_denoise_level=0])
548         AS_IF([test ${with_denoise_level:-5} -gt 4],
549                 [AS_IF([test "${svndate:+set}" = "set"], [with_denoise_level=0], [with_denoise_level=4])])
550         AC_MSG_RESULT([$with_denoise_level])
552         AC_CONFIG_COMMANDS([denoiser], [[if test $denoiserlevel -gt 0; then
553                 if test ! -d src/utils/scripts; then mkdir -p src/utils/scripts; fi
554                 sed -e "1{x;s/.*/1/;x;};/^[     ]*\$/d;/^#if /{/level.*$denoiserlevel/{x;s/^/1/;x;b0;};x;s/^/0/;x;:0;d;};/^#else/{x;/^1/{s/1/0/;b1;};s/0/1/;:1;x;d;};/^#endif/{x;s/.//;x;d;};/^[        ]*#/d;x;/^1/{x;b;};x;d" \
555                         $srcdir/src/utils/scripts/denoiser.rules > src/utils/scripts/denoiser.sed
556                 for i in `find . -name 'Makefile' -print`; do
557                         if test -n "`head -n 1 $i | grep '^#'`"; then
558                                 sed -f src/utils/scripts/denoiser.sed $i > $i.tmp && mv $i.tmp $i
559                         fi
560                 done
561         fi]], [denoiserlevel=$with_denoise_level])