This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] make search.h, locale.h and libint.h optional


From: Negreanu Marius Adrian <adrian.m.negreanu@intel.com>

Some environments (like Android) don't have them.

Signed-off-by: Adrian Marius Negreanu <adrian.m.negreanu@intel.com>
---
 config.in          |  9 +++++++++
 configure          | 37 +++++++++++++++++++++++++++++++++++++
 configure.ac       |  4 ++++
 main.cxx           |  5 +++++
 session.h          |  2 ++
 staprun/mainloop.c | 20 ++++++++++++++++++--
 staprun/stapio.c   |  4 ++--
 staprun/staprun.h  | 11 +++++++++--
 util.cxx           |  2 ++
 util.h             |  6 ++++++
 10 files changed, 94 insertions(+), 6 deletions(-)

diff --git a/config.in b/config.in
index c87460a..1e73f54 100644
--- a/config.in
+++ b/config.in
@@ -101,6 +101,15 @@
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
+/* Define to 1 if you have the <spawn.h> header file. */
+#undef HAVE_SPAWN_H
+
+/* Define to 1 if you have the <libintl.h> header file. */
+#undef HAVE_LIBINTL_H
+
+/* Define to 1 if you have the <locale.h> header file. */
+#undef HAVE_LOCALE_H
+
 /* Define to 1 if your C compiler doesn't accept -c and -o together. */
 #undef NO_MINUS_C_MINUS_O
 
diff --git a/configure b/configure
index 9209ca9..86899e1 100755
--- a/configure
+++ b/configure
@@ -10309,6 +10309,43 @@ _ACEOF
 DATE="$date"
 
 
+for ac_header in spawn.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "spawn.h" "ac_cv_header_spawn_h" "$ac_includes_default"
+if test "x$ac_cv_header_spawn_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SPAWN_H 1
+_ACEOF
+
+fi
+
+done
+
+for ac_header in libintl.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "libintl.h" "ac_cv_header_libintl_h" "$ac_includes_default"
+if test "x$ac_cv_header_libintl_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBINTL_H 1
+_ACEOF
+
+fi
+
+done
+
+for ac_header in locale.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "locale.h" "ac_cv_header_locale_h" "$ac_includes_default"
+if test "x$ac_cv_header_locale_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LOCALE_H 1
+_ACEOF
+
+fi
+
+done
+
+
 # Before PR4037, we used to arrange to pass CFLAGS+=-m64 for a staprun
 # being compiled on 32-bit userspace but running against 64-bit kernels.
 # This is no longer necessary.
diff --git a/configure.ac b/configure.ac
index dae2cf5..be28a6b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -473,6 +473,10 @@ date=`date +%Y-%m-%d`
 AC_DEFINE_UNQUOTED(DATE, "$date", [Configuration/build date])
 AC_SUBST(DATE, "$date")
 
+AC_CHECK_HEADERS([spawn.h])
+AC_CHECK_HEADERS([libintl.h])
+AC_CHECK_HEADERS([locale.h])
+
 # Before PR4037, we used to arrange to pass CFLAGS+=-m64 for a staprun
 # being compiled on 32-bit userspace but running against 64-bit kernels.
 # This is no longer necessary.
diff --git a/main.cxx b/main.cxx
index e1e864e..36d9afa 100644
--- a/main.cxx
+++ b/main.cxx
@@ -26,8 +26,13 @@
 #include "tapsets.h"
 #include "setupdwfl.h"
 
+#ifdef HAVE_LIBINTL_H
 #include <libintl.h>
+#endif
+
+#ifdef HAVE_LOCALE_H
 #include <locale.h>
+#endif
 
 #include "stap-probe.h"
 
diff --git a/session.h b/session.h
index 5e65beb..2ec9150 100644
--- a/session.h
+++ b/session.h
@@ -10,7 +10,9 @@
 #define SESSION_H
 
 #include "config.h"
+#ifdef HAVE_LIBINTL_H
 #include <libintl.h>
+#endif
 #include <locale.h>
 
 #include <list>
diff --git a/staprun/mainloop.c b/staprun/mainloop.c
index e68efb3..07954fa 100644
--- a/staprun/mainloop.c
+++ b/staprun/mainloop.c
@@ -14,9 +14,14 @@
 #include <sys/utsname.h>
 #include <sys/ptrace.h>
 #include <sys/select.h>
+
+#ifdef HAVE_SEARCH_H
 #include <search.h>
-#include <wordexp.h>
+#endif
 
+#ifdef HAVE_WORDEXP_H
+#include <wordexp.h>
+#endif
 
 #define WORKAROUND_BZ467568 1  /* PR 6964; XXX: autoconf when able */
 
