From: Charles Wilson Date: Thu, 7 Jun 2007 08:50:17 +0000 (+0000) Subject: * ltmain.m4sh (func_emit_libtool_cwrapperexe_source): X-Git-Tag: release-2-1b~118 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d754211cdbaf1a96885a9449f969545f4f85e905;p=thirdparty%2Flibtool.git * ltmain.m4sh (func_emit_libtool_cwrapperexe_source): ensure that generated source follows GCS as nearly as possible. --- diff --git a/ChangeLog b/ChangeLog index d117be735..2d3490ac4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,10 @@ -2007-04-27 Charles Wilson +2007-06-07 Charles Wilson + + * ltmain.m4sh (func_emit_libtool_cwrapperexe_source): + ensure that generated source follows GCS as nearly as + possible. + +2007-06-07 Charles Wilson * ltmain.m4sh (func_emit_libtool_wrapper_script): add code block to handle cases when wrapper script is in $objdir. diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh index b9d58fd90..c7bcb0d2a 100644 --- a/libltdl/config/ltmain.m4sh +++ b/libltdl/config/ltmain.m4sh @@ -2506,26 +2506,27 @@ EOF const char *program_name = NULL; -void * xmalloc (size_t num); -char * xstrdup (const char *string); -const char * base_name (const char *name); -char * find_executable(const char *wrapper); -char * chase_symlinks(const char *pathspec); -int make_executable(const char *path); -int check_executable(const char *path); -char * strendzap(char *str, const char *pat); +void *xmalloc (size_t num); +char *xstrdup (const char *string); +const char *base_name (const char *name); +char *find_executable (const char *wrapper); +char *chase_symlinks (const char *pathspec); +int make_executable (const char *path); +int check_executable (const char *path); +char *strendzap (char *str, const char *pat); void lt_fatal (const char *message, ...); -static const char* script_text = +static const char *script_text = EOF func_emit_libtool_wrapper_script | $SED -e 's/\([\\"]\)/\\\1/g' \ -e 's/\(WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\)=.*/\1=yes/' \ - -e 's/^/"/' -e 's/$/\\n"/' + -e 's/^/ "/' -e 's/$/\\n"/' echo ";" cat </dev/null || echo $SHELL` - case $lt_newargv0 in - *.exe | *.EXE) ;; - *) lt_newargv0=$lt_newargv0.exe ;; - esac - ;; - * ) lt_newargv0=$SHELL ;; + case $lt_newargv0 in + *.exe | *.EXE) ;; + *) lt_newargv0=$lt_newargv0.exe ;; + esac + ;; + * ) lt_newargv0=$SHELL ;; esac fi cat <= 0) && - ( - /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */ + if ((stat (path, &st) >= 0) && ( + /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */ #if defined (S_IXOTH) - ((st.st_mode & S_IXOTH) == S_IXOTH) || + ((st.st_mode & S_IXOTH) == S_IXOTH) || #endif #if defined (S_IXGRP) - ((st.st_mode & S_IXGRP) == S_IXGRP) || + ((st.st_mode & S_IXGRP) == S_IXGRP) || #endif - ((st.st_mode & S_IXUSR) == S_IXUSR)) - ) + ((st.st_mode & S_IXUSR) == S_IXUSR))) return 1; else return 0; } int -make_executable(const char * path) +make_executable (const char *path) { int rval = 0; struct stat st; @@ -2738,22 +2742,23 @@ make_executable(const char * path) /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */ int S_XFLAGS = #if defined (S_IXOTH) - S_IXOTH || + S_IXOTH || #endif #if defined (S_IXGRP) - S_IXGRP || + S_IXGRP || #endif - S_IXUSR; + S_IXUSR; - LTWRAPPER_DEBUGPRINTF("(make_executable) : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!"); - if ((!path) || (!*path)) - return 0; + LTWRAPPER_DEBUGPRINTF ("(make_executable) : %s\n", + path ? (*path ? path : "EMPTY!") : "NULL!"); + if ((!path) || (!*path)) + return 0; - if (stat (path, &st) >= 0) + if (stat (path, &st) >= 0) { - rval = chmod ( path, st.st_mode | S_XFLAGS ); + rval = chmod (path, st.st_mode | S_XFLAGS); } - return rval; + return rval; } /* Searches for the full path of the wrapper. Returns @@ -2761,184 +2766,188 @@ make_executable(const char * path) Does not chase symlinks, even on platforms that support them. */ char * -find_executable (const char* wrapper) +find_executable (const char *wrapper) { int has_slash = 0; - const char* p; - const char* p_next; + const char *p; + const char *p_next; /* static buffer for getcwd */ char tmp[LT_PATHMAX + 1]; int tmp_len; - char* concat_name; + char *concat_name; - LTWRAPPER_DEBUGPRINTF("(find_executable) : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"); + LTWRAPPER_DEBUGPRINTF ("(find_executable) : %s\n", + wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"); if ((wrapper == NULL) || (*wrapper == '\0')) return NULL; /* Absolute path? */ #if defined (HAVE_DOS_BASED_FILE_SYSTEM) - if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':') - { - concat_name = xstrdup (wrapper); - if (check_executable(concat_name)) - return concat_name; - XFREE(concat_name); - } - else - { -#endif - if (IS_DIR_SEPARATOR (wrapper[0])) + if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') { concat_name = xstrdup (wrapper); - if (check_executable(concat_name)) + if (check_executable (concat_name)) return concat_name; - XFREE(concat_name); + XFREE (concat_name); } + else + { +#endif + if (IS_DIR_SEPARATOR (wrapper[0])) + { + concat_name = xstrdup (wrapper); + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + } #if defined (HAVE_DOS_BASED_FILE_SYSTEM) - } + } #endif for (p = wrapper; *p; p++) if (*p == '/') - { - has_slash = 1; - break; - } + { + has_slash = 1; + break; + } if (!has_slash) - { - /* no slashes; search PATH */ - const char* path = getenv ("PATH"); - if (path != NULL) { - for (p = path; *p; p = p_next) - { - const char* q; - size_t p_len; - for (q = p; *q; q++) - if (IS_PATH_SEPARATOR(*q)) - break; - p_len = q - p; - p_next = (*q == '\0' ? q : q + 1); - if (p_len == 0) - { - /* empty path: current directory */ - if (getcwd (tmp, LT_PATHMAX) == NULL) - lt_fatal ("getcwd failed"); - tmp_len = strlen(tmp); - concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1); - memcpy (concat_name, tmp, tmp_len); - concat_name[tmp_len] = '/'; - strcpy (concat_name + tmp_len + 1, wrapper); - } - else + /* no slashes; search PATH */ + const char *path = getenv ("PATH"); + if (path != NULL) { - concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1); - memcpy (concat_name, p, p_len); - concat_name[p_len] = '/'; - strcpy (concat_name + p_len + 1, wrapper); + for (p = path; *p; p = p_next) + { + const char *q; + size_t p_len; + for (q = p; *q; q++) + if (IS_PATH_SEPARATOR (*q)) + break; + p_len = q - p; + p_next = (*q == '\0' ? q : q + 1); + if (p_len == 0) + { + /* empty path: current directory */ + if (getcwd (tmp, LT_PATHMAX) == NULL) + lt_fatal ("getcwd failed"); + tmp_len = strlen (tmp); + concat_name = + XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); + memcpy (concat_name, tmp, tmp_len); + concat_name[tmp_len] = '/'; + strcpy (concat_name + tmp_len + 1, wrapper); + } + else + { + concat_name = + XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); + memcpy (concat_name, p, p_len); + concat_name[p_len] = '/'; + strcpy (concat_name + p_len + 1, wrapper); + } + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + } } - if (check_executable(concat_name)) - return concat_name; - XFREE(concat_name); - } + /* not found in PATH; assume curdir */ } - /* not found in PATH; assume curdir */ - } /* Relative path | not found in path: prepend cwd */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal ("getcwd failed"); - tmp_len = strlen(tmp); - concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1); + tmp_len = strlen (tmp); + concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); - if (check_executable(concat_name)) + if (check_executable (concat_name)) return concat_name; - XFREE(concat_name); + XFREE (concat_name); return NULL; } char * -chase_symlinks(const char *pathspec) +chase_symlinks (const char *pathspec) { #ifndef S_ISLNK - return xstrdup ( pathspec ); + return xstrdup (pathspec); #else - char buf[LT_PATHMAX]; - struct stat s; - int rv = 0; - char* tmp_pathspec = xstrdup (pathspec); - char* p; - int has_symlinks = 0; - while (strlen(tmp_pathspec) && !has_symlinks) + char buf[LT_PATHMAX]; + struct stat s; + int rv = 0; + char *tmp_pathspec = xstrdup (pathspec); + char *p; + int has_symlinks = 0; + while (strlen (tmp_pathspec) && !has_symlinks) { - LTWRAPPER_DEBUGPRINTF("checking path component for symlinks: %s\n", tmp_pathspec); - if (lstat (tmp_pathspec, &s) == 0) - { - if (S_ISLNK(s.st_mode) != 0) - { - has_symlinks = 1; - break; - } - - /* search backwards for last DIR_SEPARATOR */ - p = tmp_pathspec + strlen(tmp_pathspec) - 1; - while ( (p > tmp_pathspec) && (! IS_DIR_SEPARATOR(*p)) ) - p--; - if ( (p == tmp_pathspec) && (! IS_DIR_SEPARATOR(*p)) ) - { - /* no more DIR_SEPARATORS left */ - break; - } - *p = '\0'; - } - else - { - char* errstr = strerror(errno); - lt_fatal("Error accessing file %s (%s)", tmp_pathspec, errstr); - } + LTWRAPPER_DEBUGPRINTF ("checking path component for symlinks: %s\n", + tmp_pathspec); + if (lstat (tmp_pathspec, &s) == 0) + { + if (S_ISLNK (s.st_mode) != 0) + { + has_symlinks = 1; + break; + } + + /* search backwards for last DIR_SEPARATOR */ + p = tmp_pathspec + strlen (tmp_pathspec) - 1; + while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) + p--; + if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) + { + /* no more DIR_SEPARATORS left */ + break; + } + *p = '\0'; + } + else + { + char *errstr = strerror (errno); + lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr); + } } - XFREE(tmp_pathspec); + XFREE (tmp_pathspec); - if (!has_symlinks) + if (!has_symlinks) { - return xstrdup ( pathspec ); + return xstrdup (pathspec); } - tmp_pathspec = realpath ( pathspec, buf ); - if (tmp_pathspec == 0) + tmp_pathspec = realpath (pathspec, buf); + if (tmp_pathspec == 0) { - lt_fatal("Could not follow symlinks for %s", pathspec); + lt_fatal ("Could not follow symlinks for %s", pathspec); } - return xstrdup ( tmp_pathspec ); + return xstrdup (tmp_pathspec); #endif } char * -strendzap(char *str, const char *pat) +strendzap (char *str, const char *pat) { size_t len, patlen; - assert(str != NULL); - assert(pat != NULL); + assert (str != NULL); + assert (pat != NULL); - len = strlen(str); - patlen = strlen(pat); + len = strlen (str); + patlen = strlen (pat); if (patlen <= len) - { - str += len - patlen; - if (strcmp(str, pat) == 0) - *str = '\0'; - } + { + str += len - patlen; + if (strcmp (str, pat) == 0) + *str = '\0'; + } return str; } static void -lt_error_core (int exit_status, const char * mode, - const char * message, va_list ap) +lt_error_core (int exit_status, const char *mode, + const char *message, va_list ap) { fprintf (stderr, "%s: %s: ", program_name, mode); vfprintf (stderr, message, ap);