本busybox版本1.24.2,不同版本设置方法可能不同,仅供参考。
busybox的帮助信息生成于include\usage.h,但不能直接修改usage.h文件,原因在usage.h开头也有说明:
/* DO NOT EDIT. This file is generated from usage.src.h */
/* vi: set sw=8 ts=8: */
/*
* This file suffers from chronically incorrect tabification
* of messages. Before editing this file:
* 1. Switch you editor to 8-space tab mode.
* 2. Do not use \t in messages, use real tab character.
* 3. Start each source line with message as follows:
* |<7 spaces>"text with tabs"....
* or
* |<5 spaces>"\ntext with tabs"....
*/
可以得知usage.h是在编译过程中根据usage.src.h自动生成的,跟据说明跳转到include\usage.src.h,发现只有短短几行:
#ifndef BB_USAGE_H
#define BB_USAGE_H 1
#define NOUSAGE_STR "\b"
INSERT
#define busybox_notes_usage \
"Hello world!\n"
#endif
这个INSERT是什么?
INSERT将在编译时被脚本scripts/gen_build_files.sh替换为该命令目录下*.c中以//usage:打头的内容。
举个例子,udhcpc这个工具的帮助信息就保存在dhcpc.c这个文件中,如下所示,在编译udhcpc时gen_build_files.sh就会把这部分开头的"//usage:"去掉保存到usage.h中。
所以如果要修改现有功能的帮助信息的话,直接修改该工具名.c文件下以//usage:打头的内容就可。
//usage:#if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 1
//usage:# define IF_UDHCP_VERBOSE(...) __VA_ARGS__
//usage:#else
//usage:# define IF_UDHCP_VERBOSE(...)
//usage:#endif
//usage:#define udhcpc_trivial_usage
//usage: "[-fbq"IF_UDHCP_VERBOSE("v")"RBW]"IF_FEATURE_UDHCPC_ARPING(" [-a[MSEC]]")" [-t N] [-T SEC] [-A SEC/-n]\n"
//usage: " [-i IFACE]"IF_FEATURE_UDHCP_PORT(" [-P PORT]")" [-s PROG] [-p PIDFILE]\n"
//usage: " [-oC] [-r IP] [-V VENDOR] [-F NAME] [-x OPT:VAL]... [-O OPT]..."
//usage:#define udhcpc_full_usage "\n"
//usage: IF_LONG_OPTS(
//usage: "\n -i,--interface IFACE Interface to use (default eth0)"
//usage: IF_FEATURE_UDHCP_PORT(
//usage: "\n -P,--client-port PORT Use PORT (default 68)"
//usage: )
//usage: "\n -s,--script PROG Run PROG at DHCP events (default "CONFIG_UDHCPC_DEFAULT_SCRIPT")"
//usage: "\n -p,--pidfile FILE Create pidfile"
//usage: "\n -B,--broadcast Request broadcast replies"
//usage: "\n -t,--retries N Send up to N discover packets (default 3)"
//usage: "\n -T,--timeout SEC Pause between packets (default 3)"
//usage: "\n -A,--tryagain SEC Wait if lease is not obtained (default 20)"
//usage: "\n -n,--now Exit if lease is not obtained"
//usage: "\n -q,--quit Exit after obtaining lease"
//usage: "\n -R,--release Release IP on exit"
...