@@ -202,13 +207,16 @@ void start_cmd(void)
     exit(1);
   } else if (pid == 0) {
     /* We're in the target process.	 Let's start the execve of target_cmd, */
+#ifdef HAVE_WORDEXP_H
     int rc;
     wordexp_t words;
+#endif
     char *sh_c_argv[4] = { NULL, NULL, NULL, NULL };
 
     a.sa_handler = SIG_DFL;
     sigaction(SIGINT, &a, NULL);
 
+#ifdef HAVE_WORDEXP_H
     /* Formerly, we just execl'd(sh,-c,$target_cmd).  But this does't
        work well if target_cmd is a shell builtin.  We really want to
        probe a new child process, not a mishmash of shell-interpreted
@@ -220,10 +228,12 @@ void start_cmd(void)
            we use system(3) to evaluate 'stap -c CMD'.  We could generate
            an error message ... but let's just do what the user meant.
            rhbz 467652. */
+#endif
         sh_c_argv[0] = "sh";
         sh_c_argv[1] = "-c";
         sh_c_argv[2] = target_cmd;
         sh_c_argv[3] = NULL;
+#ifdef HAVE_WORDEXP_H
       }
     else
       {
@@ -240,6 +250,7 @@ void start_cmd(void)
           }
         if (words.we_wordc < 1) { _err ("empty -c COMMAND"); _exit (1); }
       }
+#endif
 
 /* PR 6964: when tracing all the user space process including the
    child the signal will be messed due to uprobe module or utrace
@@ -275,9 +286,12 @@ void start_cmd(void)
        ...  but see PR6964.  XXX: Instead, we could open-code the
        $PATH search here; put the pause() afterward; and run a direct
        execve instead of execvp().  */
-
+#ifdef HAVE_SEARCH_H
     if (execvp ((sh_c_argv[0] == NULL ? words.we_wordv[0] : sh_c_argv[0]),
                 (sh_c_argv[0] == NULL ? words.we_wordv    : sh_c_argv)) < 0)
+#else
+    if (execvp (sh_c_argv[0], sh_c_argv) < 0)
+#endif
       perror(target_cmd);
 
       /* (There is no need to wordfree() words; they are or will be gone.) */
@@ -661,6 +675,7 @@ int stp_main_loop(void)
               if (verbose) { /* don't eliminate duplicates */
                       eprintf("%.*s", (int) nb, recvbuf.payload.data);
                       break;
+#ifdef HAVE_SEARCH_H
               } else { /* eliminate duplicates */
                       static void *seen = 0;
                       static unsigned seen_count = 0;
@@ -706,6 +721,7 @@ int stp_main_loop(void)
                       } else { /* old message */
                               free (dupstr);
                       }
+#endif
               } /* duplicate elimination */
       /* Note that "ERROR:" should not be translated, since it is
        * part of the module cmd protocol. */
diff --git a/staprun/stapio.c b/staprun/stapio.c
index e8daf0e..3086457 100644
--- a/staprun/stapio.c
+++ b/staprun/stapio.c
@@ -25,11 +25,11 @@ char *__name__ = "stapio";
 
 int main(int argc, char **argv)
 {
-
+#ifdef HAVE_LOCALE_H
 	setlocale (LC_ALL, "");
 	bindtextdomain (PACKAGE, LOCALEDIR);
 	textdomain (PACKAGE);
-
+#endif
 	setup_signals();
 	parse_args(argc, argv);
 
diff --git a/staprun/staprun.h b/staprun/staprun.h
index 39cbcae..5555587 100644
--- a/staprun/staprun.h
+++ b/staprun/staprun.h
@@ -37,13 +37,20 @@
 #include <sys/wait.h>
 #include <sys/statfs.h>
 #include <syslog.h>
-#include <libintl.h>
-#include <locale.h>
 
 /* Include config.h to pick up dependency for --prefix usage. */
 #include "../config.h"
 #include "../privilege.h"
 
+#ifdef HAVE_LIBINTL_H
+#include <libintl.h>
+#endif
+
+#ifdef HAVE_LOCALE_H
+#include <locale.h>
+#endif
+
+
 /* define gettext options if NLS is set */
 #if ENABLE_NLS
 #define _(string) gettext(string)
diff --git a/util.cxx b/util.cxx
index aec6a36..d7f2f66 100644
--- a/util.cxx
+++ b/util.cxx
@@ -30,7 +30,9 @@ extern "C" {
 #include <fcntl.h>
 #include <grp.h>
 #include <pwd.h>
+#ifdef HAVE_SPAWN_H
 #include <spawn.h>
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/stat.h>
diff --git a/util.h b/util.h
index eb35106..7a2e9e8 100644
--- a/util.h
+++ b/util.h
@@ -15,11 +15,17 @@
 #include <iomanip>
 #include <map>
 extern "C" {
+#ifdef HAVE_LIBINTL_H
 #include <libintl.h>
+#endif
+#ifdef HAVE_LOCALE_H
 #include <locale.h>
+#endif
 #include <signal.h>
 #include <stdint.h>
+#ifdef HAVE_SPAWN_H
 #include <spawn.h>
+#endif
 #include <assert.h>
 #include <poll.h>
 }
-- 
1.8.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]