/doc/man/*.8
/doc/man/*.xml
/doc/man/*.html
+/doc/man/*.h
/doc/man/asciidoc-attrs.conf
!/doc/man/lttng-health-check.3
ACLOCAL_AMFLAGS = -I m4
-DIST_SUBDIRS = include src extras doc tests
+DIST_SUBDIRS = include doc src extras tests
-SUBDIRS = include src doc tests
+SUBDIRS = include doc src tests
if BUILD_EXTRAS
SUBDIRS += extras
AC_DEFINE_UNQUOTED([MANPATH], ["`eval eval echo $mandir`"], [Path to man pages.])
+# embedded --help message
+AC_ARG_ENABLE(
+ [embedded-help],
+ AS_HELP_STRING(
+ [--enable-embedded-help],
+ [Embed the --help messages in the executable files]
+ ),
+ [embedded_help=$enableval],
+ [embedded_help=no]
+)
+AS_IF([test "x$embedded_help" = "xyes"], [
+ AS_IF([test "x$man_pages_opt" = "xno"], [
+ AC_MSG_ERROR([You need the --enable-man-pages option with the --enable-embedded-help option.])
+ ])
+ AC_PATH_PROG([man_prog_path], [man], [no])
+ AS_IF([test "x$man_prog_path" = "xno"], [
+ AC_MSG_ERROR([You need man with the --enable-embedded-help option.])
+ ])
+ AC_DEFINE_UNQUOTED([LTTNG_EMBED_HELP], 1, [Embed --help messages.])
+ AC_SUBST([MANPROG], [$man_prog_path])
+])
+AM_CONDITIONAL([EMBED_HELP], [test "x$embedded_help" != "xno"])
+
# Python agent test
UST_PYTHON_AGENT="lttngust"
m4_popdef([build_man_pages_msg])
+test "x$embedded_help" = xyes && value=1 || value=0
+PPRINT_PROP_BOOL([Embed --help messages], $value, $PPRINT_COLOR_SUBTITLE)
+
PPRINT_SET_INDENT(1)
report_bindir="`eval eval echo $bindir`"
MAN8_NO_ASCIIDOC = $(addsuffix .8,$(MAN8_NO_ASCIIDOC_NAMES))
MAN = $(MAN1) $(MAN3) $(MAN8)
+# initially empty
+CLEANFILES =
+
+if EMBED_HELP
+MAN1_H = $(addsuffix .1.h,$(MAN1_NAMES))
+MAN3_H = $(addsuffix .3.h,$(MAN3_NAMES))
+MAN8_H = $(addsuffix .8.h,$(MAN8_NAMES))
+MAN_H = $(MAN1_H) $(MAN3_H) $(MAN8_H)
+MAN_H_RECIPE = \
+ MANWIDTH=80 @MANPROG@ --encoding=UTF-8 --no-hyphenation --no-justification --local-file $< > $@ ; \
+ $(SED) -i 's/\\/\\\\/g' $@ ; \
+ $(SED) -i 's/"/\\"/g' $@ ; \
+ $(SED) -i 's/^\(.*\)$$/"\1\\n"/' $@
+
+%.1.h: %.1
+ $(MAN_H_RECIPE)
+
+%.3.h: %.3
+ $(MAN_H_RECIPE)
+
+%.8.h: %.8
+ $(MAN_H_RECIPE)
+
+all-local: $(MAN_H)
+
+CLEANFILES += $(MAN_H)
+endif # EMBED_HELP
+
if MAN_PAGES_OPT
# at this point, we know the user asked to build the man pages
if HAVE_ASCIIDOC_XMLTO
$(XTO) $<
# only clean the generated files if we have the tools to generate them again
-CLEANFILES = $(MAN_XML) $(MAN)
+CLEANFILES += $(MAN_XML) $(MAN)
else # HAVE_ASCIIDOC_XMLTO
# create man page targets used to stop the build if we want to
# build the man pages, but we don't have the necessary tools to do so
# always distribute the source files
EXTRA_DIST = $(MAN_TXT) $(COMMON_TXT) $(XSL_SRC_FILES) \
$(ASCIIDOC_CONF) $(ASCIIDOC_ATTRS_CONF).in
+
+# keep generated man pages that can be considered intermediate files
+.PRECIOUS: %.1 %.3 %.8
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src \
-DINSTALL_BIN_PATH=\""$(bindir)"\"
+if EMBED_HELP
+AM_CPPFLAGS += -I$(top_builddir)/doc/man
+endif
+
bin_PROGRAMS = lttng-crash
lttng_crash_SOURCES = lttng-crash.c
0xF1 ^ 0xFF, 0x77 ^ 0xFF, 0xBF ^ 0xFF, 0x17 ^ 0xFF, \
}
+static const char *help_msg =
+#ifdef LTTNG_EMBED_HELP
+#include <lttng-crash.1.h>
+#else
+NULL
+#endif
+;
+
/*
* Non-static to ensure the compiler does not optimize away the xor.
*/
static void usage(void)
{
- int ret = utils_show_man_page(1, "lttng-crash");
+ int ret = utils_show_help(1, "lttng-crash", help_msg);
if (ret) {
- ERR("Cannot view man page lttng-crash(1)");
+ ERR("Cannot show --help for `lttng-crash`");
perror("exec");
exit(EXIT_FAILURE);
}
-DINSTALL_BIN_PATH=\""$(lttnglibexecdir)"\" \
-DINSTALL_LIB_PATH=\""$(libdir)"\"
+if EMBED_HELP
+AM_CPPFLAGS += -I$(top_builddir)/doc/man
+endif
+
AM_CFLAGS = -fno-strict-aliasing
bin_PROGRAMS = lttng-relayd
#include "connection.h"
#include "tracefile-array.h"
+static const char *help_msg =
+#ifdef LTTNG_EMBED_HELP
+#include <lttng-relayd.8.h>
+#else
+NULL
+#endif
+;
+
/* command line options */
char *opt_output_path;
static int opt_daemon, opt_background;
}
break;
case 'h':
- ret = utils_show_man_page(8, "lttng-relayd");
+ ret = utils_show_help(8, "lttng-relayd", help_msg);
if (ret) {
- ERR("Cannot view man page lttng-relayd(8)");
+ ERR("Cannot show --help for `lttng-relayd`");
perror("exec");
}
exit(EXIT_FAILURE);
-DINSTALL_BIN_PATH=\""$(lttnglibexecdir)"\" \
-DINSTALL_LIB_PATH=\""$(libdir)"\"
+if EMBED_HELP
+AM_CPPFLAGS += -I$(top_builddir)/doc/man
+endif
+
AM_CFLAGS = -fno-strict-aliasing
bin_PROGRAMS = lttng-sessiond
#define CONSUMERD_FILE "lttng-consumerd"
+static const char *help_msg =
+#ifdef LTTNG_EMBED_HELP
+#include <lttng-sessiond.8.h>
+#else
+NULL
+#endif
+;
+
const char *progname;
const char *tracing_group_name = DEFAULT_TRACING_GROUP;
static int tracing_group_name_override;
tracing_group_name_override = 1;
}
} else if (string_match(optname, "help") || opt == 'h') {
- ret = utils_show_man_page(8, "lttng-sessiond");
+ ret = utils_show_help(8, "lttng-sessiond", help_msg);
if (ret) {
- ERR("Cannot view man page lttng-sessiond(8)");
+ ERR("Cannot show --help for `lttng-sessiond`");
perror("exec");
}
exit(ret ? EXIT_FAILURE : EXIT_SUCCESS);
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src \
-DINSTALL_BIN_PATH=\""$(bindir)"\"
+if EMBED_HELP
+AM_CPPFLAGS += -I$(top_builddir)/doc/man
+endif
+
AUTOMAKE_OPTIONS = subdir-objects
bin_PROGRAMS = lttng
#define DECL_COMMAND(_name) \
extern int cmd_##_name(int, const char **)
+#ifdef LTTNG_EMBED_HELP
+# define HELP_MSG_NAME help_msg
+# define SHOW_HELP_ERROR_LINE ERR("Cannot show --help for `lttng-%s`", argv[0]);
+#else
+# define HELP_MSG_NAME NULL
+# define SHOW_HELP_ERROR_LINE ;
+#endif
+
#define SHOW_HELP() \
do { \
- ret = show_cmd_man_page(argv[0]); \
+ ret = show_cmd_help(argv[0], HELP_MSG_NAME); \
\
if (ret) { \
- ERR("Cannot view man page lttng-%s(1)", argv[0]); \
- perror("exec"); \
+ SHOW_HELP_ERROR_LINE \
ret = CMD_ERROR; \
} \
} while (0)
static int opt_log4j;
static char *opt_type;
+#ifdef LTTNG_EMBED_HELP
+static const char help_msg[] =
+#include <lttng-add-context.1.h>
+;
+#endif
+
enum {
OPT_HELP = 1,
OPT_TYPE,
static int opt_snapshot;
static unsigned int opt_live_timer;
+#ifdef LTTNG_EMBED_HELP
+static const char help_msg[] =
+#include <lttng-create.1.h>
+;
+#endif
+
enum {
OPT_HELP = 1,
OPT_LIST_OPTIONS,
static int opt_destroy_all;
static int opt_no_wait;
+#ifdef LTTNG_EMBED_HELP
+static const char help_msg[] =
+#include <lttng-destroy.1.h>
+;
+#endif
+
/* Mi writer */
static struct mi_writer *writer;
static char *opt_session_name;
static int opt_userspace;
+#ifdef LTTNG_EMBED_HELP
+static const char help_msg[] =
+#include <lttng-disable-channel.1.h>
+;
+#endif
+
enum {
OPT_HELP = 1,
OPT_USERSPACE,
static int opt_python;
static int opt_event_type;
+#ifdef LTTNG_EMBED_HELP
+static const char help_msg[] =
+#include <lttng-disable-event.1.h>
+;
+#endif
+
enum {
OPT_HELP = 1,
OPT_TYPE_SYSCALL,
static struct mi_writer *writer;
+#ifdef LTTNG_EMBED_HELP
+static const char help_msg[] =
+#include <lttng-enable-channel.1.h>
+;
+#endif
+
enum {
OPT_HELP = 1,
OPT_DISCARD,
static char *opt_filter;
static char *opt_exclude;
+#ifdef LTTNG_EMBED_HELP
+static const char help_msg[] =
+#include <lttng-enable-event.1.h>
+;
+#endif
+
enum {
OPT_HELP = 1,
OPT_TRACEPOINT,
#include "../command.h"
#include <common/utils.h>
+static const char *help_msg =
+#ifdef LTTNG_EMBED_HELP
+#include <lttng-help.1.h>
+#else
+NULL
+#endif
+;
+
+static const char *lttng_help_msg =
+#ifdef LTTNG_EMBED_HELP
+#include <lttng.1.h>
+#else
+NULL
+#endif
+;
+
enum {
OPT_HELP = 1,
OPT_LIST_OPTIONS,
if (cmd_name == NULL) {
/* Fall back to lttng(1) */
- ret = utils_show_man_page(1, "lttng");
-
+ ret = utils_show_help(1, "lttng", lttng_help_msg);
if (ret) {
- ERR("Cannot view man page lttng(1)");
+ ERR("Cannot show --help for `lttng`");
perror("exec");
ret = CMD_ERROR;
- goto end;
}
+
+ goto end;
}
/* Make sure command name exists */
const char *indent6 = " ";
const char *indent8 = " ";
+#ifdef LTTNG_EMBED_HELP
+static const char help_msg[] =
+#include <lttng-list.1.h>
+;
+#endif
+
enum {
OPT_HELP = 1,
OPT_USERSPACE,
static const char *session_name;
+#ifdef LTTNG_EMBED_HELP
+static const char help_msg[] =
+#include <lttng-load.1.h>
+;
+#endif
+
enum {
OPT_HELP = 1,
OPT_ALL,
static int metadata_regenerate(int argc, const char **argv);
+#ifdef LTTNG_EMBED_HELP
+static const char help_msg[] =
+#include <lttng-metadata.1.h>
+;
+#endif
+
enum {
OPT_HELP = 1,
OPT_LIST_OPTIONS,
static int regenerate_metadata(int argc, const char **argv);
static int regenerate_statedump(int argc, const char **argv);
+#ifdef LTTNG_EMBED_HELP
+static const char help_msg[] =
+#include <lttng-regenerate.1.h>
+;
+#endif
+
enum {
OPT_HELP = 1,
OPT_LIST_OPTIONS,
static bool opt_save_all;
static struct mi_writer *writer;
+#ifdef LTTNG_EMBED_HELP
+static const char help_msg[] =
+#include <lttng-save.1.h>
+;
+#endif
+
enum {
OPT_HELP = 1,
OPT_ALL,
static char *opt_session_name;
+#ifdef LTTNG_EMBED_HELP
+static const char help_msg[] =
+#include <lttng-set-session.1.h>
+;
+#endif
+
enum {
OPT_HELP = 1,
OPT_LIST_OPTIONS,
static const char *indent4 = " ";
+#ifdef LTTNG_EMBED_HELP
+static const char help_msg[] =
+#include <lttng-snapshot.1.h>
+;
+#endif
+
enum {
OPT_HELP = 1,
OPT_LIST_OPTIONS,
static char *opt_session_name;
static struct mi_writer *writer;
+#ifdef LTTNG_EMBED_HELP
+static const char help_msg[] =
+#include <lttng-start.1.h>
+;
+#endif
+
enum {
OPT_HELP = 1,
OPT_LIST_OPTIONS,
#include "../utils.h"
#include <config.h>
+#ifdef LTTNG_EMBED_HELP
+static const char help_msg[] =
+#include <lttng-status.1.h>
+;
+#endif
+
enum {
OPT_HELP = 1,
OPT_LIST_OPTIONS,
static int opt_no_wait;
static struct mi_writer *writer;
+#ifdef LTTNG_EMBED_HELP
+static const char help_msg[] =
+#include <lttng-stop.1.h>
+;
+#endif
+
enum {
OPT_HELP = 1,
OPT_LIST_OPTIONS,
*/
static
int cmd_track_untrack(enum cmd_type cmd_type, const char *cmd_str,
- int argc, const char **argv)
+ int argc, const char **argv, const char *help_msg)
{
int opt, ret = 0;
enum cmd_error_code command_ret = CMD_SUCCESS;
int cmd_track(int argc, const char **argv)
{
- return cmd_track_untrack(CMD_TRACK, "track", argc, argv);
+ static const char *help_msg =
+#ifdef LTTNG_EMBED_HELP
+#include <lttng-track.1.h>
+#else
+ NULL
+#endif
+ ;
+
+ return cmd_track_untrack(CMD_TRACK, "track", argc, argv, help_msg);
}
int cmd_untrack(int argc, const char **argv)
{
- return cmd_track_untrack(CMD_UNTRACK, "untrack", argc, argv);
+ static const char *help_msg =
+#ifdef LTTNG_EMBED_HELP
+#include <lttng-untrack.1.h>
+#else
+ NULL
+#endif
+ ;
+
+ return cmd_track_untrack(CMD_UNTRACK, "untrack", argc, argv, help_msg);
}
#include "../command.h"
+#ifdef LTTNG_EMBED_HELP
+static const char help_msg[] =
+#include <lttng-version.1.h>
+;
+#endif
+
enum {
OPT_HELP = 1,
OPT_LIST_OPTIONS,
static const char *babeltrace_bin = CONFIG_BABELTRACE_BIN;
//static const char *lttv_gui_bin = CONFIG_LTTV_GUI_BIN;
+#ifdef LTTNG_EMBED_HELP
+static const char help_msg[] =
+#include <lttng-view.1.h>
+;
+#endif
+
enum {
OPT_HELP = 1,
OPT_LIST_OPTIONS,
#include "command.h"
+static const char *help_msg =
+#ifdef LTTNG_EMBED_HELP
+#include <lttng.1.h>
+#else
+NULL
+#endif
+;
+
/* Variables */
static char *progname;
int opt_no_sessiond;
ret = 0;
goto end;
case 'h':
- ret = utils_show_man_page(1, "lttng");
-
+ ret = utils_show_help(1, "lttng", help_msg);
if (ret) {
- ERR("Cannot view man page lttng(1)");
+ ERR("Cannot show --help for `lttng`");
perror("exec");
}
goto end;
return;
}
-int show_cmd_man_page(const char *cmd_name)
+int show_cmd_help(const char *cmd_name, const char *help_msg)
{
int ret;
char page_name[32];
ret = sprintf(page_name, "lttng-%s", cmd_name);
assert(ret > 0 && ret < 32);
+ ret = utils_show_help(1, page_name, help_msg);
+ if (ret && !help_msg) {
+ ERR("Cannot view man page `lttng-%s(1)`", cmd_name);
+ perror("exec");
+ }
- return utils_show_man_page(1, page_name);
+ return ret;
}
int spawn_relayd(const char *pathname, int port);
int check_relayd(void);
void print_session_stats(const char *session_name);
-int show_cmd_man_page(const char *cmd_name);
+int show_cmd_help(const char *cmd_name, const char *help_msg);
#endif /* _LTTNG_UTILS_H */
}
LTTNG_HIDDEN
-int utils_show_man_page(int section, const char *page_name)
+int utils_show_help(int section, const char *page_name,
+ const char *help_msg)
{
char section_string[8];
const char *man_bin_path = get_man_bin_path();
- int ret;
+ int ret = 0;
+
+ if (help_msg) {
+ printf("%s", help_msg);
+ goto end;
+ }
/* Section integer -> section string */
ret = sprintf(section_string, "%d", section);
*/
ret = execlp(man_bin_path, "man", "-M", MANPATH,
section_string, page_name, NULL);
+
+end:
return ret;
}
int utils_create_lock_file(const char *filepath);
int utils_recursive_rmdir(const char *path);
int utils_truncate_stream_file(int fd, off_t length);
-int utils_show_man_page(int section, const char *page_name);
+int utils_show_help(int section, const char *page_name, const char *help_msg);
#endif /* _COMMON_UTILS_H */