From 042776e04c24c8ce7a681a175d91595fbeb82103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rainer=20M=C3=BCller?= Date: Wed, 20 Feb 2013 18:31:48 +0100 Subject: [PATCH] configure: check for program_invocation_name For portabiliy, check for program_invocation_name during configure and define HAVE_PROGRAM_INVOCATION_NAME accordingly. Use of this symbol is now enclosed with the appropriate #ifdef block. The symbol program_invocation_name is only used for error message handling using error(), so it's safe to omit this if it is not available. --- configure.ac | 8 ++++++++ free.c | 4 +++- pgrep.c | 2 ++ pmap.c | 2 ++ pwdx.c | 4 +++- skill.c | 4 +++- slabtop.c | 2 ++ sysctl.c | 2 ++ tload.c | 2 ++ uptime.c | 2 ++ vmstat.c | 2 ++ w.c | 2 ++ watch.c | 2 ++ 13 files changed, 35 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 711be2ab..afb24cee 100644 --- a/configure.ac +++ b/configure.ac @@ -137,6 +137,14 @@ dnl else dnl ALL_LINGUAS="af am ar as be bg bn_IN bn ca cs cy da de el en_GB es et eu_ES fa fi fr gl gu he hi hr hu hy id is it ja ka kn ko ku lo lt lv mk ml mr ms my nb nl nn no nso or pa pl pt_BR pt ro ru si sk sl sq sr@Latn sr sv ta te th tr uk ur vi zh_CN zh_TW zu" dnl fi +AC_MSG_CHECKING(whether program_invocation_name is defined) +AC_TRY_COMPILE([#include ], + [program_invocation_name = "test";], + AC_DEFINE(HAVE_PROGRAM_INVOCATION_NAME, 1, + [Define if program_invocation_name is defined]) + AC_MSG_RESULT(yes), + AC_MSG_RESULT(no)) + AC_MSG_CHECKING(whether program_invocation_short_name is defined) AC_TRY_COMPILE([#include ], [program_invocation_short_name = "test";], diff --git a/free.c b/free.c index ecaeccdd..ffc4b86f 100644 --- a/free.c +++ b/free.c @@ -223,7 +223,9 @@ int main(int argc, char **argv) args.repeat_interval = 1000000; args.repeat_counter = 0; - program_invocation_name = program_invocation_short_name; +#ifdef HAVE_PROGRAM_INVOCATION_NAME + program_invocation_name = program_invocation_short_name; +#endif setlocale (LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); diff --git a/pgrep.c b/pgrep.c index 349221a6..7c54d964 100644 --- a/pgrep.c +++ b/pgrep.c @@ -832,7 +832,9 @@ int main (int argc, char **argv) struct el *procs; int num; +#ifdef HAVE_PROGRAM_INVOCATION_NAME program_invocation_name = program_invocation_short_name; +#endif setlocale (LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); diff --git a/pmap.c b/pmap.c index 8d19294b..7b88fec2 100644 --- a/pmap.c +++ b/pmap.c @@ -1013,7 +1013,9 @@ int main(int argc, char **argv) {NULL, 0, NULL, 0} }; +#ifdef HAVE_PROGRAM_INVOCATION_NAME program_invocation_name = program_invocation_short_name; +#endif nls_initialize(); atexit(close_stdout); diff --git a/pwdx.c b/pwdx.c index 4aee389b..214275a9 100644 --- a/pwdx.c +++ b/pwdx.c @@ -74,7 +74,9 @@ int main(int argc, char *argv[]) {NULL, 0, 0, 0} }; - program_invocation_name = program_invocation_short_name; +#ifdef HAVE_PROGRAM_INVOCATION_NAME + program_invocation_name = program_invocation_short_name; +#endif setlocale (LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); diff --git a/skill.c b/skill.c index 03df229c..fb57305a 100644 --- a/skill.c +++ b/skill.c @@ -629,7 +629,9 @@ static void skillsnice_parse(int argc, /* main body */ int main(int argc, char ** argv) { - program_invocation_name = program_invocation_short_name; +#ifdef HAVE_PROGRAM_INVOCATION_NAME + program_invocation_name = program_invocation_short_name; +#endif struct run_time_conf_t run_time; memset(&run_time, 0, sizeof(struct run_time_conf_t)); my_pid = getpid(); diff --git a/slabtop.c b/slabtop.c index 9e535d4f..ebdae8d4 100644 --- a/slabtop.c +++ b/slabtop.c @@ -300,7 +300,9 @@ int main(int argc, char *argv[]) { NULL, 0, NULL, 0 } }; +#ifdef HAVE_PROGRAM_INVOCATION_NAME program_invocation_name = program_invocation_short_name; +#endif setlocale (LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); diff --git a/sysctl.c b/sysctl.c index 07568788..2eeacd91 100644 --- a/sysctl.c +++ b/sysctl.c @@ -675,7 +675,9 @@ int main(int argc, char *argv[]) {NULL, 0, NULL, 0} }; +#ifdef HAVE_PROGRAM_INVOCATION_NAME program_invocation_name = program_invocation_short_name; +#endif setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); diff --git a/tload.c b/tload.c index 765ed177..a5fe14a0 100644 --- a/tload.c +++ b/tload.c @@ -114,7 +114,9 @@ int main(int argc, char **argv) {NULL, 0, NULL, 0} }; +#ifdef HAVE_PROGRAM_INVOCATION_NAME program_invocation_name = program_invocation_short_name; +#endif setlocale (LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); diff --git a/uptime.c b/uptime.c index ac4579cd..27421895 100644 --- a/uptime.c +++ b/uptime.c @@ -77,7 +77,9 @@ int main(int argc, char **argv) {NULL, 0, NULL, 0} }; +#ifdef HAVE_PROGRAM_INVOCATION_NAME program_invocation_name = program_invocation_short_name; +#endif setlocale (LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); diff --git a/vmstat.c b/vmstat.c index a2627b8d..6f95f095 100644 --- a/vmstat.c +++ b/vmstat.c @@ -724,7 +724,9 @@ int main(int argc, char *argv[]) {NULL, 0, NULL, 0} }; +#ifdef HAVE_PROGRAM_INVOCATION_NAME program_invocation_name = program_invocation_short_name; +#endif setlocale (LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); diff --git a/w.c b/w.c index 27c7d222..a73f3282 100644 --- a/w.c +++ b/w.c @@ -483,7 +483,9 @@ int main(int argc, char **argv) {NULL, 0, NULL, 0} }; +#ifdef HAVE_PROGRAM_INVOCATION_NAME program_invocation_name = program_invocation_short_name; +#endif setlocale (LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); diff --git a/watch.c b/watch.c index 0fe0a8fb..5a229528 100644 --- a/watch.c +++ b/watch.c @@ -590,7 +590,9 @@ int main(int argc, char *argv[]) {0, 0, 0, 0} }; +#ifdef HAVE_PROGRAM_INVOCATION_NAME program_invocation_name = program_invocation_short_name; +#endif setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE);