2.4. Hello World (part 3): The __init and __exit Macros

This demonstrates a feature of kernel 2.2 and later. Notice the change in the definitions of the init and cleanup functions. The __init macro causes the init function to be discarded and its memory freed once the init function finishes for built-in drivers, but not loadable modules. If you think about when the init function is invoked, this makes perfect sense.

There is also an __initdata which works similarly to __init but for init variables rather than functions.

The __exit macro causes the omission of the function when the module is built into the kernel, and like __exit, has no effect for loadable modules. Again, if you consider when the cleanup function runs, this makes complete sense; built-in drivers don't need a cleanup function, while loadable modules do.

These macros are defined in linux/init.h and serve to free up kernel memory. When you boot your kernel and see something like Freeing unused kernel memory: 236k freed, this is precisely what the kernel is freeing.

Example 2-5. hello-3.c

/*  hello-3.c - Illustrating the __init, __initdata and __exit macros.
*/
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_ALERT */
#include <linux/init.h> /* Needed for the macros */

static int hello3_data __initdata = 3;


static int __init hello_3_init(void)
{
printk(KERN_ALERT "Hello, world %d/n", hello3_data);
return 0;
}


static void __exit hello_3_exit(void)
{
printk(KERN_ALERT "Goodbye, world 3/n");
}


module_init(hello_3_init);
module_exit(hello_3_exit);

By the way, you may see the directive "__initfunction()" in drivers written for Linux 2.2 kernels:

 __initfunction(int init_module(void))
{
printk(KERN_ALERT "Hi there./n");
return 0;
}

This macro served the same purpose as __init, but is now very deprecated in favor of __init. I only mention it because you might see it modern kernels. As of 2.4.18, there are 38 references to __initfunction(), and of 2.4.20, there are 37 references. However, don't use it in your own code.

 

2.5. Hello World (part 4): Licensing and Module Documentation

If you're running kernel 2.4 or later, you might have noticed something like this when you loaded the previous example modules:

# insmod hello-3.o
Warning: loading hello-3.o will taint the kernel: no license
See http://www.tux.org/lkml/#export-tainted for information about tainted modules
Hello, world 3
Module hello-3 loaded, with warnings

In kernel 2.4 and later, a mechanism was devised to identify code licensed under the GPL (and friends) so people can be warned that the code is non open-source. This is accomplished by the MODULE_LICENSE() macro which is demonstrated in the next piece of code. By setting the license to GPL, you can keep the warning from being printed. This license mechanism is defined and documented in linux/module.h.

Similarly, MODULE_DESCRIPTION() is used to describe what the module does, MODULE_AUTHOR() declares the module's author, and MODULE_SUPPORTED_DEVICE() declares what types of devices the module supports.

These macros are all defined in linux/module.h and aren't used by the kernel itself. They're simply for documentation and can be viewed by a tool like objdump. As an exercise to the reader, try grepping through linux/drivers to see how module authors use these macros to document their modules.

Example 2-6. hello-4.c

/*  hello-4.c - Demonstrates module documentation.
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#define DRIVER_AUTHOR "Peiter Jay Salzman <p@dirac.org>"
#define DRIVER_DESC "A sample driver"

int init_hello_3(void);
void cleanup_hello_3(void);


static int init_hello_4(void)
{
printk(KERN_ALERT "Hello, world 4/n");
return 0;
}


static void cleanup_hello_4(void)
{
printk(KERN_ALERT "Goodbye, world 4/n");
}


module_init(init_hello_4);
module_exit(cleanup_hello_4);


/* You can use strings, like this:
*/
MODULE_LICENSE("GPL"); // Get rid of taint message by declaring code as GPL.

/* Or with defines, like this:
*/
MODULE_AUTHOR(DRIVER_AUTHOR); // Who wrote this module?
MODULE_DESCRIPTION(DRIVER_DESC); // What does this module do?

