diff options
author | jerenkrantz <jerenkrantz@13f79535-47bb-0310-9956-ffa450edef68> | 2006-07-14 03:02:09 +0000 |
---|---|---|
committer | jerenkrantz <jerenkrantz@13f79535-47bb-0310-9956-ffa450edef68> | 2006-07-14 03:02:09 +0000 |
commit | dc5fee00bb63e78a7d94e6d4ca46f073801217c0 (patch) | |
tree | 9385a25769cc9b29c38165c9a099a8bab75e22c3 /build/jlibtool.c | |
parent | 5d133889f4de0882ed7deb76a8baac0dcdb5de83 (diff) | |
download | libapr-dc5fee00bb63e78a7d94e6d4ca46f073801217c0.tar.gz |
Allow jlibtool to compile and link on mingw.
The notable bits here are:
- mingw doesn't have fork() or waitpid()
- mkdir() doesn't take the umask parameter
- The MSVCRT runtime is 'safe' and reparses anything that isn't separated with
a double-quote; so add quotes around our escaped statement to run.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@421786 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'build/jlibtool.c')
-rw-r--r-- | build/jlibtool.c | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/build/jlibtool.c b/build/jlibtool.c index 7266b0919..0d577a459 100644 --- a/build/jlibtool.c +++ b/build/jlibtool.c @@ -19,7 +19,9 @@ #include <stdlib.h> #include <sys/stat.h> #include <sys/types.h> +#if !defined(__MINGW32__) #include <sys/wait.h> +#endif #include <unistd.h> #include <dirent.h> #include <errno.h> @@ -145,6 +147,21 @@ # define LD_LIBRARY_PATH "LD_LIBRARY_PATH" #endif +#if defined(__MINGW32__) +# define SHELL_CMD "sh" +# define DYNAMIC_LIB_EXT "dll" +# define MODULE_LIB_EXT "dll" +# define STATIC_LIB_EXT "a" +# define OBJECT_EXT "o" +# define LIBRARIAN "ar" +# define LIBRARIAN_OPTS "cr" +# define RANLIB "ranlib" +# define LINKER_FLAG_PREFIX "-Wl," +# define SHARED_OPTS "-shared" +# define MODULE_OPTS "-shared" +# define MKDIR_NO_UMASK +#endif + #ifndef SHELL_CMD #error Unsupported platform: Please add defines for SHELL_CMD etc. for your platform. #endif @@ -375,10 +392,14 @@ char *shell_esc(const char *str) unsigned char *d; const unsigned char *s; - cmd = (char *)malloc(2 * strlen(str) + 1); + cmd = (char *)malloc(2 * strlen(str) + 3); d = (unsigned char *)cmd; s = (const unsigned char *)str; +#ifdef __MINGW32__ + *d++ = '\"'; +#endif + for (; *s; ++s) { if (*s == '"') { *d++ = '\\'; @@ -390,6 +411,10 @@ char *shell_esc(const char *str) *d++ = *s; } +#ifdef __MINGW32__ + *d++ = '\"'; +#endif + *d = '\0'; return cmd; } @@ -409,8 +434,8 @@ int external_spawn(command_t *cmd, const char *file, const char **argv) if (cmd->options.dry_run) { return 0; } -#ifdef __EMX__ - return spawnvp(P_WAIT, file, argv); +#if defined(__EMX__) || defined(__MINGW32__) + return spawnvp(P_WAIT, argv[0], argv); #else { pid_t pid; @@ -1380,7 +1405,11 @@ int explode_static_lib(const char *lib, command_t *cmd_data) strcpy(tmpdir, lib); strcat(tmpdir, ".exploded"); +#ifdef MKDIR_NO_UMASK + mkdir(tmpdir); +#else mkdir(tmpdir, 0); +#endif push_count_chars(cmd_data->tmp_dirs, strdup(tmpdir)); getcwd(savewd, sizeof(savewd)); @@ -1721,7 +1750,11 @@ int run_mode(command_t *cmd_data) old_umask = umask(0); umask(old_umask); +#ifdef MKDIR_NO_UMASK + mkdir(".libs"); +#else mkdir(".libs", ~old_umask); +#endif } if (cmd_data->output == otStaticLibraryOnly || |