/* This module uses /dev/testdevice. The MODULE_SUPPORTED_DEVICE macro might be used in
* the future to help automatic configuration of modules, but is currently unused other
* than for documentation purposes.
*/
MODULE_SUPPORTED_DEVICE("testdevice");
user@debian:~/ModSecurity$ git fetch --tags origin remote: Enumerating objects: 35757, done. remote: Counting objects: 100% (35757/35757), done. remote: Compressing objects: 100% (8282/8282), done. remote: Total 35008 (delta 26724), reused 34519 (delta 26239), pack-reused 0 (from 0) 接收对象中: 100% (35008/35008), 48.78 MiB | 2.72 MiB/s, 完成. 处理 delta 中: 100% (26724/26724), 完成 322 个本地对象. 来自 https://github.com/SpiderLabs/ModSecurity * [新标签] v2.1.0 -> v2.1.0 * [新标签] v2.1.0-rc7 -> v2.1.0-rc7 * [新标签] v2.1.1 -> v2.1.1 * [新标签] v2.1.1-dev2 -> v2.1.1-dev2 * [新标签] v2.1.1-dev3 -> v2.1.1-dev3 * [新标签] v2.1.1-dev4 -> v2.1.1-dev4 * [新标签] v2.1.1-rc1 -> v2.1.1-rc1 * [新标签] v2.1.1-rc2 -> v2.1.1-rc2 * [新标签] v2.1.2 -> v2.1.2 * [新标签] v2.1.2-rc1 -> v2.1.2-rc1 * [新标签] v2.1.2-rc2 -> v2.1.2-rc2 * [新标签] v2.1.2-rc3 -> v2.1.2-rc3 * [新标签] v2.1.3 -> v2.1.3 * [新标签] v2.1.3-rc1 -> v2.1.3-rc1 * [新标签] v2.1.3-rc2 -> v2.1.3-rc2 * [新标签] v2.1.4 -> v2.1.4 * [新标签] v2.1.4-rc1 -> v2.1.4-rc1 * [新标签] v2.1.4-rc2 -> v2.1.4-rc2 * [新标签] v2.1.4-rc3 -> v2.1.4-rc3 * [新标签] v2.1.4-rc4 -> v2.1.4-rc4 * [新标签] v2.1.5 -> v2.1.5 * [新标签] v2.1.5-rc1 -> v2.1.5-rc1 * [新标签] v2.1.6 -> v2.1.6 * [新标签] v2.1.6-rc1 -> v2.1.6-rc1 * [新标签] v2.1.7 -> v2.1.7 * [新标签] v2.2.0-dev1 -> v2.2.0-dev1 * [新标签] v2.5.0 -> v2.5.0 * [新标签] v2.5.0-dev2 -> v2.5.0-dev2 * [新标签] v2.5.0-rc1 -> v2.5.0-rc1 * [新标签] v2.5.0-rc2 -> v2.5.0-rc2 * [新标签] v2.5.0-rc3 -> v2.5.0-rc3 * [新标签] v2.5.0-rc3-pre2 -> v2.5.0-rc3-pre2 * [新标签] v2.5.0-rc4 -> v2.5.0-rc4 * [新标签] v2.5.1 -> v2.5.1 * [新标签] v2.5.1-rc1 -> v2.5.1-rc1 * [新标签] v2.5.10 -> v2.5.10 * [新标签] v2.5.10-dev1 -> v2.5.10-dev1 * [新标签] v2.5.10-dev2 -> v2.5.10-dev2 * [新标签] v2.5.10-dev3 -> v2.5.10-dev3 * [新标签] v2.5.11 -> v2.5.11 * [新标签] v2.5.12 -> v2.5.12 * [新标签] v2.5.13 -> v2.5.13 * [新标签] v2.5.2 -> v2.5.2 * [新标签] v2.5.3 -> v2.5.3 * [新标签] v2.5.4 -> v2.5.4 * [新标签] v2.5.5 -> v2.5.5 * [新标签] v2.5.6 -> v2.5.6 * [新标签] v2.5.7 -> v2.5.7 * [新标签] v2.5.7-rc1 -> v2.5.7-rc1 * [新标签] v2.5.8 -> v2.5.8 * [新标签] v2.5.9 -> v2.5.9 * [新标签] v2.6.0 -> v2.6.0 * [新标签] v2.6.0-rc1 -> v2.6.0-rc1 * [新标签] v2.6.0-rc2 -> v2.6.0-rc2 * [新标签] v2.6.1 -> v2.6.1 * [新标签] v2.6.2 -> v2.6.2 * [新标签] v2.6.2-rc1 -> v2.6.2-rc1 * [新标签] v2.6.3 -> v2.6.3 * [新标签] v2.6.3-rc1 -> v2.6.3-rc1 * [新标签] v2.6.4 -> v2.6.4 * [新标签] v2.6.4-rc1 -> v2.6.4-rc1 * [新标签] v2.6.5 -> v2.6.5 * [新标签] v2.6.6 -> v2.6.6 * [新标签] v2.6.7 -> v2.6.7 * [新标签] v2.6.8 -> v2.6.8 * [新标签] v2.7.0 -> v2.7.0 * [新标签] v2.7.0-rc1 -> v2.7.0-rc1 * [新标签] v2.7.0-rc3 -> v2.7.0-rc3 * [新标签] v2.7.1 -> v2.7.1 * [新标签] v2.7.2 -> v2.7.2 * [新标签] v2.7.3 -> v2.7.3 * [新标签] v2.7.4 -> v2.7.4 * [新标签] v2.7.5 -> v2.7.5 * [新标签] v2.7.6 -> v2.7.6 * [新标签] v2.7.7 -> v2.7.7 * [新标签] v2.8.0 -> v2.8.0 * [新标签] v2.8.0-rc1 -> v2.8.0-rc1 * [新标签] v2.9.0 -> v2.9.0 * [新标签] v2.9.0-rc1 -> v2.9.0-rc1 * [新标签] v2.9.0-rc2 -> v2.9.0-rc2 * [新标签] v2.9.1 -> v2.9.1 * [新标签] v2.9.1-rc1 -> v2.9.1-rc1 * [新标签] v2.9.10 -> v2.9.10 * [新标签] v2.9.2 -> v2.9.2 * [新标签] v2.9.3 -> v2.9.3 * [新标签] v2.9.4 -> v2.9.4 * [新标签] v2.9.5 -> v2.9.5 * [新标签] v2.9.6 -> v2.9.6 * [新标签] v2.9.7 -> v2.9.7 * [新标签] v2.9.8 -> v2.9.8 * [新标签] v2.9.9 -> v2.9.9 * [新标签] v3.0.0 -> v3.0.0 * [新标签] v3.0.0-rc1 -> v3.0.0-rc1 * [新标签] v3.0.1 -> v3.0.1 * [新标签] v3.0.10 -> v3.0.10 * [新标签] v3.0.11 -> v3.0.11 * [新标签] v3.0.12 -> v3.0.12 * [新标签] v3.0.13 -> v3.0.13 * [新标签] v3.0.14 -> v3.0.14 * [新标签] v3.0.2 -> v3.0.2 * [新标签] v3.0.3 -> v3.0.3 * [新标签] v3.0.4 -> v3.0.4 * [新标签] v3.0.5 -> v3.0.5 * [新标签] v3.0.6 -> v3.0.6 * [新标签] v3.0.7 -> v3.0.7 * [新标签] v3.0.8 -> v3.0.8 * [新标签] v3.0.9 -> v3.0.9 user@debian:~/ModSecurity$ git checkout v3.0.8 注意:正在切换到 &#39;v3.0.8&#39;。 您正处于分离头指针状态。您可以查看、做试验性的修改及提交,并且您可以在切换 回一个分支时,丢弃在此状态下所做的提交而不对分支造成影响。 如果您想要通过创建分支来保留在此状态下所做的提交,您可以通过在 switch 命令 中添加参数 -c 来实现(现在或稍后)。例如: git switch -c <新分支名> 或者撤销此操作: git switch - 通过将配置变量 advice.detachedHead 设置为 false 来关闭此建议 HEAD 目前位于 996c7e1e Change release version to v3.0.8 user@debian:~/ModSecurity$ ./build.sh libtoolize: putting auxiliary files in &#39;.&#39;. libtoolize: copying file &#39;./ltmain.sh&#39; libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, &#39;build&#39;. libtoolize: copying file &#39;build/libtool.m4&#39; libtoolize: copying file &#39;build/ltoptions.m4&#39; libtoolize: copying file &#39;build/ltsugar.m4&#39; libtoolize: copying file &#39;build/ltversion.m4&#39; libtoolize: copying file &#39;build/lt~obsolete.m4&#39; configure.ac:84: warning: The macro `AC_HELP_STRING&#39; is obsolete. configure.ac:84: You should run autoupdate. ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... build/yajl.m4:4: PROG_YAJL is expanded from... configure.ac:84: the top level configure.ac:98: warning: The macro `AC_HELP_STRING&#39; is obsolete. configure.ac:98: You should run autoupdate. ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... build/lmdb.m4:4: PROG_LMDB is expanded from... configure.ac:98: the top level configure.ac:102: warning: The macro `AC_HELP_STRING&#39; is obsolete. configure.ac:102: You should run autoupdate. ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... build/ssdeep.m4:5: CHECK_SSDEEP is expanded from... configure.ac:102: the top level configure.ac:106: warning: The macro `AC_HELP_STRING&#39; is obsolete. configure.ac:106: You should run autoupdate. ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... build/lua.m4:5: CHECK_LUA is expanded from... configure.ac:106: the top level configure.ac:106: warning: The macro `AC_TRY_COMPILE&#39; is obsolete. configure.ac:106: You should run autoupdate. ./lib/autoconf/general.m4:2847: AC_TRY_COMPILE is expanded from... build/lua.m4:121: CHECK_FOR_LUA_AT is expanded from... build/lua.m4:5: CHECK_LUA is expanded from... configure.ac:106: the top level configure.ac:113: warning: The macro `AC_HELP_STRING&#39; is obsolete. configure.ac:113: You should run autoupdate. ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... ./lib/autoconf/general.m4:1553: AC_ARG_WITH is expanded from... build/curl.m4:15: CHECK_CURL is expanded from... configure.ac:113: the top level configure.ac:123: warning: The macro `AC_HELP_STRING&#39; is obsolete. configure.ac:123: You should run autoupdate. ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... ./lib/autoconf/general.m4:1553: AC_ARG_WITH is expanded from... build/libxml.m4:14: CHECK_LIBXML2 is expanded from... configure.ac:123: the top level configure.ac:129: warning: The macro `AC_HELP_STRING&#39; is obsolete. configure.ac:129: You should run autoupdate. ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... ./lib/autoconf/general.m4:1553: AC_ARG_WITH is expanded from... build/pcre.m4:15: CHECK_PCRE is expanded from... configure.ac:129: the top level configure.ac:129: warning: The macro `AC_TRY_LINK&#39; is obsolete. configure.ac:129: You should run autoupdate. ./lib/autoconf/general.m4:2920: AC_TRY_LINK is expanded from... build/pcre.m4:15: CHECK_PCRE is expanded from... configure.ac:129: the top level configure.ac:135: warning: The macro `AC_HELP_STRING&#39; is obsolete. configure.ac:135: You should run autoupdate. ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... build/pcre2.m4:4: PROG_PCRE2 is expanded from... configure.ac:135: the top level configure.ac:140: warning: The macro `AC_HEADER_STDC&#39; is obsolete. configure.ac:140: You should run autoupdate. ./lib/autoconf/headers.m4:704: AC_HEADER_STDC is expanded from... configure.ac:140: the top level configure.ac:231: warning: The macro `AC_HELP_STRING&#39; is obsolete. configure.ac:231: You should run autoupdate. ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... ./lib/autoconf/general.m4:1534: AC_ARG_ENABLE is expanded from... configure.ac:231: the top level configure.ac:249: warning: The macro `AC_HELP_STRING&#39; is obsolete. configure.ac:249: You should run autoupdate. ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... ./lib/autoconf/general.m4:1534: AC_ARG_ENABLE is expanded from... configure.ac:249: the top level configure.ac:262: warning: The macro `AC_HELP_STRING&#39; is obsolete. configure.ac:262: You should run autoupdate. ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... ./lib/autoconf/general.m4:1534: AC_ARG_ENABLE is expanded from... configure.ac:262: the top level configure.ac:275: warning: The macro `AC_HELP_STRING&#39; is obsolete. configure.ac:275: You should run autoupdate. ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... ./lib/autoconf/general.m4:1534: AC_ARG_ENABLE is expanded from... configure.ac:275: the top level configure.ac:288: warning: The macro `AC_HELP_STRING&#39; is obsolete. configure.ac:288: You should run autoupdate. ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... ./lib/autoconf/general.m4:1534: AC_ARG_ENABLE is expanded from... configure.ac:288: the top level configure.ac:307: warning: AC_PROG_LEX without either yywrap or noyywrap is obsolete ./lib/autoconf/programs.m4:716: _AC_PROG_LEX is expanded from... ./lib/autoconf/programs.m4:709: AC_PROG_LEX is expanded from... configure.ac:307: the top level configure.ac:50: installing &#39;./compile&#39; configure.ac:45: installing &#39;./missing&#39; examples/multiprocess_c/Makefile.am: installing &#39;./depcomp&#39; configure.ac:84: warning: The macro `AC_HELP_STRING&#39; is obsolete. configure.ac:84: You should run autoupdate. ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... build/yajl.m4:4: PROG_YAJL is expanded from... configure.ac:84: the top level configure.ac:98: warning: The macro `AC_HELP_STRING&#39; is obsolete. configure.ac:98: You should run autoupdate. ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... build/lmdb.m4:4: PROG_LMDB is expanded from... configure.ac:98: the top level configure.ac:102: warning: The macro `AC_HELP_STRING&#39; is obsolete. configure.ac:102: You should run autoupdate. ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... build/ssdeep.m4:5: CHECK_SSDEEP is expanded from... configure.ac:102: the top level configure.ac:106: warning: The macro `AC_HELP_STRING&#39; is obsolete. configure.ac:106: You should run autoupdate. ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... build/lua.m4:5: CHECK_LUA is expanded from... configure.ac:106: the top level configure.ac:106: warning: The macro `AC_TRY_COMPILE&#39; is obsolete. configure.ac:106: You should run autoupdate. ./lib/autoconf/general.m4:2847: AC_TRY_COMPILE is expanded from... build/lua.m4:121: CHECK_FOR_LUA_AT is expanded from... build/lua.m4:5: CHECK_LUA is expanded from... configure.ac:106: the top level configure.ac:113: warning: The macro `AC_HELP_STRING&#39; is obsolete. configure.ac:113: You should run autoupdate. ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... ./lib/autoconf/general.m4:1553: AC_ARG_WITH is expanded from... build/curl.m4:15: CHECK_CURL is expanded from... configure.ac:113: the top level configure.ac:123: warning: The macro `AC_HELP_STRING&#39; is obsolete. configure.ac:123: You should run autoupdate. ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... ./lib/autoconf/general.m4:1553: AC_ARG_WITH is expanded from... build/libxml.m4:14: CHECK_LIBXML2 is expanded from... configure.ac:123: the top level configure.ac:129: warning: The macro `AC_HELP_STRING&#39; is obsolete. configure.ac:129: You should run autoupdate. ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... ./lib/autoconf/general.m4:1553: AC_ARG_WITH is expanded from... build/pcre.m4:15: CHECK_PCRE is expanded from... configure.ac:129: the top level configure.ac:129: warning: The macro `AC_TRY_LINK&#39; is obsolete. configure.ac:129: You should run autoupdate. ./lib/autoconf/general.m4:2920: AC_TRY_LINK is expanded from... build/pcre.m4:15: CHECK_PCRE is expanded from... configure.ac:129: the top level configure.ac:135: warning: The macro `AC_HELP_STRING&#39; is obsolete. configure.ac:135: You should run autoupdate. ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... build/pcre2.m4:4: PROG_PCRE2 is expanded from... configure.ac:135: the top level configure.ac:140: warning: The macro `AC_HEADER_STDC&#39; is obsolete. configure.ac:140: You should run autoupdate. ./lib/autoconf/headers.m4:704: AC_HEADER_STDC is expanded from... configure.ac:140: the top level configure.ac:231: warning: The macro `AC_HELP_STRING&#39; is obsolete. configure.ac:231: You should run autoupdate. ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... ./lib/autoconf/general.m4:1534: AC_ARG_ENABLE is expanded from... configure.ac:231: the top level configure.ac:249: warning: The macro `AC_HELP_STRING&#39; is obsolete. configure.ac:249: You should run autoupdate. ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... ./lib/autoconf/general.m4:1534: AC_ARG_ENABLE is expanded from... configure.ac:249: the top level configure.ac:262: warning: The macro `AC_HELP_STRING&#39; is obsolete. configure.ac:262: You should run autoupdate. ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... ./lib/autoconf/general.m4:1534: AC_ARG_ENABLE is expanded from... configure.ac:262: the top level configure.ac:275: warning: The macro `AC_HELP_STRING&#39; is obsolete. configure.ac:275: You should run autoupdate. ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... ./lib/autoconf/general.m4:1534: AC_ARG_ENABLE is expanded from... configure.ac:275: the top level configure.ac:288: warning: The macro `AC_HELP_STRING&#39; is obsolete. configure.ac:288: You should run autoupdate. ./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from... ./lib/autoconf/general.m4:1534: AC_ARG_ENABLE is expanded from... configure.ac:288: the top level configure.ac:307: warning: AC_PROG_LEX without either yywrap or noyywrap is obsolete ./lib/autoconf/programs.m4:716: _AC_PROG_LEX is expanded from... ./lib/autoconf/programs.m4:709: AC_PROG_LEX is expanded from... configure.ac:307: the top level user@debian:~/ModSecurity$
06-29
<think>我们正在处理用户关于ModSecurity构建脚本中出现的过时宏警告问题。具体来说,用户遇到了`AC_HELP_STRING`宏被标记为过时的警告。在autotools中,`AC_HELP_STRING`已经被`AS_HELP_STRING`取代。因此,我们需要更新项目中的`configure.ac`(或`configure.in`)文件,将所有`AC_HELP_STRING`替换为`AS_HELP_STRING`。 此外,用户可能使用的是较旧版本的ModSecurity,因为新版本已经修复了这个问题。如果用户使用的是旧版本,我们可以手动修改。 步骤: 1.定位`configure.ac`(或`configure.in`)文件。2.将文件中所有的`AC_HELP_STRING`替换为`AS_HELP_STRING`。3.重新运行构建脚本。注意:`AS_HELP_STRING`宏在autoconf2.50及更高版本中可用,所以需要确保系统中安装的autoconf版本至少是2.50。如果构建脚本中还有其他过时的宏,我们可能需要根据具体警告进行相应的替换。另外,用户提供的构建脚本(build.sh)本身也可以优化,比如使用`autoreconf`来简化步骤。下面我们给出详细的解决方案。</think>### 解决 ModSecurity 构建中 `AC_HELP_STRING` 过时警告的完整指南 #### 问题原因分析 在构建 ModSecurity 时出现的 `AC_HELP_STRING` 过时警告是由于 Autoconf 版本升级导致的: - `AC_HELP_STRING` 宏在 Autoconf 2.50+ 中被标记为过时[^1] - 新版本 Autoconf 要求使用 `AS_HELP_STRING` 替代[^2] - 根本原因是项目中的 `configure.ac` 文件使用了旧版宏定义 #### 解决方案(逐步操作) 1. **修改 configure.ac 文件** 找到项目中的 `configure.ac` 文件,将所有 `AC_HELP_STRING` 替换为 `AS_HELP_STRING`: ```bash sed -i &#39;s/AC_HELP_STRING/AS_HELP_STRING/g&#39; configure.ac ``` 2. **更新 aclocal.m4 宏定义** 在 `configure.ac` 开头添加宏重定义: ```m4 m4_ifndef([AS_HELP_STRING], [m4_define([AS_HELP_STRING], [AC_HELP_STRING([$1],[$2])])]) ``` 3. **检查 Autoconf 版本兼容性** 验证系统 Autoconf 版本: ```bash autoconf --version | head -1 ``` - 若版本 < 2.50:需升级 Autoconf ```bash # Ubuntu/Debian sudo apt install autoconf # RHEL/CentOS sudo yum install autoconf ``` 4. **优化构建脚本** 修改 `build.sh` 使用现代化构建流程: ```bash #!/bin/sh rm -rf autom4te.cache autoreconf -ivf # 替代所有手动步骤 ``` #### 验证修复 ```bash # 重新生成配置系统 ./build.sh # 检查警告是否消失 ./configure | grep "HELP_STRING" ``` #### 技术原理说明 - `AS_HELP_STRING` 提供更好的格式化和国际化支持[^2] - 宏替换通过 M4 处理器在生成 `configure` 脚本时完成[^1] - `autoreconf -ivf` 自动处理所有依赖关系: ```mermaid graph LR A[configure.ac] --> B[autoreconf] B --> C[aclocal] B --> D[autoheader] B --> E[automake] B --> F[autoconf] F --> G[无警告的configure] ``` #### 备选方案 如果上述修改无效,可直接应用社区补丁: ```bash # 适用于 ModSecurity v3.x wget https://github.com/SpiderLabs/ModSecurity/commit/xxxxxxx.patch patch -p1 < xxxxxxx.patch ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值