All of these patches have now been acked and tested. Thanks are due to to Ian Campbell and Roger Pau Monne. I am posting them in their final form and will apply them very shortly. 01/27 libxl: handle POLLERR, POLLHUP, POLLNVAL properly 02/27 libxl: support multiple libxl__ev_fds for the same fd 03/27 libxl: event API: new facilities for waiting for subprocesses 04/27 autoconf: trim the configure script; use autoheader 05/27 autoconf: New test for openpty et al. 06/27 libxl: provide libxl__remove_file et al. 07/27 libxl: Introduce libxl__sendmsg_fds and libxl__recvmsg_fds 08/27 libxl: Clean up setdefault in do_domain_create 09/27 libxl: provide libxl__datacopier_* 10/27 libxl: provide libxl__openpty_* 11/27 libxl: ao: Convert libxl_run_bootloader 12/27 libxl: make libxl_create_logfile const-correct 13/27 libxl: log bootloader output 14/27 libxl: Allow AO_GC and EGC_GC even if not used 15/27 libxl: add a dummy ao_how to libxl_domain_core_dump 16/27 libxl: remove ctx->waitpid_instead 17/27 libxl: change some structures to unit arrays 18/27 libxl: ao: convert libxl__spawn_* 19/27 libxl: set guest_domid even if libxl__domain_make fails 20/27 libxl: make libxl_create run bootloader via callback 21/27 libxl: Fix an ao completion bug; document locking policy 22/27 libxl: provide progress reporting for long-running operations 23/27 libxl: remove malloc failure handling from NEW_EVENT 24/27 libxl: convert console callback to libxl_asyncprogress_how 25/27 libxl: clarify definition of "slow" operation 26/27 libxl: child processes cleanups 27/27 libxl: abort bootloader invocation when domain dies
Ian Jackson
2012-May-11 17:57 UTC
[PATCH 01/27] libxl: handle POLLERR, POLLHUP, POLLNVAL properly
Pass POLLERR and POLLHUP to fd callbacks, as is necessary. Crash on POLLNVAL since that means our fds are messed up. Document the behaviour (including the fact that poll sometimes sets POLLHUP or POLLERR even if only POLLIN was requested. Fix the one current fd callback to do something with POLLERR|POLLHUP. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> --- tools/libxl/libxl_event.c | 7 ++++++- tools/libxl/libxl_internal.h | 5 +++++ 2 files changed, 11 insertions(+), 1 deletions(-) diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index e11a4e7..5046938 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -339,6 +339,9 @@ static void watchfd_callback(libxl__egc *egc, libxl__ev_fd *ev, { EGC_GC; + if (revents & (POLLERR|POLLHUP)) + LIBXL__EVENT_DISASTER(egc, "unexpected poll event on watch fd", 0, 0); + for (;;) { char **event = xs_check_watch(CTX->xsh); if (!event) { @@ -743,7 +746,9 @@ static int afterpoll_check_fd(libxl__poller *poller, /* again, stale slot entry */ return 0; - int revents = fds[slot].revents & events; + assert(!(fds[slot].revents & POLLNVAL)); + + int revents = fds[slot].revents & (events | POLLERR | POLLHUP); /* we mask in case requested events have changed */ return revents; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 8947ddd..74e640f 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -128,6 +128,11 @@ _hidden void libxl__alloc_failed(libxl_ctx *, const char *func, typedef struct libxl__ev_fd libxl__ev_fd; typedef void libxl__ev_fd_callback(libxl__egc *egc, libxl__ev_fd *ev, int fd, short events, short revents); + /* Note that revents may contain POLLERR or POLLHUP regardless of + * events; otherwise revents contains only bits in events. Contrary + * to the documentation for poll(2), POLLERR and POLLHUP can occur + * even if only POLLIN was set in events. (POLLNVAL is a fatal + * error and will cause libxl event machinery to fail an assertion.) */ struct libxl__ev_fd { /* caller should include this in their own struct */ /* read-only for caller, who may read only when registered: */ -- 1.7.2.5
Ian Jackson
2012-May-11 17:57 UTC
[PATCH 02/27] libxl: support multiple libxl__ev_fds for the same fd
We need a slightly more sophisticated data structure to allow this, where we record the slot not just for each fd but also for each (fd,eventbit) where eventbit is POLLIN, POLLPRI, POLLOUT. Document the new relaxed restriction. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Changes since v6: * Fix typo --- tools/libxl/libxl_event.c | 62 +++++++++++++++++++++++------------------ tools/libxl/libxl_internal.h | 10 +++++-- 2 files changed, 42 insertions(+), 30 deletions(-) diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index 5046938..93c1d1f 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -639,10 +639,11 @@ static int beforepoll_internal(libxl__gc *gc, libxl__poller *poller, /* - * In order to be able to efficiently find the libxl__ev_fd - * for a struct poll during _afterpoll, we maintain a shadow - * data structure in CTX->fd_beforepolled: each slot in - * the fds array corresponds to a slot in fd_beforepolled. + * In order to be able to efficiently find the libxl__ev_fd for a + * struct poll during _afterpoll, we maintain a shadow data + * structure in CTX->fd_rindices: each fd corresponds to a slot in + * fd_rindices, and each element in the rindices is three indices + * into the fd array (for POLLIN, POLLPRI and POLLOUT). */ if (*nfds_io) { @@ -663,14 +664,16 @@ static int beforepoll_internal(libxl__gc *gc, libxl__poller *poller, }); /* make sure our array is as big as *nfds_io */ - if (poller->fd_rindex_allocd < maxfd) { - assert(maxfd < INT_MAX / sizeof(int) / 2); - int *newarray = realloc(poller->fd_rindex, sizeof(int) * maxfd); - if (!newarray) { rc = ERROR_NOMEM; goto out; } - memset(newarray + poller->fd_rindex_allocd, 0, - sizeof(int) * (maxfd - poller->fd_rindex_allocd)); - poller->fd_rindex = newarray; - poller->fd_rindex_allocd = maxfd; + if (poller->fd_rindices_allocd < maxfd) { + assert(ARRAY_SIZE_OK(poller->fd_rindices, maxfd)); + poller->fd_rindices + libxl__realloc(0, poller->fd_rindices, + maxfd * sizeof(*poller->fd_rindices)); + memset(poller->fd_rindices + poller->fd_rindices_allocd, + 0, + (maxfd - poller->fd_rindices_allocd) + * sizeof(*poller->fd_rindices)); + poller->fd_rindices_allocd = maxfd; } } @@ -681,8 +684,10 @@ static int beforepoll_internal(libxl__gc *gc, libxl__poller *poller, fds[used].fd = req_fd; fds[used].events = req_events; fds[used].revents = 0; - assert(req_fd < poller->fd_rindex_allocd); - poller->fd_rindex[req_fd] = used; + assert(req_fd < poller->fd_rindices_allocd); + if (req_events & POLLIN) poller->fd_rindices[req_fd][0] = used; + if (req_events & POLLPRI) poller->fd_rindices[req_fd][1] = used; + if (req_events & POLLOUT) poller->fd_rindices[req_fd][2] = used; } used++; }); @@ -710,7 +715,6 @@ static int beforepoll_internal(libxl__gc *gc, libxl__poller *poller, *timeout_upd = our_timeout; } - out: return rc; } @@ -732,24 +736,28 @@ static int afterpoll_check_fd(libxl__poller *poller, int fd, int events) /* returns mask of events which were requested and occurred */ { - if (fd >= poller->fd_rindex_allocd) + if (fd >= poller->fd_rindices_allocd) /* added after we went into poll, have to try again */ return 0; - int slot = poller->fd_rindex[fd]; + int i, revents = 0; + for (i=0; i<3; i++) { + int slot = poller->fd_rindices[fd][i]; - if (slot >= nfds) - /* stale slot entry; again, added afterwards */ - return 0; + if (slot >= nfds) + /* stale slot entry; again, added afterwards */ + continue; - if (fds[slot].fd != fd) - /* again, stale slot entry */ - return 0; + if (fds[slot].fd != fd) + /* again, stale slot entry */ + continue; - assert(!(fds[slot].revents & POLLNVAL)); + assert(!(fds[slot].revents & POLLNVAL)); + revents |= fds[slot].revents; + } - int revents = fds[slot].revents & (events | POLLERR | POLLHUP); /* we mask in case requested events have changed */ + revents &= (events | POLLERR | POLLHUP); return revents; } @@ -1013,7 +1021,7 @@ int libxl__poller_init(libxl_ctx *ctx, libxl__poller *p) { int r, rc; p->fd_polls = 0; - p->fd_rindex = 0; + p->fd_rindices = 0; r = pipe(p->wakeup_pipe); if (r) { @@ -1040,7 +1048,7 @@ void libxl__poller_dispose(libxl__poller *p) if (p->wakeup_pipe[1] > 0) close(p->wakeup_pipe[1]); if (p->wakeup_pipe[0] > 0) close(p->wakeup_pipe[0]); free(p->fd_polls); - free(p->fd_rindex); + free(p->fd_rindices); } libxl__poller *libxl__poller_get(libxl_ctx *ctx) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 74e640f..01c9ba9 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -132,7 +132,11 @@ typedef void libxl__ev_fd_callback(libxl__egc *egc, libxl__ev_fd *ev, * events; otherwise revents contains only bits in events. Contrary * to the documentation for poll(2), POLLERR and POLLHUP can occur * even if only POLLIN was set in events. (POLLNVAL is a fatal - * error and will cause libxl event machinery to fail an assertion.) */ + * error and will cause libxl event machinery to fail an assertion.) + * + * It is not permitted to listen for the same or overlapping events + * on the same fd using multiple different libxl__ev_fd''s. + */ struct libxl__ev_fd { /* caller should include this in their own struct */ /* read-only for caller, who may read only when registered: */ @@ -248,8 +252,8 @@ struct libxl__poller { struct pollfd *fd_polls; int fd_polls_allocd; - int fd_rindex_allocd; - int *fd_rindex; /* see libxl_osevent_beforepoll */ + int fd_rindices_allocd; + int (*fd_rindices)[3]; /* see libxl_osevent_beforepoll */ int wakeup_pipe[2]; /* 0 means no fd allocated */ }; -- 1.7.2.5
Ian Jackson
2012-May-11 17:57 UTC
[PATCH 03/27] libxl: event API: new facilities for waiting for subprocesses
The current arrangements in libxl for spawning subprocesses have two key problems: (i) they make unwarranted (and largely undocumented) assumptions about the caller''s use of subprocesses, (ii) they aren''t integrated into the event system and can''t be made asynchronous etc. So replace them with a new set of facilities. Primarily, from the point of view of code inside libxl, this is libxl__ev_child_fork which is both (a) a version of fork() and (b) an event source which generates a callback when the child dies. From the point of view of the application, we fully document our use of SIGCHLD. The application can tell us whether it wants to own SIGCHLD or not; if it does, it has to tell us about deaths of our children. Currently there are no callers in libxl which use these facilities. All code in libxl which forks needs to be converted and libxl_fork needse to be be abolished. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> --- tools/libxl/libxl.c | 17 +++- tools/libxl/libxl.h | 1 + tools/libxl/libxl_event.c | 53 +++++++-- tools/libxl/libxl_event.h | 147 +++++++++++++++++++++++- tools/libxl/libxl_fork.c | 255 ++++++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_internal.h | 62 ++++++++++- 6 files changed, 515 insertions(+), 20 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index c420e19..939cc02 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -39,7 +39,7 @@ int libxl_ctx_alloc(libxl_ctx **pctx, int version, memset(ctx, 0, sizeof(libxl_ctx)); ctx->lg = lg; - /* First initialise pointers (cannot fail) */ + /* First initialise pointers etc. (cannot fail) */ LIBXL_TAILQ_INIT(&ctx->occurred); @@ -58,6 +58,11 @@ int libxl_ctx_alloc(libxl_ctx **pctx, int version, LIBXL_TAILQ_INIT(&ctx->death_list); libxl__ev_xswatch_init(&ctx->death_watch); + ctx->childproc_hooks = &libxl__childproc_default_hooks; + ctx->childproc_user = 0; + + ctx->sigchld_selfpipe[0] = -1; + /* The mutex is special because we can''t idempotently destroy it */ if (libxl__init_recursive_mutex(ctx, &ctx->lock) < 0) { @@ -160,6 +165,16 @@ int libxl_ctx_free(libxl_ctx *ctx) discard_events(&ctx->occurred); + /* If we have outstanding children, then the application inherits + * them; we wish the application good luck with understanding + * this if and when it reaps them. */ + libxl__sigchld_removehandler(ctx); + + if (ctx->sigchld_selfpipe[0] >= 0) { + close(ctx->sigchld_selfpipe[0]); + close(ctx->sigchld_selfpipe[1]); + } + pthread_mutex_destroy(&ctx->lock); GC_FREE; diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index d59f0ee..fb90aed 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -380,6 +380,7 @@ enum { ERROR_NOT_READY = -11, ERROR_OSEVENT_REG_FAIL = -12, ERROR_BUFFERFULL = -13, + ERROR_UNKNOWN_CHILD = -14, }; diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index 93c1d1f..3e784f0 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -627,6 +627,10 @@ static int beforepoll_internal(libxl__gc *gc, libxl__poller *poller, \ REQUIRE_FD(poller->wakeup_pipe[0], POLLIN, BODY); \ \ + int selfpipe = libxl__fork_selfpipe_active(CTX); \ + if (selfpipe >= 0) \ + REQUIRE_FD(selfpipe, POLLIN, BODY); \ + \ }while(0) #define REQUIRE_FD(req_fd_, req_events_, BODY) do{ \ @@ -766,10 +770,11 @@ static void afterpoll_internal(libxl__egc *egc, libxl__poller *poller, int nfds, const struct pollfd *fds, struct timeval now) { + /* May make callbacks into the application for child processes. + * ctx must be locked exactly once */ EGC_GC; libxl__ev_fd *efd; - LIBXL_LIST_FOREACH(efd, &CTX->efds, entry) { if (!efd->events) continue; @@ -780,11 +785,16 @@ static void afterpoll_internal(libxl__egc *egc, libxl__poller *poller, } if (afterpoll_check_fd(poller,fds,nfds, poller->wakeup_pipe[0],POLLIN)) { - char buf[256]; - int r = read(poller->wakeup_pipe[0], buf, sizeof(buf)); - if (r < 0) - if (errno != EINTR && errno != EWOULDBLOCK) - LIBXL__EVENT_DISASTER(egc, "read wakeup", errno, 0); + int e = libxl__self_pipe_eatall(poller->wakeup_pipe[0]); + if (e) LIBXL__EVENT_DISASTER(egc, "read wakeup", e, 0); + } + + int selfpipe = libxl__fork_selfpipe_active(CTX); + if (selfpipe >= 0 && + afterpoll_check_fd(poller,fds,nfds, selfpipe, POLLIN)) { + int e = libxl__self_pipe_eatall(selfpipe); + if (e) LIBXL__EVENT_DISASTER(egc, "read sigchld pipe", e, 0); + libxl__fork_selfpipe_woken(egc); } for (;;) { @@ -1082,16 +1092,37 @@ void libxl__poller_put(libxl_ctx *ctx, libxl__poller *p) void libxl__poller_wakeup(libxl__egc *egc, libxl__poller *p) { + int e = libxl__self_pipe_wakeup(p->wakeup_pipe[1]); + if (e) LIBXL__EVENT_DISASTER(egc, "cannot poke watch pipe", e, 0); +} + +int libxl__self_pipe_wakeup(int fd) +{ static const char buf[1] = ""; for (;;) { - int r = write(p->wakeup_pipe[1], buf, 1); - if (r==1) return; + int r = write(fd, buf, 1); + if (r==1) return 0; assert(r==-1); if (errno == EINTR) continue; - if (errno == EWOULDBLOCK) return; - LIBXL__EVENT_DISASTER(egc, "cannot poke watch pipe", errno, 0); - return; + if (errno == EWOULDBLOCK) return 0; + assert(errno); + return errno; + } +} + +int libxl__self_pipe_eatall(int fd) +{ + char buf[256]; + for (;;) { + int r = read(fd, buf, sizeof(buf)); + if (r == sizeof(buf)) continue; + if (r >= 0) return 0; + assert(r == -1); + if (errno == EINTR) continue; + if (errno == EWOULDBLOCK) return 0; + assert(errno); + return errno; } } diff --git a/tools/libxl/libxl_event.h b/tools/libxl/libxl_event.h index 2d2196f..713d96d 100644 --- a/tools/libxl/libxl_event.h +++ b/tools/libxl/libxl_event.h @@ -163,11 +163,6 @@ void libxl_event_register_callbacks(libxl_ctx *ctx, * After libxl_ctx_free, all corresponding evgen handles become * invalid and must no longer be passed to evdisable. * - * Events enabled with evenable prior to a fork and libxl_ctx_postfork - * are no longer generated after the fork/postfork; however the evgen - * structures are still valid and must be passed to evdisable if the - * memory they use should not be leaked. - * * Applications should ensure that they eventually retrieve every * event using libxl_event_check or libxl_event_wait, since events * which occur but are not retreived by the application will be queued @@ -372,6 +367,148 @@ void libxl_osevent_occurred_fd(libxl_ctx *ctx, void *for_libxl, void libxl_osevent_occurred_timeout(libxl_ctx *ctx, void *for_libxl); +/*======================================================================*/ + +/* + * Subprocess handling. + * + * Unfortunately the POSIX interface makes this very awkward. + * + * There are two possible arrangements for collecting statuses from + * wait/waitpid. + * + * For naive programs: + * + * libxl will keep a SIGCHLD handler installed whenever it has an + * active (unreaped) child. It will reap all children with + * wait(); any children it does not recognise will be passed to + * the application via an optional callback (and will result in + * logged warnings if no callback is provided or the callback + * denies responsibility for the child). + * + * libxl may have children whenever: + * + * - libxl is performing an operation which can be made + * asynchronous; ie one taking a libxl_asyncop_how, even + * if NULL is passed indicating that the operation is + * synchronous; or + * + * - events of any kind are being generated, as requested + * by libxl_evenable_.... + * + * A multithreaded application which is naive in this sense may + * block SIGCHLD on some of its threads, but there must be at + * least one thread that has SIGCHLD unblocked. libxl will not + * modify the blocking flag for SIGCHLD (except that it may create + * internal service threads with all signals blocked). + * + * A naive program must only have at any one time only + * one libxl context which might have children. + * + * For programs which run their own children alongside libxl''s: + * + * A program which does this must call libxl_childproc_setmode. + * There are two options: + * + * libxl_sigchld_owner_mainloop: + * The application must install a SIGCHLD handler and reap (at + * least) all of libxl''s children and pass their exit status + * to libxl by calling libxl_childproc_exited. + * + * libxl_sigchld_owner_libxl_always: + * The application expects libxl to reap all of its children, + * and provides a callback to be notified of their exit + * statues. + * + * An application which fails to call setmode, or which passes 0 for + * hooks, while it uses any libxl operation which might + * create or use child processes (see above): + * - Must not have any child processes running. + * - Must not install a SIGCHLD handler. + * - Must not reap any children. + */ + + +typedef enum { + /* libxl owns SIGCHLD whenever it has a child. */ + libxl_sigchld_owner_libxl, + + /* Application promises to call libxl_childproc_exited but NOT + * from within a signal handler. libxl will not itself arrange to + * (un)block or catch SIGCHLD. */ + libxl_sigchld_owner_mainloop, + + /* libxl owns SIGCHLD all the time, and the application is + * relying on libxl''s event loop for reaping its own children. */ + libxl_sigchld_owner_libxl_always, +} libxl_sigchld_owner; + +typedef struct { + libxl_sigchld_owner chldowner; + + /* All of these are optional: */ + + /* Called by libxl instead of fork. Should behave exactly like + * fork, including setting errno etc. May NOT reenter into libxl. + * Application may use this to discover pids of libxl''s children, + * for example. + */ + pid_t (*fork_replacement)(void *user); + + /* With libxl_sigchld_owner_libxl, called by libxl when it has + * reaped a pid. (Not permitted with _owner_mainloop.) + * + * Should return 0 if the child was recognised by the application + * (or if the application does not keep those kind of records), + * ERROR_UNKNOWN_CHILD if the application knows that the child is not + * the application''s; if it returns another error code it is a + * disaster as described for libxl_event_register_callbacks. + * (libxl will report unexpected children to its error log.) + * + * If not supplied, the application is assumed not to start + * any children of its own. + * + * This function is NOT called from within the signal handler. + * Rather it will be called from inside a libxl''s event handling + * code and thus only when libxl is running, for example from + * within libxl_event_wait. (libxl uses the self-pipe trick + * to implement this.) + * + * childproc_exited_callback may call back into libxl, but it + * is best to avoid making long-running libxl calls as that might + * stall the calling event loop while the nested operation + * completes. + */ + int (*reaped_callback)(pid_t, int status, void *user); +} libxl_childproc_hooks; + +/* hooks may be 0 in which is equivalent to &{ libxl_sigchld_owner_libxl, 0, 0 } + * + * May not be called when libxl might have any child processes, or the + * behaviour is undefined. So it is best to call this at + * initialisation. + */ +void libxl_childproc_setmode(libxl_ctx *ctx, const libxl_childproc_hooks *hooks, + void *user); + +/* + * This function is for an application which owns SIGCHLD and which + * therefore reaps all of the process''s children. + * + * May be called only by an application which has called setmode with + * chldowner == libxl_sigchld_owner_mainloop. If pid was a process started + * by this instance of libxl, returns 0 after doing whatever + * processing is appropriate. Otherwise silently returns + * ERROR_UNKNOWN_CHILD. No other error returns are possible. + * + * May NOT be called from within a signal handler which might + * interrupt any libxl operation. The application will almost + * certainly need to use the self-pipe trick (or a working pselect or + * ppoll) to implement this. + */ +int libxl_childproc_reaped(libxl_ctx *ctx, pid_t, int status); + + /* * An application which initialises a libxl_ctx in a parent process * and then forks a child which does not quickly exec, must diff --git a/tools/libxl/libxl_fork.c b/tools/libxl/libxl_fork.c index dce88ad..35c8bdd 100644 --- a/tools/libxl/libxl_fork.c +++ b/tools/libxl/libxl_fork.c @@ -46,6 +46,12 @@ static int atfork_registered; static LIBXL_LIST_HEAD(, libxl__carefd) carefds LIBXL_LIST_HEAD_INITIALIZER(carefds); +/* non-null iff installed, protected by no_forking */ +static libxl_ctx *sigchld_owner; +static struct sigaction sigchld_saved_action; + +static void sigchld_removehandler_core(void); + static void atfork_lock(void) { int r = pthread_mutex_lock(&no_forking); @@ -107,6 +113,7 @@ void libxl_postfork_child_noexec(libxl_ctx *ctx) int r; atfork_lock(); + LIBXL_LIST_FOREACH_SAFE(cf, &carefds, entry, cf_tmp) { if (cf->fd >= 0) { r = close(cf->fd); @@ -118,6 +125,10 @@ void libxl_postfork_child_noexec(libxl_ctx *ctx) free(cf); } LIBXL_LIST_INIT(&carefds); + + if (sigchld_owner) + sigchld_removehandler_core(); + atfork_unlock(); } @@ -141,6 +152,250 @@ int libxl__carefd_fd(const libxl__carefd *cf) } /* + * Actual child process handling + */ + +static void sigchld_handler(int signo) +{ + int e = libxl__self_pipe_wakeup(sigchld_owner->sigchld_selfpipe[1]); + assert(!e); /* errors are probably EBADF, very bad */ +} + +static void sigchld_removehandler_core(void) +{ + struct sigaction was; + int r; + + r = sigaction(SIGCHLD, &sigchld_saved_action, &was); + assert(!r); + assert(!(was.sa_flags & SA_SIGINFO)); + assert(was.sa_handler == sigchld_handler); + sigchld_owner = 0; +} + +void libxl__sigchld_removehandler(libxl_ctx *ctx) /* non-reentrant */ +{ + atfork_lock(); + if (sigchld_owner == ctx) + sigchld_removehandler_core(); + atfork_unlock(); +} + +int libxl__sigchld_installhandler(libxl_ctx *ctx) /* non-reentrant */ +{ + int r, rc; + + if (ctx->sigchld_selfpipe[0] < 0) { + r = pipe(ctx->sigchld_selfpipe); + if (r) { + ctx->sigchld_selfpipe[0] = -1; + LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, + "failed to create sigchld pipe"); + rc = ERROR_FAIL; + goto out; + } + } + + atfork_lock(); + if (sigchld_owner != ctx) { + struct sigaction ours; + + assert(!sigchld_owner); + sigchld_owner = ctx; + + memset(&ours,0,sizeof(ours)); + ours.sa_handler = sigchld_handler; + sigemptyset(&ours.sa_mask); + ours.sa_flags = SA_NOCLDSTOP | SA_RESTART; + r = sigaction(SIGCHLD, &ours, &sigchld_saved_action); + assert(!r); + + assert(((void)"application must negotiate with libxl about SIGCHLD", + !(sigchld_saved_action.sa_flags & SA_SIGINFO) && + (sigchld_saved_action.sa_handler == SIG_DFL || + sigchld_saved_action.sa_handler == SIG_IGN))); + } + atfork_unlock(); + + rc = 0; + out: + return rc; +} + +static int chldmode_ours(libxl_ctx *ctx) +{ + return ctx->childproc_hooks->chldowner == libxl_sigchld_owner_libxl; +} + +int libxl__fork_selfpipe_active(libxl_ctx *ctx) +{ + /* Returns the fd to read, or -1 */ + if (!chldmode_ours(ctx)) + return -1; + + if (LIBXL_LIST_EMPTY(&ctx->children)) + return -1; + + return ctx->sigchld_selfpipe[0]; +} + +static void perhaps_removehandler(libxl_ctx *ctx) +{ + if (LIBXL_LIST_EMPTY(&ctx->children) && + ctx->childproc_hooks->chldowner != libxl_sigchld_owner_libxl_always) + libxl__sigchld_removehandler(ctx); +} + +static int childproc_reaped(libxl__egc *egc, pid_t pid, int status) +{ + EGC_GC; + libxl__ev_child *ch; + + LIBXL_LIST_FOREACH(ch, &CTX->children, entry) + if (ch->pid == pid) + goto found; + + /* not found */ + return ERROR_UNKNOWN_CHILD; + + found: + LIBXL_LIST_REMOVE(ch, entry); + ch->pid = -1; + ch->callback(egc, ch, pid, status); + + perhaps_removehandler(CTX); + + return 0; +} + +int libxl_childproc_reaped(libxl_ctx *ctx, pid_t pid, int status) +{ + EGC_INIT(ctx); + CTX_LOCK; + int rc = childproc_reaped(egc, pid, status); + CTX_UNLOCK; + EGC_FREE; + return rc; +} + +void libxl__fork_selfpipe_woken(libxl__egc *egc) +{ + /* May make callbacks into the application for child processes. + * ctx must be locked EXACTLY ONCE */ + EGC_GC; + + while (chldmode_ours(CTX) /* in case the app changes the mode */) { + int status; + pid_t pid = waitpid(-1, &status, WNOHANG); + + if (pid == 0) return; + + if (pid == -1) { + if (errno == ECHILD) return; + if (errno == EINTR) continue; + LIBXL__EVENT_DISASTER(egc, "waitpid() failed", errno, 0); + return; + } + + int rc = childproc_reaped(egc, pid, status); + + if (rc) { + if (CTX->childproc_hooks->reaped_callback) { + CTX_UNLOCK; + rc = CTX->childproc_hooks->reaped_callback + (pid, status, CTX->childproc_user); + CTX_LOCK; + if (rc != 0 && rc != ERROR_UNKNOWN_CHILD) { + char disasterbuf[200]; + snprintf(disasterbuf, sizeof(disasterbuf), " reported by" + " libxl_childproc_hooks->reaped_callback" + " (for pid=%lu, status=%d; error code %d)", + (unsigned long)pid, status, rc); + LIBXL__EVENT_DISASTER(egc, disasterbuf, 0, 0); + return; + } + } else { + rc = ERROR_UNKNOWN_CHILD; + } + if (rc) + libxl_report_child_exitstatus(CTX, XTL_WARN, + "unknown child", (long)pid, status); + } + } +} + +pid_t libxl__ev_child_fork(libxl__gc *gc, libxl__ev_child *ch, + libxl__ev_child_callback *death) +{ + CTX_LOCK; + int rc; + + if (chldmode_ours(CTX)) { + rc = libxl__sigchld_installhandler(CTX); + if (rc) goto out; + } + + pid_t pid + CTX->childproc_hooks->fork_replacement + ? CTX->childproc_hooks->fork_replacement(CTX->childproc_user) + : fork(); + if (pid == -1) { + LOGE(ERROR, "fork failed"); + rc = ERROR_FAIL; + goto out; + } + + if (!pid) { + /* woohoo! */ + return 0; /* Yes, CTX is left locked in the child. */ + } + + ch->pid = pid; + ch->callback = death; + LIBXL_LIST_INSERT_HEAD(&CTX->children, ch, entry); + rc = pid; + + out: + perhaps_removehandler(CTX); + CTX_UNLOCK; + return rc; +} + +void libxl_childproc_setmode(libxl_ctx *ctx, const libxl_childproc_hooks *hooks, + void *user) +{ + GC_INIT(ctx); + CTX_LOCK; + + assert(LIBXL_LIST_EMPTY(&CTX->children)); + + if (!hooks) + hooks = &libxl__childproc_default_hooks; + + ctx->childproc_hooks = hooks; + ctx->childproc_user = user; + + switch (ctx->childproc_hooks->chldowner) { + case libxl_sigchld_owner_mainloop: + case libxl_sigchld_owner_libxl: + libxl__sigchld_removehandler(ctx); + break; + case libxl_sigchld_owner_libxl_always: + libxl__sigchld_installhandler(ctx); + break; + default: + abort(); + } + + CTX_UNLOCK; + GC_FREE; +} + +const libxl_childproc_hooks libxl__childproc_default_hooks = { + libxl_sigchld_owner_libxl, 0, 0 +}; + +/* * Local variables: * mode: C * c-basic-offset: 4 diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 01c9ba9..d04e856 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -198,6 +198,19 @@ _hidden libxl__ev_xswatch *libxl__watch_slot_contents(libxl__gc *gc, int slotnum); +typedef struct libxl__ev_child libxl__ev_child; +typedef void libxl__ev_child_callback(libxl__egc *egc, libxl__ev_child*, + pid_t pid, int status); +struct libxl__ev_child { + /* caller should include this in their own struct */ + /* read-only for caller: */ + pid_t pid; /* -1 means unused ("unregistered", ie Idle) */ + libxl__ev_child_callback *callback; + /* remainder is private for libxl__ev_... */ + LIBXL_LIST_ENTRY(struct libxl__ev_child) entry; +}; + + /* * evgen structures, which are the state we use for generating * events for the caller. @@ -306,10 +319,14 @@ struct libxl__ctx { LIBXL_LIST_HEAD(, libxl_evgen_disk_eject) disk_eject_evgens; - /* for callers who reap children willy-nilly; caller must only - * set this after libxl_init and before any other call - or - * may leave them untouched */ + const libxl_childproc_hooks *childproc_hooks; + void *childproc_user; + int sigchld_selfpipe[2]; /* [0]==-1 means handler not installed */ + LIBXL_LIST_HEAD(, libxl__ev_child) children; + + /* This is obsolete and must be removed: */ int (*waitpid_instead)(pid_t pid, int *status, int flags); + libxl_version_info version_info; }; @@ -557,6 +574,36 @@ static inline int libxl__ev_xswatch_isregistered(const libxl__ev_xswatch *xw) /* + * For making subprocesses. This is the only permitted mechanism for + * code in libxl to do so. + * + * In the parent, returns the pid, filling in childw_out. + * In the child, returns 0. + * If it fails, returns a libxl error (all of which are -ve). + * + * The child should go on to exec (or exit) soon. The child may not + * make any further calls to libxl infrastructure, except for memory + * allocation and logging. If the child needs to use xenstore it + * must open its own xs handle and use it directly, rather than via + * the libxl event machinery. + * + * The parent may signal the child but it must not reap it. That will + * be done by the event machinery. death may be NULL in which case + * the child is still reaped but its death is ignored. + * + * It is not possible to "deregister" the child death event source. + * It will generate exactly one event callback; until then the childw + * is Active and may not be reused. + */ +_hidden pid_t libxl__ev_child_fork(libxl__gc *gc, libxl__ev_child *childw_out, + libxl__ev_child_callback *death); +static inline void libxl__ev_child_init(libxl__ev_child *childw_out) + { childw_out->pid = -1; } +static inline int libxl__ev_child_inuse(libxl__ev_child *childw_out) + { return childw_out->pid >= 0; } + + +/* * Other event-handling support provided by the libxl event core to * the rest of libxl. */ @@ -610,6 +657,15 @@ _hidden void libxl__poller_put(libxl_ctx *ctx, libxl__poller *p); * ctx must be locked. */ _hidden void libxl__poller_wakeup(libxl__egc *egc, libxl__poller *p); +/* Internal to fork and child reaping machinery */ +extern const libxl_childproc_hooks libxl__childproc_default_hooks; +int libxl__sigchld_installhandler(libxl_ctx *ctx); /* non-reentrant;logs errs */ +void libxl__sigchld_removehandler(libxl_ctx *ctx); /* non-reentrant */ +int libxl__fork_selfpipe_active(libxl_ctx *ctx); /* returns read fd or -1 */ +void libxl__fork_selfpipe_woken(libxl__egc *egc); +int libxl__self_pipe_wakeup(int fd); /* returns 0 or -1 setting errno */ +int libxl__self_pipe_eatall(int fd); /* returns 0 or -1 setting errno */ + _hidden int libxl__atfork_init(libxl_ctx *ctx); -- 1.7.2.5
Ian Jackson
2012-May-11 17:57 UTC
[PATCH 04/27] autoconf: trim the configure script; use autoheader
Remove a lot of unnecessary tests. Specifically, we no longer test for standard POSIX facilities which we expect to be provided everywhere and which we don't in any case have any alternative for. Switch to generating config.h.in with autoheader. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Cc: Roger Pau Monne <roger.pau@entel.upc.edu> Changes since v7: * Removed AX_CHECK_PTYFUNCS (snuck in from previous patch) --- autogen.sh | 1 + tools/config.h.in | 73 +- tools/configure | 8825 +++++++++++++++++----------------------------------- tools/configure.ac | 60 +- 4 files changed, 2981 insertions(+), 5978 deletions(-) diff --git a/autogen.sh b/autogen.sh index c288b71..58a71ce 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,3 +1,4 @@ #!/bin/sh -e cd tools autoconf +autoheader diff --git a/tools/config.h.in b/tools/config.h.in index f8f96dc..17c8913 100644 --- a/tools/config.h.in +++ b/tools/config.h.in @@ -1,19 +1,64 @@ -/* - * Copyright (C) 2012 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; version 2.1 only. with the special - * exception on linking described in file LICENSE. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - */ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the <inttypes.h> header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the `crypto' library (-lcrypto). */ +#undef HAVE_LIBCRYPTO + +/* Define to 1 if you have the `yajl' library (-lyajl). */ +#undef HAVE_LIBYAJL + +/* Define to 1 if you have the `z' library (-lz). */ +#undef HAVE_LIBZ + +/* Define to 1 if you have the <memory.h> header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the <stdint.h> header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the <stdlib.h> header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the <strings.h> header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the <string.h> header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the <sys/types.h> header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the <unistd.h> header file. */ +#undef HAVE_UNISTD_H /* Define to 1 if you have the <yajl/yajl_version.h> header file. */ #undef HAVE_YAJL_YAJL_VERSION_H -/* Define curses header to include. */ +/* Define curses header to use */ #undef INCLUDE_CURSES_H + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS diff --git a/tools/configure b/tools/configure index 897e061..d8918fe 100755 --- a/tools/configure +++ b/tools/configure @@ -595,12 +595,8 @@ ac_includes_default="\ # include <unistd.h> #endif" -ac_header_list-ac_func_list ac_subst_vars='LTLIBOBJS -POW_LIB LIBOBJS -ALLOCA libiconv PTHREAD_LIBS PTHREAD_LDFLAGS @@ -616,6 +612,9 @@ PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG CURSES_LIBS +EGREP +GREP +CPP pyconfig PYTHONPATH OCAMLBUILD @@ -635,8 +634,13 @@ INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM SET_MAKE -LN_S -SED +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC IASL BCC LD86 @@ -665,24 +669,6 @@ xenapi vtpm monitors githttp -host_os -host_vendor -host_cpu -host -build_os -build_vendor -build_cpu -build -EGREP -GREP -CPP -OBJEXT -EXEEXT -ac_ct_CC -CPPFLAGS -LDFLAGS -CFLAGS -CC target_alias host_alias build_alias @@ -740,12 +726,6 @@ enable_debug ac_precious_vars='build_alias host_alias target_alias -CC -CFLAGS -LDFLAGS -LIBS -CPPFLAGS -CPP PREPEND_INCLUDES PREPEND_LIB APPEND_INCLUDES @@ -762,6 +742,12 @@ AS86 LD86 BCC IASL +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR @@ -1365,10 +1351,6 @@ Fine tuning of the installation directories: _ACEOF cat <<\_ACEOF - -System types: - --build=BUILD configure for building on BUILD [guessed] - --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi @@ -1399,14 +1381,6 @@ Optional Features: --disable-debug Disable debug build of tools (default is ENABLED) Some influential environment variables: - CC C compiler command - CFLAGS C compiler flags - LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a - nonstandard directory <lib dir> - LIBS libraries to pass to the linker, e.g. -l<library> - CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if - you have headers in a nonstandard directory <include dir> - CPP C preprocessor PREPEND_INCLUDES List of include folders to prepend to CFLAGS (without -I) PREPEND_LIB List of library folders to prepend to LDFLAGS (without -L) @@ -1425,6 +1399,14 @@ Some influential environment variables: LD86 Path to ld86 tool BCC Path to bcc tool IASL Path to iasl tool + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a + nonstandard directory <lib dir> + LIBS libraries to pass to the linker, e.g. -l<library> + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if + you have headers in a nonstandard directory <include dir> + CPP C preprocessor PKG_CONFIG path to pkg-config utility PKG_CONFIG_PATH directories to add to pkg-config's search path @@ -1797,311 +1779,6 @@ fi as_fn_set_status $ac_retval } # ac_fn_c_try_link - -# ac_fn_c_check_func LINENO FUNC VAR -# ---------------------------------- -# Tests whether FUNC exists, setting the cache variable VAR accordingly -ac_fn_c_check_func () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -/* Define $2 to an innocuous variant, in case <limits.h> declares $2. - For example, HP-UX 11i <limits.h> declares gettimeofday. */ -#define $2 innocuous_$2 - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $2 (); below. - Prefer <limits.h> to <assert.h> if __STDC__ is defined, since - <limits.h> exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include <limits.h> -#else -# include <assert.h> -#endif - -#undef $2 - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $2 (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$2 || defined __stub___$2 -choke me -#endif - -int -main () -{ -return $2 (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_c_check_func - -# ac_fn_c_check_type LINENO TYPE VAR INCLUDES -# ------------------------------------------- -# Tests whether TYPE exists after having included INCLUDES, setting cache -# variable VAR accordingly. -ac_fn_c_check_type () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=no" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -if (sizeof ($2)) - return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -if (sizeof (($2))) - return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - eval "$3=yes" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_c_check_type - -# ac_fn_c_find_intX_t LINENO BITS VAR -# ----------------------------------- -# Finds a signed integer type with width BITS, setting cache variable VAR -# accordingly. -ac_fn_c_find_intX_t () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for int$2_t" >&5 -$as_echo_n "checking for int$2_t... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=no" - # Order is important - never check a type that is potentially smaller - # than half of the expected target width. - for ac_type in int$2_t 'int' 'long int' \ - 'long long int' 'short int' 'signed char'; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default - enum { N = $2 / 2 - 1 }; -int -main () -{ -static int test_array [1 - 2 * !(0 < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1))]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default - enum { N = $2 / 2 - 1 }; -int -main () -{ -static int test_array [1 - 2 * !(($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1) - < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 2))]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - case $ac_type in #( - int$2_t) : - eval "$3=yes" ;; #( - *) : - eval "$3=\$ac_type" ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - if eval test \"x\$"$3"\" = x"no"; then : - -else - break -fi - done -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_c_find_intX_t - -# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES -# ---------------------------------------------------- -# Tries to find if the field MEMBER exists in type AGGR, after including -# INCLUDES, setting cache variable VAR accordingly. -ac_fn_c_check_member () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 -$as_echo_n "checking for $2.$3... " >&6; } -if eval "test \"\${$4+set}\"" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$5 -int -main () -{ -static $2 ac_aggr; -if (ac_aggr.$3) -return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$4=yes" -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$5 -int -main () -{ -static $2 ac_aggr; -if (sizeof ac_aggr.$3) -return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$4=yes" -else - eval "$4=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$4 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_c_check_member - -# ac_fn_c_find_uintX_t LINENO BITS VAR -# ------------------------------------ -# Finds an unsigned integer type with width BITS, setting cache variable VAR -# accordingly. -ac_fn_c_find_uintX_t () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5 -$as_echo_n "checking for uint$2_t... " >&6; } -if eval "test \"\${$3+set}\"" = set; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=no" - # Order is important - never check a type that is potentially smaller - # than half of the expected target width. - for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \ - 'unsigned long long int' 'unsigned short int' 'unsigned char'; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - case $ac_type in #( - uint$2_t) : - eval "$3=yes" ;; #( - *) : - eval "$3=\$ac_type" ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - if eval test \"x\$"$3"\" = x"no"; then : - -else - break -fi - done -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_c_find_uintX_t cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. @@ -2386,11 +2063,6 @@ $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi -as_fn_append ac_header_list " sys/time.h" -as_fn_append ac_header_list " unistd.h" -as_fn_append ac_func_list " alarm" -as_fn_append ac_header_list " stdlib.h" -as_fn_append ac_header_list " sys/param.h" # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false @@ -2508,1730 +2180,40 @@ APPEND_INCLUDES and APPEND_LIB instead when possible." >&2;} fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - fi -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl.exe - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl.exe -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CC" && break -done - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -fi - -fi - - -test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5 ; } - -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" -# Try to create an executable without -o first, disregard a.out. -# It will help us diagnose broken compilers, and finding out an intuition -# of exeext. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 -$as_echo_n "checking whether the C compiler works... " >&6; } -ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` - -# The possible output files: -ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" - -ac_rmfiles-for ac_file in $ac_files -do - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - * ) ac_rmfiles="$ac_rmfiles $ac_file";; - esac -done -rm -f $ac_rmfiles - -if { { ac_try="$ac_link_default" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link_default") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. -# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' -# in a Makefile. We should not override ac_cv_exeext if it was cached, -# so that the user can short-circuit this test for compilers unknown to -# Autoconf. -for ac_file in $ac_files '' -do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) - ;; - [ab].out ) - # We found the default executable, but exeext='' is most - # certainly right. - break;; - *.* ) - if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; - then :; else - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - fi - # We set ac_cv_exeext here because the later test for it is not - # safe: cross compilers may not add the suffix if given an `-o' - # argument, so we may need to know it at that point already. - # Even if this section looks crufty: it has the advantage of - # actually working. - break;; - * ) - break;; - esac -done -test "$ac_cv_exeext" = no && ac_cv_exeext- -else - ac_file='' -fi -if test -z "$ac_file"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "C compiler cannot create executables -See \`config.log' for more details" "$LINENO" 5 ; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 -$as_echo_n "checking for C compiler default output file name... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 -$as_echo "$ac_file" >&6; } -ac_exeext=$ac_cv_exeext - -rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 -$as_echo_n "checking for suffix of executables... " >&6; } -if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - # If both `conftest.exe' and `conftest' are `present' (well, observable) -# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will -# work properly (i.e., refer to `conftest.exe'), while it won't with -# `rm'. -for ac_file in conftest.exe conftest conftest.*; do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - break;; - * ) break;; - esac -done -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details" "$LINENO" 5 ; } -fi -rm -f conftest conftest$ac_cv_exeext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 -$as_echo "$ac_cv_exeext" >&6; } - -rm -f conftest.$ac_ext -EXEEXT=$ac_cv_exeext -ac_exeext=$EXEEXT -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <stdio.h> -int -main () -{ -FILE *f = fopen ("conftest.out", "w"); - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -ac_clean_files="$ac_clean_files conftest.out" -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } -if test "$cross_compiling" != yes; then - { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - if { ac_try='./conftest$ac_cv_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details" "$LINENO" 5 ; } - fi - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } - -rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 -$as_echo_n "checking for suffix of object files... " >&6; } -if test "${ac_cv_objext+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.o conftest.obj -if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - for ac_file in conftest.o conftest.obj conftest.*; do - test -f "$ac_file" || continue; - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; - *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` - break;; - esac -done -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of object files: cannot compile -See \`config.log' for more details" "$LINENO" 5 ; } -fi -rm -f conftest.$ac_cv_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 -$as_echo "$ac_cv_objext" >&6; } -OBJEXT=$ac_cv_objext -ac_objext=$OBJEXT -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 -$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if test "${ac_cv_c_compiler_gnu+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_compiler_gnu=yes -else - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 -$as_echo "$ac_cv_c_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GCC=yes -else - GCC-fi -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -$as_echo_n "checking whether $CC accepts -g... " >&6; } -if test "${ac_cv_prog_cc_g+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - ac_cv_prog_cc_g=no - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -else - CFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - ac_c_werror_flag=$ac_save_c_werror_flag - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_c_werror_flag=$ac_save_c_werror_flag -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 -$as_echo "$ac_cv_prog_cc_g" >&6; } -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS- fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 -$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <stdarg.h> -#include <stdio.h> -#include <sys/types.h> -#include <sys/stat.h> -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; - -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_c89=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC - -fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -$as_echo "none needed" >&6; } ;; - xno) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -$as_echo "unsupported" >&6; } ;; - *) - CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; -esac -if test "x$ac_cv_prog_cc_c89" != xno; then : - -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 -$as_echo_n "checking how to run the C preprocessor... " >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP-fi -if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since - # <limits.h> exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include <limits.h> -#else -# include <assert.h> -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <ac_nonexistent.h> -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - break -fi - - done - ac_cv_prog_CPP=$CPP - -fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 -$as_echo "$CPP" >&6; } -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since - # <limits.h> exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include <limits.h> -#else -# include <assert.h> -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <ac_nonexistent.h> -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5 ; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 -$as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if test "${ac_cv_path_GREP+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$GREP"; then - ac_path_GREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue -# Check for GNU ac_path_GREP and select it if it is found. - # Check for GNU $ac_path_GREP -case `"$ac_path_GREP" --version 2>&1` in -*GNU*) - ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'GREP' >> "conftest.nl" - "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_GREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_GREP="$ac_path_GREP" - ac_path_GREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_GREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_GREP"; then - as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_GREP=$GREP -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 -$as_echo "$ac_cv_path_GREP" >&6; } - GREP="$ac_cv_path_GREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 -$as_echo_n "checking for egrep... " >&6; } -if test "${ac_cv_path_EGREP+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 - then ac_cv_path_EGREP="$GREP -E" - else - if test -z "$EGREP"; then - ac_path_EGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue -# Check for GNU ac_path_EGREP and select it if it is found. - # Check for GNU $ac_path_EGREP -case `"$ac_path_EGREP" --version 2>&1` in -*GNU*) - ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'EGREP' >> "conftest.nl" - "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_EGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_EGREP="$ac_path_EGREP" - ac_path_EGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_EGREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_EGREP"; then - as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_EGREP=$EGREP -fi - - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 -$as_echo "$ac_cv_path_EGREP" >&6; } - EGREP="$ac_cv_path_EGREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 -$as_echo_n "checking for ANSI C header files... " >&6; } -if test "${ac_cv_header_stdc+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <stdlib.h> -#include <stdarg.h> -#include <string.h> -#include <float.h> - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_header_stdc=yes -else - ac_cv_header_stdc=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <string.h> - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <stdlib.h> - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then : - : -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <ctype.h> -#include <stdlib.h> -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - return 2; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - -else - ac_cv_header_stdc=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 -$as_echo "$ac_cv_header_stdc" >&6; } -if test $ac_cv_header_stdc = yes; then - -$as_echo "#define STDC_HEADERS 1" >>confdefs.h - -fi - -# On IRIX 5.3, sys/types and inttypes.h are conflicting. -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default -" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - - - ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default" -if test "x$ac_cv_header_minix_config_h" = x""yes; then : - MINIX=yes -else - MINIX-fi - - - if test "$MINIX" = yes; then - -$as_echo "#define _POSIX_SOURCE 1" >>confdefs.h - - -$as_echo "#define _POSIX_1_SOURCE 2" >>confdefs.h - - -$as_echo "#define _MINIX 1" >>confdefs.h - - fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5 -$as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; } -if test "${ac_cv_safe_to_define___extensions__+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -# define __EXTENSIONS__ 1 - $ac_includes_default -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_safe_to_define___extensions__=yes -else - ac_cv_safe_to_define___extensions__=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5 -$as_echo "$ac_cv_safe_to_define___extensions__" >&6; } - test $ac_cv_safe_to_define___extensions__ = yes && - $as_echo "#define __EXTENSIONS__ 1" >>confdefs.h - - $as_echo "#define _ALL_SOURCE 1" >>confdefs.h - - $as_echo "#define _GNU_SOURCE 1" >>confdefs.h - - $as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h - - $as_echo "#define _TANDEM_SOURCE 1" >>confdefs.h - - -# Make sure we can run config.sub. -$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || - as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 -$as_echo_n "checking build system type... " >&6; } -if test "${ac_cv_build+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_build_alias=$build_alias -test "x$ac_build_alias" = x && - ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` -test "x$ac_build_alias" = x && - as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 -ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 -$as_echo "$ac_cv_build" >&6; } -case $ac_cv_build in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5 ;; -esac -build=$ac_cv_build -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_build -shift -build_cpu=$1 -build_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -build_os=$* -IFS=$ac_save_IFS -case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 -$as_echo_n "checking host system type... " >&6; } -if test "${ac_cv_host+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "x$host_alias" = x; then - ac_cv_host=$ac_cv_build -else - ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 -$as_echo "$ac_cv_host" >&6; } -case $ac_cv_host in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5 ;; -esac -host=$ac_cv_host -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_host -shift -host_cpu=$1 -host_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -host_os=$* -IFS=$ac_save_IFS -case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac - - - -# M4 Macro includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- -# serial 1 (pkg-config-0.24) -# -# Copyright © 2004 Scott James Remnant <scott@netsplit.com>. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# PKG_PROG_PKG_CONFIG([MIN-VERSION]) -# ---------------------------------- -# PKG_PROG_PKG_CONFIG - -# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -# -# Check to see whether a particular set of modules exists. Similar -# to PKG_CHECK_MODULES(), but does not set variables or print errors. -# -# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) -# only at the first occurence in configure.ac, so if the first place -# it's called might be skipped (such as if it is within an "if", you -# have to call PKG_CHECK_EXISTS manually -# -------------------------------------------------------------- - - -# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) -# --------------------------------------------- -# _PKG_CONFIG - -# _PKG_SHORT_ERRORS_SUPPORTED -# ----------------------------- -# _PKG_SHORT_ERRORS_SUPPORTED - - -# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], -# [ACTION-IF-NOT-FOUND]) -# -# -# Note that if there is a possibility the first call to -# PKG_CHECK_MODULES might not happen, you should be sure to include an -# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac -# -# -# -------------------------------------------------------------- -# PKG_CHECK_MODULES - - - -# We define, separately, PTHREAD_CFLAGS, _LDFLAGS and _LIBS -# even though currently we don't set them very separately. -# This means that the makefiles will not need to change in -# the future if we make the test more sophisticated. - - - -# We invoke AX_PTHREAD_VARS with the name of another macro -# which is then expanded once for each variable. - - - - - - - - -# Enable/disable options - -# Check whether --enable-githttp was given. -if test "${enable_githttp+set}" = set; then : - enableval=$enable_githttp; -fi - - -if test "x$enable_githttp" = "xno"; then : - - ax_cv_githttp="n" - -elif test "x$enable_githttp" = "xyes"; then : - - ax_cv_githttp="y" - -elif test -z $ax_cv_githttp; then : - - ax_cv_githttp="n" - -fi -githttp=$ax_cv_githttp - - - -# Check whether --enable-monitors was given. -if test "${enable_monitors+set}" = set; then : - enableval=$enable_monitors; -fi - - -if test "x$enable_monitors" = "xno"; then : - - ax_cv_monitors="n" - -elif test "x$enable_monitors" = "xyes"; then : - - ax_cv_monitors="y" - -elif test -z $ax_cv_monitors; then : - - ax_cv_monitors="y" - -fi -monitors=$ax_cv_monitors - - - -# Check whether --enable-vtpm was given. -if test "${enable_vtpm+set}" = set; then : - enableval=$enable_vtpm; -fi - - -if test "x$enable_vtpm" = "xno"; then : - - ax_cv_vtpm="n" - -elif test "x$enable_vtpm" = "xyes"; then : - - ax_cv_vtpm="y" - -elif test -z $ax_cv_vtpm; then : - - ax_cv_vtpm="n" - -fi -vtpm=$ax_cv_vtpm - - - -# Check whether --enable-xenapi was given. -if test "${enable_xenapi+set}" = set; then : - enableval=$enable_xenapi; -fi - - -if test "x$enable_xenapi" = "xno"; then : - - ax_cv_xenapi="n" - -elif test "x$enable_xenapi" = "xyes"; then : - - ax_cv_xenapi="y" - -elif test -z $ax_cv_xenapi; then : - - ax_cv_xenapi="n" - -fi -xenapi=$ax_cv_xenapi - - - -# Check whether --enable-pythontools was given. -if test "${enable_pythontools+set}" = set; then : - enableval=$enable_pythontools; -fi - - -if test "x$enable_pythontools" = "xno"; then : - - ax_cv_pythontools="n" - -elif test "x$enable_pythontools" = "xyes"; then : - - ax_cv_pythontools="y" - -elif test -z $ax_cv_pythontools; then : - - ax_cv_pythontools="y" - -fi -pythontools=$ax_cv_pythontools - - - -# Check whether --enable-ocamltools was given. -if test "${enable_ocamltools+set}" = set; then : - enableval=$enable_ocamltools; -fi - - -if test "x$enable_ocamltools" = "xno"; then : - - ax_cv_ocamltools="n" - -elif test "x$enable_ocamltools" = "xyes"; then : - - ax_cv_ocamltools="y" - -elif test -z $ax_cv_ocamltools; then : - - ax_cv_ocamltools="y" - -fi -ocamltools=$ax_cv_ocamltools - - - -# Check whether --enable-miniterm was given. -if test "${enable_miniterm+set}" = set; then : - enableval=$enable_miniterm; -fi - - -if test "x$enable_miniterm" = "xno"; then : - - ax_cv_miniterm="n" - -elif test "x$enable_miniterm" = "xyes"; then : - - ax_cv_miniterm="y" - -elif test -z $ax_cv_miniterm; then : - - ax_cv_miniterm="n" - -fi -miniterm=$ax_cv_miniterm - - - -# Check whether --enable-lomount was given. -if test "${enable_lomount+set}" = set; then : - enableval=$enable_lomount; -fi - - -if test "x$enable_lomount" = "xno"; then : - - ax_cv_lomount="n" - -elif test "x$enable_lomount" = "xyes"; then : - - ax_cv_lomount="y" - -elif test -z $ax_cv_lomount; then : - - ax_cv_lomount="n" - -fi -lomount=$ax_cv_lomount - - - -# Check whether --enable-ovmf was given. -if test "${enable_ovmf+set}" = set; then : - enableval=$enable_ovmf; -fi - - -if test "x$enable_ovmf" = "xno"; then : - - ax_cv_ovmf="n" - -elif test "x$enable_ovmf" = "xyes"; then : - - ax_cv_ovmf="y" - -elif test -z $ax_cv_ovmf; then : - - ax_cv_ovmf="n" - -fi -ovmf=$ax_cv_ovmf +# M4 Macro includes -# Check whether --enable-rombios was given. -if test "${enable_rombios+set}" = set; then : - enableval=$enable_rombios; -fi -if test "x$enable_rombios" = "xno"; then : - ax_cv_rombios="n" -elif test "x$enable_rombios" = "xyes"; then : - ax_cv_rombios="y" -elif test -z $ax_cv_rombios; then : - ax_cv_rombios="y" -fi -rombios=$ax_cv_rombios -# Check whether --enable-seabios was given. -if test "${enable_seabios+set}" = set; then : - enableval=$enable_seabios; -fi -if test "x$enable_seabios" = "xno"; then : - ax_cv_seabios="n" -elif test "x$enable_seabios" = "xyes"; then : - ax_cv_seabios="y" -elif test -z $ax_cv_seabios; then : - ax_cv_seabios="y" -fi -seabios=$ax_cv_seabios -# Check whether --enable-debug was given. -if test "${enable_debug+set}" = set; then : - enableval=$enable_debug; -fi -if test "x$enable_debug" = "xno"; then : - ax_cv_debug="n" -elif test "x$enable_debug" = "xyes"; then : - ax_cv_debug="y" -elif test -z $ax_cv_debug; then : - ax_cv_debug="y" -fi -debug=$ax_cv_debug @@ -4240,930 +2222,432 @@ debug=$ax_cv_debug -for cflag in $PREPEND_INCLUDES -do - PREPEND_CFLAGS+=" -I$cflag" -done -for ldflag in $PREPEND_LIB -do - PREPEND_LDFLAGS+=" -L$ldflag" -done -for cflag in $APPEND_INCLUDES -do - APPEND_CFLAGS+=" -I$cflag" -done -for ldflag in $APPEND_LIB -do - APPEND_LDFLAGS+=" -L$ldflag" -done -CFLAGS="$PREPEND_CFLAGS $CFLAGS $APPEND_CFLAGS" -LDFLAGS="$PREPEND_LDFLAGS $LDFLAGS $APPEND_LDFLAGS" +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# serial 1 (pkg-config-0.24) +# +# Copyright © 2004 Scott James Remnant <scott@netsplit.com>. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. +# PKG_PROG_PKG_CONFIG([MIN-VERSION]) +# ---------------------------------- +# PKG_PROG_PKG_CONFIG +# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# +# Check to see whether a particular set of modules exists. Similar +# to PKG_CHECK_MODULES(), but does not set variables or print errors. +# +# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +# only at the first occurence in configure.ac, so if the first place +# it's called might be skipped (such as if it is within an "if", you +# have to call PKG_CHECK_EXISTS manually +# -------------------------------------------------------------- +# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) +# --------------------------------------------- +# _PKG_CONFIG +# _PKG_SHORT_ERRORS_SUPPORTED +# ----------------------------- +# _PKG_SHORT_ERRORS_SUPPORTED +# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +# [ACTION-IF-NOT-FOUND]) +# +# +# Note that if there is a possibility the first call to +# PKG_CHECK_MODULES might not happen, you should be sure to include an +# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac +# +# +# -------------------------------------------------------------- +# PKG_CHECK_MODULES -# Checks for programs. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 -$as_echo_n "checking for a sed that does not truncate output... " >&6; } -if test "${ac_cv_path_SED+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ - for ac_i in 1 2 3 4 5 6 7; do - ac_script="$ac_script$as_nl$ac_script" - done - echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed - { ac_script=; unset ac_script;} - if test -z "$SED"; then - ac_path_SED_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in sed gsed; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue -# Check for GNU ac_path_SED and select it if it is found. - # Check for GNU $ac_path_SED -case `"$ac_path_SED" --version 2>&1` in -*GNU*) - ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo '' >> "conftest.nl" - "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_SED_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_SED="$ac_path_SED" - ac_path_SED_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - $ac_path_SED_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_SED"; then - as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 - fi -else - ac_cv_path_SED=$SED -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 -$as_echo "$ac_cv_path_SED" >&6; } - SED="$ac_cv_path_SED" - rm -f conftest.sed +# We define, separately, PTHREAD_CFLAGS, _LDFLAGS and _LIBS +# even though currently we don't set them very separately. +# This means that the makefiles will not need to change in +# the future if we make the test more sophisticated. -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi +# We invoke AX_PTHREAD_VARS with the name of another macro +# which is then expanded once for each variable. -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - fi -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } +# Enable/disable options + +# Check whether --enable-githttp was given. +if test "${enable_githttp+set}" = set; then : + enableval=$enable_githttp; fi -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl.exe - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS +if test "x$enable_githttp" = "xno"; then : -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi + ax_cv_githttp="n" +elif test "x$enable_githttp" = "xyes"; then : - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl.exe -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS + ax_cv_githttp="y" + +elif test -z $ax_cv_githttp; then : + + ax_cv_githttp="n" fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi +githttp=$ax_cv_githttp - test -n "$ac_ct_CC" && break -done - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi +# Check whether --enable-monitors was given. +if test "${enable_monitors+set}" = set; then : + enableval=$enable_monitors; fi -fi +if test "x$enable_monitors" = "xno"; then : -test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5 ; } + ax_cv_monitors="n" -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done +elif test "x$enable_monitors" = "xyes"; then : -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 -$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if test "${ac_cv_c_compiler_gnu+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ + ax_cv_monitors="y" -int -main () -{ -#ifndef __GNUC__ - choke me -#endif +elif test -z $ax_cv_monitors; then : - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_compiler_gnu=yes -else - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu + ax_cv_monitors="y" fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 -$as_echo "$ac_cv_c_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GCC=yes -else - GCC-fi -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -$as_echo_n "checking whether $CC accepts -g... " >&6; } -if test "${ac_cv_prog_cc_g+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - ac_cv_prog_cc_g=no - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ +monitors=$ax_cv_monitors -int -main () -{ - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -else - CFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -int -main () -{ +# Check whether --enable-vtpm was given. +if test "${enable_vtpm+set}" = set; then : + enableval=$enable_vtpm; +fi - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : -else - ac_c_werror_flag=$ac_save_c_werror_flag - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ +if test "x$enable_vtpm" = "xno"; then : -int -main () -{ + ax_cv_vtpm="n" + +elif test "x$enable_vtpm" = "xyes"; then : + + ax_cv_vtpm="y" + +elif test -z $ax_cv_vtpm; then : + + ax_cv_vtpm="n" - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_c_werror_flag=$ac_save_c_werror_flag -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 -$as_echo "$ac_cv_prog_cc_g" >&6; } -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS- fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 -$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <stdarg.h> -#include <stdio.h> -#include <sys/types.h> -#include <sys/stat.h> -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} +vtpm=$ax_cv_vtpm -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_c89=$ac_arg +# Check whether --enable-xenapi was given. +if test "${enable_xenapi+set}" = set; then : + enableval=$enable_xenapi; fi -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC + + +if test "x$enable_xenapi" = "xno"; then : + + ax_cv_xenapi="n" + +elif test "x$enable_xenapi" = "xyes"; then : + + ax_cv_xenapi="y" + +elif test -z $ax_cv_xenapi; then : + + ax_cv_xenapi="n" fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -$as_echo "none needed" >&6; } ;; - xno) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -$as_echo "unsupported" >&6; } ;; - *) - CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; -esac -if test "x$ac_cv_prog_cc_c89" != xno; then : +xenapi=$ax_cv_xenapi + + +# Check whether --enable-pythontools was given. +if test "${enable_pythontools+set}" = set; then : + enableval=$enable_pythontools; fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 -$as_echo_n "checking whether ln -s works... " >&6; } -LN_S=$as_ln_s -if test "$LN_S" = "ln -s"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 -$as_echo "no, using $LN_S" >&6; } +if test "x$enable_pythontools" = "xno"; then : + + ax_cv_pythontools="n" + +elif test "x$enable_pythontools" = "xyes"; then : + + ax_cv_pythontools="y" + +elif test -z $ax_cv_pythontools; then : + + ax_cv_pythontools="y" + fi +pythontools=$ax_cv_pythontools -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } -set x ${MAKE-make} -ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\"" = set; then : - $as_echo_n "(cached) " >&6 -else - cat >conftest.make <<\_ACEOF -SHELL = /bin/sh -all: - @echo '@@@%%%=$(MAKE)=@@@%%%' -_ACEOF -# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. -case `${MAKE-make} -f conftest.make 2>/dev/null` in - *@@@%%%=?*=@@@%%%*) - eval ac_cv_prog_make_${ac_make}_set=yes;; - *) - eval ac_cv_prog_make_${ac_make}_set=no;; -esac -rm -f conftest.make + + +# Check whether --enable-ocamltools was given. +if test "${enable_ocamltools+set}" = set; then : + enableval=$enable_ocamltools; fi -if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - SET_MAKE-else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - SET_MAKE="MAKE=${MAKE-make}" + + +if test "x$enable_ocamltools" = "xno"; then : + + ax_cv_ocamltools="n" + +elif test "x$enable_ocamltools" = "xyes"; then : + + ax_cv_ocamltools="y" + +elif test -z $ax_cv_ocamltools; then : + + ax_cv_ocamltools="y" + fi +ocamltools=$ax_cv_ocamltools -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AmigaOS /C/install, which installs bootblocks on floppy discs -# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -# OS/2's system install, which has a completely different semantic -# ./install, which can be erroneously created by make from ./install.sh. -# Reject install programs that cannot install multiple files. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 -$as_echo_n "checking for a BSD-compatible install... " >&6; } -if test -z "$INSTALL"; then -if test "${ac_cv_path_install+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - # Account for people who put trailing slashes in PATH elements. -case $as_dir/ in #(( - ./ | .// | /[cC]/* | \ - /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ - ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ - /usr/ucb/* ) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then - if test $ac_prog = install && - grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - : - elif test $ac_prog = install && - grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # program-specific install script used by HP pwplus--don't use. - : - else - rm -rf conftest.one conftest.two conftest.dir - echo one > conftest.one - echo two > conftest.two - mkdir conftest.dir - if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && - test -s conftest.one && test -s conftest.two && - test -s conftest.dir/conftest.one && - test -s conftest.dir/conftest.two - then - ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" - break 3 - fi - fi - fi - done - done - ;; -esac - done -IFS=$as_save_IFS -rm -rf conftest.one conftest.two conftest.dir +# Check whether --enable-miniterm was given. +if test "${enable_miniterm+set}" = set; then : + enableval=$enable_miniterm; +fi + + +if test "x$enable_miniterm" = "xno"; then : + + ax_cv_miniterm="n" + +elif test "x$enable_miniterm" = "xyes"; then : + + ax_cv_miniterm="y" + +elif test -z $ax_cv_miniterm; then : + + ax_cv_miniterm="n" fi - if test "${ac_cv_path_install+set}" = set; then - INSTALL=$ac_cv_path_install - else - # As a last resort, use the slow shell script. Don't cache a - # value for INSTALL within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the value is a relative name. - INSTALL=$ac_install_sh - fi +miniterm=$ax_cv_miniterm + + + +# Check whether --enable-lomount was given. +if test "${enable_lomount+set}" = set; then : + enableval=$enable_lomount; fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 -$as_echo "$INSTALL" >&6; } -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' +if test "x$enable_lomount" = "xno"; then : -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + ax_cv_lomount="n" -# Extract the first word of "bison", so it can be a program name with args. -set dummy bison; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_BISON+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - case $BISON in - [\\/]* | ?:[\\/]*) - ac_cv_path_BISON="$BISON" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_BISON="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS +elif test "x$enable_lomount" = "xyes"; then : + + ax_cv_lomount="y" + +elif test -z $ax_cv_lomount; then : + + ax_cv_lomount="n" - ;; -esac fi -BISON=$ac_cv_path_BISON -if test -n "$BISON"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BISON" >&5 -$as_echo "$BISON" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } +lomount=$ax_cv_lomount + + + +# Check whether --enable-ovmf was given. +if test "${enable_ovmf+set}" = set; then : + enableval=$enable_ovmf; fi -# Extract the first word of "flex", so it can be a program name with args. -set dummy flex; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_FLEX+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - case $FLEX in - [\\/]* | ?:[\\/]*) - ac_cv_path_FLEX="$FLEX" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_FLEX="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS +if test "x$enable_ovmf" = "xno"; then : + + ax_cv_ovmf="n" + +elif test "x$enable_ovmf" = "xyes"; then : + + ax_cv_ovmf="y" + +elif test -z $ax_cv_ovmf; then : + + ax_cv_ovmf="n" - ;; -esac fi -FLEX=$ac_cv_path_FLEX -if test -n "$FLEX"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FLEX" >&5 -$as_echo "$FLEX" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } +ovmf=$ax_cv_ovmf + + + +# Check whether --enable-rombios was given. +if test "${enable_rombios+set}" = set; then : + enableval=$enable_rombios; fi -# Extract the first word of "perl", so it can be a program name with args. -set dummy perl; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_PERL+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - case $PERL in - [\\/]* | ?:[\\/]*) - ac_cv_path_PERL="$PERL" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_PERL="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS +if test "x$enable_rombios" = "xno"; then : + + ax_cv_rombios="n" + +elif test "x$enable_rombios" = "xyes"; then : + + ax_cv_rombios="y" + +elif test -z $ax_cv_rombios; then : + + ax_cv_rombios="y" - test -z "$ac_cv_path_PERL" && ac_cv_path_PERL="no" - ;; -esac fi -PERL=$ac_cv_path_PERL -if test -n "$PERL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 -$as_echo "$PERL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } +rombios=$ax_cv_rombios + + + +# Check whether --enable-seabios was given. +if test "${enable_seabios+set}" = set; then : + enableval=$enable_seabios; +fi + + +if test "x$enable_seabios" = "xno"; then : + + ax_cv_seabios="n" + +elif test "x$enable_seabios" = "xyes"; then : + + ax_cv_seabios="y" + +elif test -z $ax_cv_seabios; then : + + ax_cv_seabios="y" + +fi +seabios=$ax_cv_seabios + + + +# Check whether --enable-debug was given. +if test "${enable_debug+set}" = set; then : + enableval=$enable_debug; +fi + + +if test "x$enable_debug" = "xno"; then : + + ax_cv_debug="n" + +elif test "x$enable_debug" = "xyes"; then : + + ax_cv_debug="y" + +elif test -z $ax_cv_debug; then : + + ax_cv_debug="y" + fi +debug=$ax_cv_debug + + + + + + + + +for cflag in $PREPEND_INCLUDES +do + PREPEND_CFLAGS+=" -I$cflag" +done +for ldflag in $PREPEND_LIB +do + PREPEND_LDFLAGS+=" -L$ldflag" +done +for cflag in $APPEND_INCLUDES +do + APPEND_CFLAGS+=" -I$cflag" +done +for ldflag in $APPEND_LIB +do + APPEND_LDFLAGS+=" -L$ldflag" +done +CFLAGS="$PREPEND_CFLAGS $CFLAGS $APPEND_CFLAGS" +LDFLAGS="$PREPEND_LDFLAGS $LDFLAGS $APPEND_LDFLAGS" + + -if test x"${PERL}" == x"no" -then - as_fn_error $? "Unable to find perl, please install perl" "$LINENO" 5 -fi -if test "x$xapi" = "xy"; then : - # Extract the first word of "curl-config", so it can be a program name with args. -set dummy curl-config; ac_word=$2 + + + + + + + + + +# Checks for programs. +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_CURL+set}" = set; then : +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else - case $CURL in - [\\/]* | ?:[\\/]*) - ac_cv_path_CURL="$CURL" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_CURL="$as_dir/$ac_word$ac_exec_ext" + ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -5171,44 +2655,39 @@ done done IFS=$as_save_IFS - test -z "$ac_cv_path_CURL" && ac_cv_path_CURL="no" - ;; -esac fi -CURL=$ac_cv_path_CURL -if test -n "$CURL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CURL" >&5 -$as_echo "$CURL" >&6; } +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi -if test x"${CURL}" == x"no" -then - as_fn_error $? "Unable to find curl-config, please install curl-config" "$LINENO" 5 fi - # Extract the first word of "xml2-config", so it can be a program name with args. -set dummy xml2-config; ac_word=$2 +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_XML+set}" = set; then : +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else - case $XML in - [\\/]* | ?:[\\/]*) - ac_cv_path_XML="$XML" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_XML="$as_dir/$ac_word$ac_exec_ext" + ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -5216,39 +2695,43 @@ done done IFS=$as_save_IFS - test -z "$ac_cv_path_XML" && ac_cv_path_XML="no" - ;; -esac fi -XML=$ac_cv_path_XML -if test -n "$XML"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XML" >&5 -$as_echo "$XML" >&6; } +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - -if test x"${XML}" == x"no" -then - as_fn_error $? "Unable to find xml2-config, please install xml2-config" "$LINENO" 5 -fi - + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" fi -if test "x$ocamltools" = "xy"; then : - # checking for ocamlc - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ocamlc", so it can be a program name with args. -set dummy ${ac_tool_prefix}ocamlc; ac_word=$2 +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OCAMLC+set}" = set; then : +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test -n "$OCAMLC"; then - ac_cv_prog_OCAMLC="$OCAMLC" # Let the user override the test. + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH @@ -5257,7 +2740,7 @@ do test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_OCAMLC="${ac_tool_prefix}ocamlc" + ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -5267,29 +2750,30 @@ IFS=$as_save_IFS fi fi -OCAMLC=$ac_cv_prog_OCAMLC -if test -n "$OCAMLC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLC" >&5 -$as_echo "$OCAMLC" >&6; } +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi + fi fi -if test -z "$ac_cv_prog_OCAMLC"; then - ac_ct_OCAMLC=$OCAMLC - # Extract the first word of "ocamlc", so it can be a program name with args. -set dummy ocamlc; ac_word=$2 +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OCAMLC+set}" = set; then : +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test -n "$ac_ct_OCAMLC"; then - ac_cv_prog_ac_ct_OCAMLC="$ac_ct_OCAMLC" # Let the user override the test. + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. else + ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do @@ -5297,7 +2781,11 @@ do test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_OCAMLC="ocamlc" + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -5305,61 +2793,44 @@ done done IFS=$as_save_IFS +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi fi fi -ac_ct_OCAMLC=$ac_cv_prog_ac_ct_OCAMLC -if test -n "$ac_ct_OCAMLC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLC" >&5 -$as_echo "$ac_ct_OCAMLC" >&6; } +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - if test "x$ac_ct_OCAMLC" = x; then - OCAMLC="no" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OCAMLC=$ac_ct_OCAMLC - fi -else - OCAMLC="$ac_cv_prog_OCAMLC" -fi - - - if test "$OCAMLC" != "no"; then - OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p'` - { $as_echo "$as_me:${as_lineno-$LINENO}: result: OCaml version is $OCAMLVERSION" >&5 -$as_echo "OCaml version is $OCAMLVERSION" >&6; } - # If OCAMLLIB is set, use it - if test "$OCAMLLIB" = ""; then - OCAMLLIB=`$OCAMLC -where 2>/dev/null || $OCAMLC -v|tail -1|cut -d ' ' -f 4` - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: OCAMLLIB previously set; preserving it." >&5 -$as_echo "OCAMLLIB previously set; preserving it." >&6; } - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: OCaml library path is $OCAMLLIB" >&5 -$as_echo "OCaml library path is $OCAMLLIB" >&6; } - - - - # checking for ocamlopt - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ocamlopt", so it can be a program name with args. -set dummy ${ac_tool_prefix}ocamlopt; ac_word=$2 +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OCAMLOPT+set}" = set; then : +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test -n "$OCAMLOPT"; then - ac_cv_prog_OCAMLOPT="$OCAMLOPT" # Let the user override the test. + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH @@ -5368,7 +2839,7 @@ do test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_OCAMLOPT="${ac_tool_prefix}ocamlopt" + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -5378,28 +2849,32 @@ IFS=$as_save_IFS fi fi -OCAMLOPT=$ac_cv_prog_OCAMLOPT -if test -n "$OCAMLOPT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLOPT" >&5 -$as_echo "$OCAMLOPT" >&6; } +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi + test -n "$CC" && break + done fi -if test -z "$ac_cv_prog_OCAMLOPT"; then - ac_ct_OCAMLOPT=$OCAMLOPT - # Extract the first word of "ocamlopt", so it can be a program name with args. -set dummy ocamlopt; ac_word=$2 +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OCAMLOPT+set}" = set; then : +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test -n "$ac_ct_OCAMLOPT"; then - ac_cv_prog_ac_ct_OCAMLOPT="$ac_ct_OCAMLOPT" # Let the user override the test. + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH @@ -5408,7 +2883,7 @@ do test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_OCAMLOPT="ocamlopt" + ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -5416,19 +2891,23 @@ done done IFS=$as_save_IFS -fi -fi -ac_ct_OCAMLOPT=$ac_cv_prog_ac_ct_OCAMLOPT -if test -n "$ac_ct_OCAMLOPT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLOPT" >&5 -$as_echo "$ac_ct_OCAMLOPT" >&6; } +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - if test "x$ac_ct_OCAMLOPT" = x; then - OCAMLOPT="no" + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" else case $cross_compiling:$ac_tool_warned in yes:) @@ -5436,396 +2915,649 @@ yes:) $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac - OCAMLOPT=$ac_ct_OCAMLOPT + CC=$ac_ct_CC fi -else - OCAMLOPT="$ac_cv_prog_OCAMLOPT" fi - OCAMLBEST=byte - if test "$OCAMLOPT" = "no"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Cannot find ocamlopt; bytecode compilation only." >&5 -$as_echo "$as_me: WARNING: Cannot find ocamlopt; bytecode compilation only." >&2;} - else - TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` - if test "$TMPVERSION" != "$OCAMLVERSION" ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: versions differs from ocamlc; ocamlopt discarded." >&5 -$as_echo "versions differs from ocamlc; ocamlopt discarded." >&6; } - OCAMLOPT=no - else - OCAMLBEST=opt +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5 ; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles+for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { { ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi - fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext+ +else + ac_file='' +fi +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5 ; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +ac_exeext=$ac_cv_exeext + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5 ; } +fi +rm -f conftest conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdio.h> +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details" "$LINENO" 5 ; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } - # checking for ocamlc.opt - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ocamlc.opt", so it can be a program name with args. -set dummy ${ac_tool_prefix}ocamlc.opt; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OCAMLCDOTOPT+set}" = set; then : +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if test "${ac_cv_objext+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test -n "$OCAMLCDOTOPT"; then - ac_cv_prog_OCAMLCDOTOPT="$OCAMLCDOTOPT" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_OCAMLCDOTOPT="${ac_tool_prefix}ocamlc.opt" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ -fi -fi -OCAMLCDOTOPT=$ac_cv_prog_OCAMLCDOTOPT -if test -n "$OCAMLCDOTOPT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLCDOTOPT" >&5 -$as_echo "$OCAMLCDOTOPT" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi +int +main () +{ + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5 ; } fi -if test -z "$ac_cv_prog_OCAMLCDOTOPT"; then - ac_ct_OCAMLCDOTOPT=$OCAMLCDOTOPT - # Extract the first word of "ocamlc.opt", so it can be a program name with args. -set dummy ocamlc.opt; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OCAMLCDOTOPT+set}" = set; then : +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if test "${ac_cv_c_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test -n "$ac_ct_OCAMLCDOTOPT"; then - ac_cv_prog_ac_ct_OCAMLCDOTOPT="$ac_ct_OCAMLCDOTOPT" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_OCAMLCDOTOPT="ocamlc.opt" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ -fi -fi -ac_ct_OCAMLCDOTOPT=$ac_cv_prog_ac_ct_OCAMLCDOTOPT -if test -n "$ac_ct_OCAMLCDOTOPT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLCDOTOPT" >&5 -$as_echo "$ac_ct_OCAMLCDOTOPT" >&6; } +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + ac_compiler_gnu=no fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu - if test "x$ac_ct_OCAMLCDOTOPT" = x; then - OCAMLCDOTOPT="no" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OCAMLCDOTOPT=$ac_ct_OCAMLCDOTOPT - fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes else - OCAMLCDOTOPT="$ac_cv_prog_OCAMLCDOTOPT" + GCC fi - - if test "$OCAMLCDOTOPT" != "no"; then - TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` - if test "$TMPVERSION" != "$OCAMLVERSION" ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: versions differs from ocamlc; ocamlc.opt discarded." >&5 -$as_echo "versions differs from ocamlc; ocamlc.opt discarded." >&6; } - else - OCAMLC=$OCAMLCDOTOPT - fi - fi - - # checking for ocamlopt.opt - if test "$OCAMLOPT" != "no" ; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ocamlopt.opt", so it can be a program name with args. -set dummy ${ac_tool_prefix}ocamlopt.opt; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OCAMLOPTDOTOPT+set}" = set; then : +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if test "${ac_cv_prog_cc_g+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test -n "$OCAMLOPTDOTOPT"; then - ac_cv_prog_OCAMLOPTDOTOPT="$OCAMLOPTDOTOPT" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_OCAMLOPTDOTOPT="${ac_tool_prefix}ocamlopt.opt" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ -fi -fi -OCAMLOPTDOTOPT=$ac_cv_prog_OCAMLOPTDOTOPT -if test -n "$OCAMLOPTDOTOPT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLOPTDOTOPT" >&5 -$as_echo "$OCAMLOPTDOTOPT" >&6; } +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int +main () +{ -fi -if test -z "$ac_cv_prog_OCAMLOPTDOTOPT"; then - ac_ct_OCAMLOPTDOTOPT=$OCAMLOPTDOTOPT - # Extract the first word of "ocamlopt.opt", so it can be a program name with args. -set dummy ocamlopt.opt; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OCAMLOPTDOTOPT+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OCAMLOPTDOTOPT"; then - ac_cv_prog_ac_ct_OCAMLOPTDOTOPT="$ac_ct_OCAMLOPTDOTOPT" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_OCAMLOPTDOTOPT="ocamlopt.opt" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -ac_ct_OCAMLOPTDOTOPT=$ac_cv_prog_ac_ct_OCAMLOPTDOTOPT -if test -n "$ac_ct_OCAMLOPTDOTOPT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLOPTDOTOPT" >&5 -$as_echo "$ac_ct_OCAMLOPTDOTOPT" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - - if test "x$ac_ct_OCAMLOPTDOTOPT" = x; then - OCAMLOPTDOTOPT="no" +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OCAMLOPTDOTOPT=$ac_ct_OCAMLOPTDOTOPT + CFLAGS="-g" fi else - OCAMLOPTDOTOPT="$ac_cv_prog_OCAMLOPTDOTOPT" -fi - - if test "$OCAMLOPTDOTOPT" != "no"; then - TMPVERSION=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` - if test "$TMPVERSION" != "$OCAMLVERSION" ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: version differs from ocamlc; ocamlopt.opt discarded." >&5 -$as_echo "version differs from ocamlc; ocamlopt.opt discarded." >&6; } - else - OCAMLOPT=$OCAMLOPTDOTOPT - fi - fi - fi - - + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if test "${ac_cv_prog_cc_c89+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdarg.h> +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; - # checking for ocaml toplevel - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ocaml", so it can be a program name with args. -set dummy ${ac_tool_prefix}ocaml; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OCAML+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OCAML"; then - ac_cv_prog_OCAML="$OCAML" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_OCAML="${ac_tool_prefix}ocaml" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break done - done -IFS=$as_save_IFS +rm -f conftest.$ac_ext +CC=$ac_save_CC fi -fi -OCAML=$ac_cv_prog_OCAML -if test -n "$OCAML"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAML" >&5 -$as_echo "$OCAML" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu -fi -if test -z "$ac_cv_prog_OCAML"; then - ac_ct_OCAML=$OCAML - # Extract the first word of "ocaml", so it can be a program name with args. -set dummy ocaml; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OCAML+set}" = set; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +set x ${MAKE-make} +ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\"" = set; then : $as_echo_n "(cached) " >&6 else - if test -n "$ac_ct_OCAML"; then - ac_cv_prog_ac_ct_OCAML="$ac_ct_OCAML" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_OCAML="ocaml" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_OCAML=$ac_cv_prog_ac_ct_OCAML -if test -n "$ac_ct_OCAML"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAML" >&5 -$as_echo "$ac_ct_OCAML" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OCAML" = x; then - OCAML="no" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; esac - OCAML=$ac_ct_OCAML - fi +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + SET_MAKE else - OCAML="$ac_cv_prog_OCAML" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" fi - - # checking for ocamldep - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ocamldep", so it can be a program name with args. -set dummy ${ac_tool_prefix}ocamldep; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OCAMLDEP+set}" = set; then : +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +# Reject install programs that cannot install multiple files. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 +$as_echo_n "checking for a BSD-compatible install... " >&6; } +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test -n "$OCAMLDEP"; then - ac_cv_prog_OCAMLDEP="$OCAMLDEP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_OCAMLDEP="${ac_tool_prefix}ocamldep" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in #(( + ./ | .// | /[cC]/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + rm -rf conftest.one conftest.two conftest.dir + echo one > conftest.one + echo two > conftest.two + mkdir conftest.dir + if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && + test -s conftest.one && test -s conftest.two && + test -s conftest.dir/conftest.one && + test -s conftest.dir/conftest.two + then + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + fi + done + done + ;; +esac + done IFS=$as_save_IFS +rm -rf conftest.one conftest.two conftest.dir + fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi fi -OCAMLDEP=$ac_cv_prog_OCAMLDEP -if test -n "$OCAMLDEP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLDEP" >&5 -$as_echo "$OCAMLDEP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 +$as_echo "$INSTALL" >&6; } +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' -fi -if test -z "$ac_cv_prog_OCAMLDEP"; then - ac_ct_OCAMLDEP=$OCAMLDEP - # Extract the first word of "ocamldep", so it can be a program name with args. -set dummy ocamldep; ac_word=$2 +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +# Extract the first word of "bison", so it can be a program name with args. +set dummy bison; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OCAMLDEP+set}" = set; then : +if test "${ac_cv_path_BISON+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test -n "$ac_ct_OCAMLDEP"; then - ac_cv_prog_ac_ct_OCAMLDEP="$ac_ct_OCAMLDEP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + case $BISON in + [\\/]* | ?:[\\/]*) + ac_cv_path_BISON="$BISON" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_OCAMLDEP="ocamldep" + ac_cv_path_BISON="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -5833,53 +3565,39 @@ done done IFS=$as_save_IFS + ;; +esac fi -fi -ac_ct_OCAMLDEP=$ac_cv_prog_ac_ct_OCAMLDEP -if test -n "$ac_ct_OCAMLDEP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLDEP" >&5 -$as_echo "$ac_ct_OCAMLDEP" >&6; } +BISON=$ac_cv_path_BISON +if test -n "$BISON"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BISON" >&5 +$as_echo "$BISON" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - if test "x$ac_ct_OCAMLDEP" = x; then - OCAMLDEP="no" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OCAMLDEP=$ac_ct_OCAMLDEP - fi -else - OCAMLDEP="$ac_cv_prog_OCAMLDEP" -fi - - # checking for ocamlmktop - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ocamlmktop", so it can be a program name with args. -set dummy ${ac_tool_prefix}ocamlmktop; ac_word=$2 +# Extract the first word of "flex", so it can be a program name with args. +set dummy flex; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OCAMLMKTOP+set}" = set; then : +if test "${ac_cv_path_FLEX+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test -n "$OCAMLMKTOP"; then - ac_cv_prog_OCAMLMKTOP="$OCAMLMKTOP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + case $FLEX in + [\\/]* | ?:[\\/]*) + ac_cv_path_FLEX="$FLEX" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_OCAMLMKTOP="${ac_tool_prefix}ocamlmktop" + ac_cv_path_FLEX="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -5887,39 +3605,39 @@ done done IFS=$as_save_IFS + ;; +esac fi -fi -OCAMLMKTOP=$ac_cv_prog_OCAMLMKTOP -if test -n "$OCAMLMKTOP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLMKTOP" >&5 -$as_echo "$OCAMLMKTOP" >&6; } +FLEX=$ac_cv_path_FLEX +if test -n "$FLEX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FLEX" >&5 +$as_echo "$FLEX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi -fi -if test -z "$ac_cv_prog_OCAMLMKTOP"; then - ac_ct_OCAMLMKTOP=$OCAMLMKTOP - # Extract the first word of "ocamlmktop", so it can be a program name with args. -set dummy ocamlmktop; ac_word=$2 +# Extract the first word of "perl", so it can be a program name with args. +set dummy perl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OCAMLMKTOP+set}" = set; then : +if test "${ac_cv_path_PERL+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test -n "$ac_ct_OCAMLMKTOP"; then - ac_cv_prog_ac_ct_OCAMLMKTOP="$ac_ct_OCAMLMKTOP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + case $PERL in + [\\/]* | ?:[\\/]*) + ac_cv_path_PERL="$PERL" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_OCAMLMKTOP="ocamlmktop" + ac_cv_path_PERL="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -5927,53 +3645,46 @@ done done IFS=$as_save_IFS + test -z "$ac_cv_path_PERL" && ac_cv_path_PERL="no" + ;; +esac fi -fi -ac_ct_OCAMLMKTOP=$ac_cv_prog_ac_ct_OCAMLMKTOP -if test -n "$ac_ct_OCAMLMKTOP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLMKTOP" >&5 -$as_echo "$ac_ct_OCAMLMKTOP" >&6; } +PERL=$ac_cv_path_PERL +if test -n "$PERL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERL" >&5 +$as_echo "$PERL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - if test "x$ac_ct_OCAMLMKTOP" = x; then - OCAMLMKTOP="no" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OCAMLMKTOP=$ac_ct_OCAMLMKTOP - fi -else - OCAMLMKTOP="$ac_cv_prog_OCAMLMKTOP" -fi +if test x"${PERL}" == x"no" +then + as_fn_error $? "Unable to find perl, please install perl" "$LINENO" 5 +fi +if test "x$xapi" = "xy"; then : - # checking for ocamlmklib - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ocamlmklib", so it can be a program name with args. -set dummy ${ac_tool_prefix}ocamlmklib; ac_word=$2 + # Extract the first word of "curl-config", so it can be a program name with args. +set dummy curl-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OCAMLMKLIB+set}" = set; then : +if test "${ac_cv_path_CURL+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test -n "$OCAMLMKLIB"; then - ac_cv_prog_OCAMLMKLIB="$OCAMLMKLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + case $CURL in + [\\/]* | ?:[\\/]*) + ac_cv_path_CURL="$CURL" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_OCAMLMKLIB="${ac_tool_prefix}ocamlmklib" + ac_cv_path_CURL="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -5981,39 +3692,44 @@ done done IFS=$as_save_IFS + test -z "$ac_cv_path_CURL" && ac_cv_path_CURL="no" + ;; +esac fi -fi -OCAMLMKLIB=$ac_cv_prog_OCAMLMKLIB -if test -n "$OCAMLMKLIB"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLMKLIB" >&5 -$as_echo "$OCAMLMKLIB" >&6; } +CURL=$ac_cv_path_CURL +if test -n "$CURL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CURL" >&5 +$as_echo "$CURL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi +if test x"${CURL}" == x"no" +then + as_fn_error $? "Unable to find curl-config, please install curl-config" "$LINENO" 5 fi -if test -z "$ac_cv_prog_OCAMLMKLIB"; then - ac_ct_OCAMLMKLIB=$OCAMLMKLIB - # Extract the first word of "ocamlmklib", so it can be a program name with args. -set dummy ocamlmklib; ac_word=$2 + # Extract the first word of "xml2-config", so it can be a program name with args. +set dummy xml2-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OCAMLMKLIB+set}" = set; then : +if test "${ac_cv_path_XML+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test -n "$ac_ct_OCAMLMKLIB"; then - ac_cv_prog_ac_ct_OCAMLMKLIB="$ac_ct_OCAMLMKLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + case $XML in + [\\/]* | ?:[\\/]*) + ac_cv_path_XML="$XML" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_OCAMLMKLIB="ocamlmklib" + ac_cv_path_XML="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -6021,44 +3737,39 @@ done done IFS=$as_save_IFS + test -z "$ac_cv_path_XML" && ac_cv_path_XML="no" + ;; +esac fi -fi -ac_ct_OCAMLMKLIB=$ac_cv_prog_ac_ct_OCAMLMKLIB -if test -n "$ac_ct_OCAMLMKLIB"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLMKLIB" >&5 -$as_echo "$ac_ct_OCAMLMKLIB" >&6; } +XML=$ac_cv_path_XML +if test -n "$XML"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XML" >&5 +$as_echo "$XML" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - if test "x$ac_ct_OCAMLMKLIB" = x; then - OCAMLMKLIB="no" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OCAMLMKLIB=$ac_ct_OCAMLMKLIB - fi -else - OCAMLMKLIB="$ac_cv_prog_OCAMLMKLIB" + +if test x"${XML}" == x"no" +then + as_fn_error $? "Unable to find xml2-config, please install xml2-config" "$LINENO" 5 fi +fi +if test "x$ocamltools" = "xy"; then : - # checking for ocamldoc + # checking for ocamlc if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ocamldoc", so it can be a program name with args. -set dummy ${ac_tool_prefix}ocamldoc; ac_word=$2 + # Extract the first word of "${ac_tool_prefix}ocamlc", so it can be a program name with args. +set dummy ${ac_tool_prefix}ocamlc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OCAMLDOC+set}" = set; then : +if test "${ac_cv_prog_OCAMLC+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test -n "$OCAMLDOC"; then - ac_cv_prog_OCAMLDOC="$OCAMLDOC" # Let the user override the test. + if test -n "$OCAMLC"; then + ac_cv_prog_OCAMLC="$OCAMLC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH @@ -6067,7 +3778,7 @@ do test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_OCAMLDOC="${ac_tool_prefix}ocamldoc" + ac_cv_prog_OCAMLC="${ac_tool_prefix}ocamlc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -6077,10 +3788,10 @@ IFS=$as_save_IFS fi fi -OCAMLDOC=$ac_cv_prog_OCAMLDOC -if test -n "$OCAMLDOC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLDOC" >&5 -$as_echo "$OCAMLDOC" >&6; } +OCAMLC=$ac_cv_prog_OCAMLC +if test -n "$OCAMLC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLC" >&5 +$as_echo "$OCAMLC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } @@ -6088,17 +3799,17 @@ fi fi -if test -z "$ac_cv_prog_OCAMLDOC"; then - ac_ct_OCAMLDOC=$OCAMLDOC - # Extract the first word of "ocamldoc", so it can be a program name with args. -set dummy ocamldoc; ac_word=$2 +if test -z "$ac_cv_prog_OCAMLC"; then + ac_ct_OCAMLC=$OCAMLC + # Extract the first word of "ocamlc", so it can be a program name with args. +set dummy ocamlc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OCAMLDOC+set}" = set; then : +if test "${ac_cv_prog_ac_ct_OCAMLC+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test -n "$ac_ct_OCAMLDOC"; then - ac_cv_prog_ac_ct_OCAMLDOC="$ac_ct_OCAMLDOC" # Let the user override the test. + if test -n "$ac_ct_OCAMLC"; then + ac_cv_prog_ac_ct_OCAMLC="$ac_ct_OCAMLC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH @@ -6107,7 +3818,7 @@ do test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_OCAMLDOC="ocamldoc" + ac_cv_prog_ac_ct_OCAMLC="ocamlc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -6117,17 +3828,17 @@ IFS=$as_save_IFS fi fi -ac_ct_OCAMLDOC=$ac_cv_prog_ac_ct_OCAMLDOC -if test -n "$ac_ct_OCAMLDOC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLDOC" >&5 -$as_echo "$ac_ct_OCAMLDOC" >&6; } +ac_ct_OCAMLC=$ac_cv_prog_ac_ct_OCAMLC +if test -n "$ac_ct_OCAMLC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLC" >&5 +$as_echo "$ac_ct_OCAMLC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - if test "x$ac_ct_OCAMLDOC" = x; then - OCAMLDOC="no" + if test "x$ac_ct_OCAMLC" = x; then + OCAMLC="no" else case $cross_compiling:$ac_tool_warned in yes:) @@ -6135,24 +3846,41 @@ yes:) $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac - OCAMLDOC=$ac_ct_OCAMLDOC + OCAMLC=$ac_ct_OCAMLC fi else - OCAMLDOC="$ac_cv_prog_OCAMLDOC" + OCAMLC="$ac_cv_prog_OCAMLC" fi - # checking for ocamlbuild - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ocamlbuild", so it can be a program name with args. -set dummy ${ac_tool_prefix}ocamlbuild; ac_word=$2 + if test "$OCAMLC" != "no"; then + OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p'` + { $as_echo "$as_me:${as_lineno-$LINENO}: result: OCaml version is $OCAMLVERSION" >&5 +$as_echo "OCaml version is $OCAMLVERSION" >&6; } + # If OCAMLLIB is set, use it + if test "$OCAMLLIB" = ""; then + OCAMLLIB=`$OCAMLC -where 2>/dev/null || $OCAMLC -v|tail -1|cut -d ' ' -f 4` + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: OCAMLLIB previously set; preserving it." >&5 +$as_echo "OCAMLLIB previously set; preserving it." >&6; } + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: OCaml library path is $OCAMLLIB" >&5 +$as_echo "OCaml library path is $OCAMLLIB" >&6; } + + + + + # checking for ocamlopt + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ocamlopt", so it can be a program name with args. +set dummy ${ac_tool_prefix}ocamlopt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OCAMLBUILD+set}" = set; then : +if test "${ac_cv_prog_OCAMLOPT+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test -n "$OCAMLBUILD"; then - ac_cv_prog_OCAMLBUILD="$OCAMLBUILD" # Let the user override the test. + if test -n "$OCAMLOPT"; then + ac_cv_prog_OCAMLOPT="$OCAMLOPT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH @@ -6161,7 +3889,7 @@ do test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_OCAMLBUILD="${ac_tool_prefix}ocamlbuild" + ac_cv_prog_OCAMLOPT="${ac_tool_prefix}ocamlopt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -6171,10 +3899,10 @@ IFS=$as_save_IFS fi fi -OCAMLBUILD=$ac_cv_prog_OCAMLBUILD -if test -n "$OCAMLBUILD"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLBUILD" >&5 -$as_echo "$OCAMLBUILD" >&6; } +OCAMLOPT=$ac_cv_prog_OCAMLOPT +if test -n "$OCAMLOPT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLOPT" >&5 +$as_echo "$OCAMLOPT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } @@ -6182,17 +3910,17 @@ fi fi -if test -z "$ac_cv_prog_OCAMLBUILD"; then - ac_ct_OCAMLBUILD=$OCAMLBUILD - # Extract the first word of "ocamlbuild", so it can be a program name with args. -set dummy ocamlbuild; ac_word=$2 +if test -z "$ac_cv_prog_OCAMLOPT"; then + ac_ct_OCAMLOPT=$OCAMLOPT + # Extract the first word of "ocamlopt", so it can be a program name with args. +set dummy ocamlopt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OCAMLBUILD+set}" = set; then : +if test "${ac_cv_prog_ac_ct_OCAMLOPT+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test -n "$ac_ct_OCAMLBUILD"; then - ac_cv_prog_ac_ct_OCAMLBUILD="$ac_ct_OCAMLBUILD" # Let the user override the test. + if test -n "$ac_ct_OCAMLOPT"; then + ac_cv_prog_ac_ct_OCAMLOPT="$ac_ct_OCAMLOPT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH @@ -6201,7 +3929,7 @@ do test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_OCAMLBUILD="ocamlbuild" + ac_cv_prog_ac_ct_OCAMLOPT="ocamlopt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -6211,17 +3939,17 @@ IFS=$as_save_IFS fi fi -ac_ct_OCAMLBUILD=$ac_cv_prog_ac_ct_OCAMLBUILD -if test -n "$ac_ct_OCAMLBUILD"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLBUILD" >&5 -$as_echo "$ac_ct_OCAMLBUILD" >&6; } +ac_ct_OCAMLOPT=$ac_cv_prog_ac_ct_OCAMLOPT +if test -n "$ac_ct_OCAMLOPT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLOPT" >&5 +$as_echo "$ac_ct_OCAMLOPT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - if test "x$ac_ct_OCAMLBUILD" = x; then - OCAMLBUILD="no" + if test "x$ac_ct_OCAMLOPT" = x; then + OCAMLOPT="no" else case $cross_compiling:$ac_tool_warned in yes:) @@ -6229,44 +3957,89 @@ yes:) $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac - OCAMLBUILD=$ac_ct_OCAMLBUILD + OCAMLOPT=$ac_ct_OCAMLOPT fi else - OCAMLBUILD="$ac_cv_prog_OCAMLBUILD" + OCAMLOPT="$ac_cv_prog_OCAMLOPT" fi + OCAMLBEST=byte + if test "$OCAMLOPT" = "no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Cannot find ocamlopt; bytecode compilation only." >&5 +$as_echo "$as_me: WARNING: Cannot find ocamlopt; bytecode compilation only." >&2;} + else + TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` + if test "$TMPVERSION" != "$OCAMLVERSION" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: versions differs from ocamlc; ocamlopt discarded." >&5 +$as_echo "versions differs from ocamlc; ocamlopt discarded." >&6; } + OCAMLOPT=no + else + OCAMLBEST=opt + fi + fi - if test "x$OCAMLC" = "xno"; then : - if test "x$enable_ocamltools" = "xyes"; then : - as_fn_error $? "Ocaml tools enabled, but unable to find Ocaml" "$LINENO" 5 -fi - ocamltools="n" + # checking for ocamlc.opt + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ocamlc.opt", so it can be a program name with args. +set dummy ${ac_tool_prefix}ocamlc.opt; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_OCAMLCDOTOPT+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$OCAMLCDOTOPT"; then + ac_cv_prog_OCAMLCDOTOPT="$OCAMLCDOTOPT" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_OCAMLCDOTOPT="${ac_tool_prefix}ocamlc.opt" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS fi +fi +OCAMLCDOTOPT=$ac_cv_prog_OCAMLCDOTOPT +if test -n "$OCAMLCDOTOPT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLCDOTOPT" >&5 +$as_echo "$OCAMLCDOTOPT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + fi -# Extract the first word of "bash", so it can be a program name with args. -set dummy bash; ac_word=$2 +if test -z "$ac_cv_prog_OCAMLCDOTOPT"; then + ac_ct_OCAMLCDOTOPT=$OCAMLCDOTOPT + # Extract the first word of "ocamlc.opt", so it can be a program name with args. +set dummy ocamlc.opt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_BASH+set}" = set; then : +if test "${ac_cv_prog_ac_ct_OCAMLCDOTOPT+set}" = set; then : $as_echo_n "(cached) " >&6 else - case $BASH in - [\\/]* | ?:[\\/]*) - ac_cv_path_BASH="$BASH" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + if test -n "$ac_ct_OCAMLCDOTOPT"; then + ac_cv_prog_ac_ct_OCAMLCDOTOPT="$ac_ct_OCAMLCDOTOPT" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_BASH="$as_dir/$ac_word$ac_exec_ext" + ac_cv_prog_ac_ct_OCAMLCDOTOPT="ocamlc.opt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -6274,56 +4047,63 @@ done done IFS=$as_save_IFS - test -z "$ac_cv_path_BASH" && ac_cv_path_BASH="no" - ;; -esac fi -BASH=$ac_cv_path_BASH -if test -n "$BASH"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BASH" >&5 -$as_echo "$BASH" >&6; } +fi +ac_ct_OCAMLCDOTOPT=$ac_cv_prog_ac_ct_OCAMLCDOTOPT +if test -n "$ac_ct_OCAMLCDOTOPT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLCDOTOPT" >&5 +$as_echo "$ac_ct_OCAMLCDOTOPT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - -if test x"${BASH}" == x"no" -then - as_fn_error $? "Unable to find bash, please install bash" "$LINENO" 5 + if test "x$ac_ct_OCAMLCDOTOPT" = x; then + OCAMLCDOTOPT="no" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OCAMLCDOTOPT=$ac_ct_OCAMLCDOTOPT + fi +else + OCAMLCDOTOPT="$ac_cv_prog_OCAMLCDOTOPT" fi -if test "x$pythontools" = "xy"; then : - - if echo "$PYTHON" | grep -q "^/"; then : - PYTHONPATH=$PYTHON - PYTHON=`basename $PYTHONPATH` + if test "$OCAMLCDOTOPT" != "no"; then + TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` + if test "$TMPVERSION" != "$OCAMLVERSION" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: versions differs from ocamlc; ocamlc.opt discarded." >&5 +$as_echo "versions differs from ocamlc; ocamlc.opt discarded." >&6; } + else + OCAMLC=$OCAMLCDOTOPT + fi + fi -elif test -z "$PYTHON"; then : - PYTHON="python" -else - as_fn_error $? "PYTHON specified, but is not an absolute path" "$LINENO" 5 -fi - # Extract the first word of "$PYTHON", so it can be a program name with args. -set dummy $PYTHON; ac_word=$2 + # checking for ocamlopt.opt + if test "$OCAMLOPT" != "no" ; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ocamlopt.opt", so it can be a program name with args. +set dummy ${ac_tool_prefix}ocamlopt.opt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_PYTHONPATH+set}" = set; then : +if test "${ac_cv_prog_OCAMLOPTDOTOPT+set}" = set; then : $as_echo_n "(cached) " >&6 else - case $PYTHONPATH in - [\\/]* | ?:[\\/]*) - ac_cv_path_PYTHONPATH="$PYTHONPATH" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + if test -n "$OCAMLOPTDOTOPT"; then + ac_cv_prog_OCAMLOPTDOTOPT="$OCAMLOPTDOTOPT" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_PYTHONPATH="$as_dir/$ac_word$ac_exec_ext" + ac_cv_prog_OCAMLOPTDOTOPT="${ac_tool_prefix}ocamlopt.opt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -6331,62 +4111,39 @@ done done IFS=$as_save_IFS - test -z "$ac_cv_path_PYTHONPATH" && ac_cv_path_PYTHONPATH="no" - ;; -esac fi -PYTHONPATH=$ac_cv_path_PYTHONPATH -if test -n "$PYTHONPATH"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHONPATH" >&5 -$as_echo "$PYTHONPATH" >&6; } +fi +OCAMLOPTDOTOPT=$ac_cv_prog_OCAMLOPTDOTOPT +if test -n "$OCAMLOPTDOTOPT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLOPTDOTOPT" >&5 +$as_echo "$OCAMLOPTDOTOPT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi -if test x"${PYTHONPATH}" == x"no" -then - as_fn_error $? "Unable to find $PYTHON, please install $PYTHON" "$LINENO" 5 -fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for python version >= 2.3 " >&5 -$as_echo_n "checking for python version >= 2.3 ... " >&6; } -`$PYTHON -c 'import sys; sys.exit(eval("sys.version_info < (2, 3)"))'` -if test "$?" != "0" -then - python_version=`$PYTHON -V 2>&1` - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - as_fn_error $? "$python_version is too old, minimum required version is 2.3" "$LINENO" 5 -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } fi - -ac_previous_cppflags=$CPPFLAGS -ac_previous_ldflags=$LDFLAGS -ac_python_version=`$PYTHON -c 'import distutils.sysconfig; \ - print distutils.sysconfig.get_config_var("VERSION")'` -# Extract the first word of "$PYTHON-config", so it can be a program name with args. -set dummy $PYTHON-config; ac_word=$2 +if test -z "$ac_cv_prog_OCAMLOPTDOTOPT"; then + ac_ct_OCAMLOPTDOTOPT=$OCAMLOPTDOTOPT + # Extract the first word of "ocamlopt.opt", so it can be a program name with args. +set dummy ocamlopt.opt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_pyconfig+set}" = set; then : +if test "${ac_cv_prog_ac_ct_OCAMLOPTDOTOPT+set}" = set; then : $as_echo_n "(cached) " >&6 else - case $pyconfig in - [\\/]* | ?:[\\/]*) - ac_cv_path_pyconfig="$pyconfig" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + if test -n "$ac_ct_OCAMLOPTDOTOPT"; then + ac_cv_prog_ac_ct_OCAMLOPTDOTOPT="$ac_ct_OCAMLOPTDOTOPT" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_pyconfig="$as_dir/$ac_word$ac_exec_ext" + ac_cv_prog_ac_ct_OCAMLOPTDOTOPT="ocamlopt.opt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -6394,127 +4151,68 @@ done done IFS=$as_save_IFS - test -z "$ac_cv_path_pyconfig" && ac_cv_path_pyconfig="no" - ;; -esac fi -pyconfig=$ac_cv_path_pyconfig -if test -n "$pyconfig"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $pyconfig" >&5 -$as_echo "$pyconfig" >&6; } +fi +ac_ct_OCAMLOPTDOTOPT=$ac_cv_prog_ac_ct_OCAMLOPTDOTOPT +if test -n "$ac_ct_OCAMLOPTDOTOPT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLOPTDOTOPT" >&5 +$as_echo "$ac_ct_OCAMLOPTDOTOPT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - -if test x"$pyconfig" == x"no"; then : - - CPPFLAGS="$CFLAGS `$PYTHON -c 'import distutils.sysconfig; \ - print "-I" + distutils.sysconfig.get_config_var("INCLUDEPY")'`" - CPPFLAGS="$CPPFLAGS `$PYTHON -c 'import distutils.sysconfig; \ - print distutils.sysconfig.get_config_var("CFLAGS")'`" - LDFLAGS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \ - print distutils.sysconfig.get_config_var("LIBS")'`" - LDFLAGS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \ - print distutils.sysconfig.get_config_var("SYSLIBS")'`" - LDFLAGS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \ - print "-L" + distutils.sysconfig.get_python_lib(plat_specific=1,\ - standard_lib=1) + "/config"'`" - LDFLAGS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \ - print distutils.sysconfig.get_config_var("LINKFORSHARED")'`" - LDFLAGS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \ - print distutils.sysconfig.get_config_var("LDFLAGS")'`" - -else - - CPPFLAGS="$CFLAGS `$PYTHON-config --cflags`" - LDFLAGS="$LDFLAGS `$PYTHON-config --ldflags`" - -fi - -ac_fn_c_check_header_mongrel "$LINENO" "Python.h" "ac_cv_header_Python_h" "$ac_includes_default" -if test "x$ac_cv_header_Python_h" = x""yes; then : - + if test "x$ac_ct_OCAMLOPTDOTOPT" = x; then + OCAMLOPTDOTOPT="no" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OCAMLOPTDOTOPT=$ac_ct_OCAMLOPTDOTOPT + fi else - as_fn_error $? "Unable to find Python development headers" "$LINENO" 5 + OCAMLOPTDOTOPT="$ac_cv_prog_OCAMLOPTDOTOPT" fi + if test "$OCAMLOPTDOTOPT" != "no"; then + TMPVERSION=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` + if test "$TMPVERSION" != "$OCAMLVERSION" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: version differs from ocamlc; ocamlopt.opt discarded." >&5 +$as_echo "version differs from ocamlc; ocamlopt.opt discarded." >&6; } + else + OCAMLOPT=$OCAMLOPTDOTOPT + fi + fi + fi -as_ac_Lib=`$as_echo "ac_cv_lib_python$ac_python_version''_PyArg_ParseTuple" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PyArg_ParseTuple in -lpython$ac_python_version" >&5 -$as_echo_n "checking for PyArg_ParseTuple in -lpython$ac_python_version... " >&6; } -if eval "test \"\${$as_ac_Lib+set}\"" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lpython$ac_python_version $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char PyArg_ParseTuple (); -int -main () -{ -return PyArg_ParseTuple (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - eval "$as_ac_Lib=yes" -else - eval "$as_ac_Lib=no" -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -eval ac_res=\$$as_ac_Lib - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_LIBpython$ac_python_version" | $as_tr_cpp` 1 -_ACEOF - - LIBS="-lpython$ac_python_version $LIBS" -else - as_fn_error $? "Unable to find a suitable python development library" "$LINENO" 5 -fi + fi -CPPFLAGS=$ac_previous_cppflags -LDLFAGS=$ac_previous_ldflags -fi -# Extract the first word of "xgettext", so it can be a program name with args. -set dummy xgettext; ac_word=$2 + # checking for ocaml toplevel + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ocaml", so it can be a program name with args. +set dummy ${ac_tool_prefix}ocaml; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_XGETTEXT+set}" = set; then : +if test "${ac_cv_prog_OCAML+set}" = set; then : $as_echo_n "(cached) " >&6 else - case $XGETTEXT in - [\\/]* | ?:[\\/]*) - ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + if test -n "$OCAML"; then + ac_cv_prog_OCAML="$OCAML" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_XGETTEXT="$as_dir/$ac_word$ac_exec_ext" + ac_cv_prog_OCAML="${ac_tool_prefix}ocaml" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -6522,44 +4220,39 @@ done done IFS=$as_save_IFS - test -z "$ac_cv_path_XGETTEXT" && ac_cv_path_XGETTEXT="no" - ;; -esac fi -XGETTEXT=$ac_cv_path_XGETTEXT -if test -n "$XGETTEXT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XGETTEXT" >&5 -$as_echo "$XGETTEXT" >&6; } +fi +OCAML=$ac_cv_prog_OCAML +if test -n "$OCAML"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAML" >&5 +$as_echo "$OCAML" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi -if test x"${XGETTEXT}" == x"no" -then - as_fn_error $? "Unable to find xgettext, please install xgettext" "$LINENO" 5 fi -# Extract the first word of "as86", so it can be a program name with args. -set dummy as86; ac_word=$2 +if test -z "$ac_cv_prog_OCAML"; then + ac_ct_OCAML=$OCAML + # Extract the first word of "ocaml", so it can be a program name with args. +set dummy ocaml; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_AS86+set}" = set; then : +if test "${ac_cv_prog_ac_ct_OCAML+set}" = set; then : $as_echo_n "(cached) " >&6 else - case $AS86 in - [\\/]* | ?:[\\/]*) - ac_cv_path_AS86="$AS86" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + if test -n "$ac_ct_OCAML"; then + ac_cv_prog_ac_ct_OCAML="$ac_ct_OCAML" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_AS86="$as_dir/$ac_word$ac_exec_ext" + ac_cv_prog_ac_ct_OCAML="ocaml" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -6567,44 +4260,53 @@ done done IFS=$as_save_IFS - test -z "$ac_cv_path_AS86" && ac_cv_path_AS86="no" - ;; -esac fi -AS86=$ac_cv_path_AS86 -if test -n "$AS86"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AS86" >&5 -$as_echo "$AS86" >&6; } +fi +ac_ct_OCAML=$ac_cv_prog_ac_ct_OCAML +if test -n "$ac_ct_OCAML"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAML" >&5 +$as_echo "$ac_ct_OCAML" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - -if test x"${AS86}" == x"no" -then - as_fn_error $? "Unable to find as86, please install as86" "$LINENO" 5 + if test "x$ac_ct_OCAML" = x; then + OCAML="no" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OCAML=$ac_ct_OCAML + fi +else + OCAML="$ac_cv_prog_OCAML" fi -# Extract the first word of "ld86", so it can be a program name with args. -set dummy ld86; ac_word=$2 + + + # checking for ocamldep + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ocamldep", so it can be a program name with args. +set dummy ${ac_tool_prefix}ocamldep; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_LD86+set}" = set; then : +if test "${ac_cv_prog_OCAMLDEP+set}" = set; then : $as_echo_n "(cached) " >&6 else - case $LD86 in - [\\/]* | ?:[\\/]*) - ac_cv_path_LD86="$LD86" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + if test -n "$OCAMLDEP"; then + ac_cv_prog_OCAMLDEP="$OCAMLDEP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_LD86="$as_dir/$ac_word$ac_exec_ext" + ac_cv_prog_OCAMLDEP="${ac_tool_prefix}ocamldep" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -6612,44 +4314,39 @@ done done IFS=$as_save_IFS - test -z "$ac_cv_path_LD86" && ac_cv_path_LD86="no" - ;; -esac fi -LD86=$ac_cv_path_LD86 -if test -n "$LD86"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD86" >&5 -$as_echo "$LD86" >&6; } +fi +OCAMLDEP=$ac_cv_prog_OCAMLDEP +if test -n "$OCAMLDEP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLDEP" >&5 +$as_echo "$OCAMLDEP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi -if test x"${LD86}" == x"no" -then - as_fn_error $? "Unable to find ld86, please install ld86" "$LINENO" 5 fi -# Extract the first word of "bcc", so it can be a program name with args. -set dummy bcc; ac_word=$2 +if test -z "$ac_cv_prog_OCAMLDEP"; then + ac_ct_OCAMLDEP=$OCAMLDEP + # Extract the first word of "ocamldep", so it can be a program name with args. +set dummy ocamldep; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_BCC+set}" = set; then : +if test "${ac_cv_prog_ac_ct_OCAMLDEP+set}" = set; then : $as_echo_n "(cached) " >&6 else - case $BCC in - [\\/]* | ?:[\\/]*) - ac_cv_path_BCC="$BCC" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + if test -n "$ac_ct_OCAMLDEP"; then + ac_cv_prog_ac_ct_OCAMLDEP="$ac_ct_OCAMLDEP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_BCC="$as_dir/$ac_word$ac_exec_ext" + ac_cv_prog_ac_ct_OCAMLDEP="ocamldep" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -6657,283 +4354,241 @@ done done IFS=$as_save_IFS - test -z "$ac_cv_path_BCC" && ac_cv_path_BCC="no" - ;; -esac fi -BCC=$ac_cv_path_BCC -if test -n "$BCC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BCC" >&5 -$as_echo "$BCC" >&6; } +fi +ac_ct_OCAMLDEP=$ac_cv_prog_ac_ct_OCAMLDEP +if test -n "$ac_ct_OCAMLDEP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLDEP" >&5 +$as_echo "$ac_ct_OCAMLDEP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - -if test x"${BCC}" == x"no" -then - as_fn_error $? "Unable to find bcc, please install bcc" "$LINENO" 5 + if test "x$ac_ct_OCAMLDEP" = x; then + OCAMLDEP="no" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OCAMLDEP=$ac_ct_OCAMLDEP + fi +else + OCAMLDEP="$ac_cv_prog_OCAMLDEP" fi -# Extract the first word of "iasl", so it can be a program name with args. -set dummy iasl; ac_word=$2 + + + # checking for ocamlmktop + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ocamlmktop", so it can be a program name with args. +set dummy ${ac_tool_prefix}ocamlmktop; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_IASL+set}" = set; then : +if test "${ac_cv_prog_OCAMLMKTOP+set}" = set; then : $as_echo_n "(cached) " >&6 else - case $IASL in - [\\/]* | ?:[\\/]*) - ac_cv_path_IASL="$IASL" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + if test -n "$OCAMLMKTOP"; then + ac_cv_prog_OCAMLMKTOP="$OCAMLMKTOP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_IASL="$as_dir/$ac_word$ac_exec_ext" + ac_cv_prog_OCAMLMKTOP="${ac_tool_prefix}ocamlmktop" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 - fi -done - done -IFS=$as_save_IFS - - test -z "$ac_cv_path_IASL" && ac_cv_path_IASL="no" - ;; -esac -fi -IASL=$ac_cv_path_IASL -if test -n "$IASL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $IASL" >&5 -$as_echo "$IASL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -if test x"${IASL}" == x"no" -then - as_fn_error $? "Unable to find iasl, please install iasl" "$LINENO" 5 -fi - -ac_fn_c_check_header_mongrel "$LINENO" "uuid/uuid.h" "ac_cv_header_uuid_uuid_h" "$ac_includes_default" -if test "x$ac_cv_header_uuid_uuid_h" = x""yes; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_clear in -luuid" >&5 -$as_echo_n "checking for uuid_clear in -luuid... " >&6; } -if test "${ac_cv_lib_uuid_uuid_clear+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-luuid $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char uuid_clear (); -int -main () -{ -return uuid_clear (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_uuid_uuid_clear=yes -else - ac_cv_lib_uuid_uuid_clear=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_uuid_uuid_clear" >&5 -$as_echo "$ac_cv_lib_uuid_uuid_clear" >&6; } -if test "x$ac_cv_lib_uuid_uuid_clear" = x""yes; then : - libuuid="y" -fi - + fi +done + done +IFS=$as_save_IFS fi - - -ac_fn_c_check_header_mongrel "$LINENO" "uuid.h" "ac_cv_header_uuid_h" "$ac_includes_default" -if test "x$ac_cv_header_uuid_h" = x""yes; then : - libuuid="y" fi - - -if test "$libuuid" != "y"; then : - - as_fn_error $? "cannot find a valid uuid library" "$LINENO" 5 - +OCAMLMKTOP=$ac_cv_prog_OCAMLMKTOP +if test -n "$OCAMLMKTOP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLMKTOP" >&5 +$as_echo "$OCAMLMKTOP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi -ac_fn_c_check_header_mongrel "$LINENO" "curses.h" "ac_cv_header_curses_h" "$ac_includes_default" -if test "x$ac_cv_header_curses_h" = x""yes; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for clear in -lcurses" >&5 -$as_echo_n "checking for clear in -lcurses... " >&6; } -if test "${ac_cv_lib_curses_clear+set}" = set; then : +fi +if test -z "$ac_cv_prog_OCAMLMKTOP"; then + ac_ct_OCAMLMKTOP=$OCAMLMKTOP + # Extract the first word of "ocamlmktop", so it can be a program name with args. +set dummy ocamlmktop; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_OCAMLMKTOP+set}" = set; then : $as_echo_n "(cached) " >&6 else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lcurses $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char clear (); -int -main () -{ -return clear (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_curses_clear=yes + if test -n "$ac_ct_OCAMLMKTOP"; then + ac_cv_prog_ac_ct_OCAMLMKTOP="$ac_ct_OCAMLMKTOP" # Let the user override the test. else - ac_cv_lib_curses_clear=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_OCAMLMKTOP="ocamlmktop" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_clear" >&5 -$as_echo "$ac_cv_lib_curses_clear" >&6; } -if test "x$ac_cv_lib_curses_clear" = x""yes; then : - curses="y" +ac_ct_OCAMLMKTOP=$ac_cv_prog_ac_ct_OCAMLMKTOP +if test -n "$ac_ct_OCAMLMKTOP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLMKTOP" >&5 +$as_echo "$ac_ct_OCAMLMKTOP" >&6; } else - curses="n" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi - + if test "x$ac_ct_OCAMLMKTOP" = x; then + OCAMLMKTOP="no" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OCAMLMKTOP=$ac_ct_OCAMLMKTOP + fi else - curses="n" + OCAMLMKTOP="$ac_cv_prog_OCAMLMKTOP" fi -ac_fn_c_check_header_mongrel "$LINENO" "ncurses.h" "ac_cv_header_ncurses_h" "$ac_includes_default" -if test "x$ac_cv_header_ncurses_h" = x""yes; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for clear in -lncurses" >&5 -$as_echo_n "checking for clear in -lncurses... " >&6; } -if test "${ac_cv_lib_ncurses_clear+set}" = set; then : + # checking for ocamlmklib + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ocamlmklib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ocamlmklib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_OCAMLMKLIB+set}" = set; then : $as_echo_n "(cached) " >&6 else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lncurses $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char clear (); -int -main () -{ -return clear (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_ncurses_clear=yes + if test -n "$OCAMLMKLIB"; then + ac_cv_prog_OCAMLMKLIB="$OCAMLMKLIB" # Let the user override the test. else - ac_cv_lib_ncurses_clear=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_OCAMLMKLIB="${ac_tool_prefix}ocamlmklib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncurses_clear" >&5 -$as_echo "$ac_cv_lib_ncurses_clear" >&6; } -if test "x$ac_cv_lib_ncurses_clear" = x""yes; then : - ncurses="y" +OCAMLMKLIB=$ac_cv_prog_OCAMLMKLIB +if test -n "$OCAMLMKLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLMKLIB" >&5 +$as_echo "$OCAMLMKLIB" >&6; } else - ncurses="n" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi -else - ncurses="n" fi - - -if test "$curses" = "n" && test "$ncurses" = "n"; then : - - as_fn_error $? "Unable to find a suitable curses library" "$LINENO" 5 +if test -z "$ac_cv_prog_OCAMLMKLIB"; then + ac_ct_OCAMLMKLIB=$OCAMLMKLIB + # Extract the first word of "ocamlmklib", so it can be a program name with args. +set dummy ocamlmklib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_OCAMLMKLIB+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_OCAMLMKLIB"; then + ac_cv_prog_ac_ct_OCAMLMKLIB="$ac_ct_OCAMLMKLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_OCAMLMKLIB="ocamlmklib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS fi -# Prefer ncurses over curses if both are present -if test "$ncurses" = "y"; then : - - CURSES_LIBS="-lncurses" - -$as_echo "#define INCLUDE_CURSES_H <ncurses.h>" >>confdefs.h - - +fi +ac_ct_OCAMLMKLIB=$ac_cv_prog_ac_ct_OCAMLMKLIB +if test -n "$ac_ct_OCAMLMKLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLMKLIB" >&5 +$as_echo "$ac_ct_OCAMLMKLIB" >&6; } else - - CURSES_LIBS="-lcurses" - -$as_echo "#define INCLUDE_CURSES_H <curses.h>" >>confdefs.h - - + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi + if test "x$ac_ct_OCAMLMKLIB" = x; then + OCAMLMKLIB="no" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OCAMLMKLIB=$ac_ct_OCAMLMKLIB + fi +else + OCAMLMKLIB="$ac_cv_prog_OCAMLMKLIB" +fi - - - - - -if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. -set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 + # checking for ocamldoc + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ocamldoc", so it can be a program name with args. +set dummy ${ac_tool_prefix}ocamldoc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_PKG_CONFIG+set}" = set; then : +if test "${ac_cv_prog_OCAMLDOC+set}" = set; then : $as_echo_n "(cached) " >&6 else - case $PKG_CONFIG in - [\\/]* | ?:[\\/]*) - ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + if test -n "$OCAMLDOC"; then + ac_cv_prog_OCAMLDOC="$OCAMLDOC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + ac_cv_prog_OCAMLDOC="${ac_tool_prefix}ocamldoc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -6941,13 +4596,12 @@ done done IFS=$as_save_IFS - ;; -esac fi -PKG_CONFIG=$ac_cv_path_PKG_CONFIG -if test -n "$PKG_CONFIG"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 -$as_echo "$PKG_CONFIG" >&6; } +fi +OCAMLDOC=$ac_cv_prog_OCAMLDOC +if test -n "$OCAMLDOC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLDOC" >&5 +$as_echo "$OCAMLDOC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } @@ -6955,28 +4609,26 @@ fi fi -if test -z "$ac_cv_path_PKG_CONFIG"; then - ac_pt_PKG_CONFIG=$PKG_CONFIG - # Extract the first word of "pkg-config", so it can be a program name with args. -set dummy pkg-config; ac_word=$2 +if test -z "$ac_cv_prog_OCAMLDOC"; then + ac_ct_OCAMLDOC=$OCAMLDOC + # Extract the first word of "ocamldoc", so it can be a program name with args. +set dummy ocamldoc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then : +if test "${ac_cv_prog_ac_ct_OCAMLDOC+set}" = set; then : $as_echo_n "(cached) " >&6 else - case $ac_pt_PKG_CONFIG in - [\\/]* | ?:[\\/]*) - ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR + if test -n "$ac_ct_OCAMLDOC"; then + ac_cv_prog_ac_ct_OCAMLDOC="$ac_ct_OCAMLDOC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + ac_cv_prog_ac_ct_OCAMLDOC="ocamldoc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -6984,20 +4636,19 @@ done done IFS=$as_save_IFS - ;; -esac fi -ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG -if test -n "$ac_pt_PKG_CONFIG"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 -$as_echo "$ac_pt_PKG_CONFIG" >&6; } +fi +ac_ct_OCAMLDOC=$ac_cv_prog_ac_ct_OCAMLDOC +if test -n "$ac_ct_OCAMLDOC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLDOC" >&5 +$as_echo "$ac_ct_OCAMLDOC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - if test "x$ac_pt_PKG_CONFIG" = x; then - PKG_CONFIG="" + if test "x$ac_ct_OCAMLDOC" = x; then + OCAMLDOC="no" else case $cross_compiling:$ac_tool_warned in yes:) @@ -7005,624 +4656,718 @@ yes:) $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac - PKG_CONFIG=$ac_pt_PKG_CONFIG + OCAMLDOC=$ac_ct_OCAMLDOC fi else - PKG_CONFIG="$ac_cv_path_PKG_CONFIG" -fi - -fi -if test -n "$PKG_CONFIG"; then - _pkg_min_version=0.9.0 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 -$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } - if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - PKG_CONFIG="" - fi -fi - -pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for glib" >&5 -$as_echo_n "checking for glib... " >&6; } - -if test -n "$glib_CFLAGS"; then - pkg_cv_glib_CFLAGS="$glib_CFLAGS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"glib-2.0\""; } >&5 - ($PKG_CONFIG --exists --print-errors "glib-2.0") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_glib_CFLAGS=`$PKG_CONFIG --cflags "glib-2.0" 2>/dev/null` -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi -if test -n "$glib_LIBS"; then - pkg_cv_glib_LIBS="$glib_LIBS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"glib-2.0\""; } >&5 - ($PKG_CONFIG --exists --print-errors "glib-2.0") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_glib_LIBS=`$PKG_CONFIG --libs "glib-2.0" 2>/dev/null` -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi - - - -if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no + OCAMLDOC="$ac_cv_prog_OCAMLDOC" fi - if test $_pkg_short_errors_supported = yes; then - glib_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "glib-2.0" 2>&1` - else - glib_PKG_ERRORS=`$PKG_CONFIG --print-errors "glib-2.0" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$glib_PKG_ERRORS" >&5 - - as_fn_error $? "Package requirements (glib-2.0) were not met: - -$glib_PKG_ERRORS - -Consider adjusting the PKG_CONFIG_PATH environment variable if you -installed software in a non-standard prefix. - -Alternatively, you may set the environment variables glib_CFLAGS -and glib_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details." "$LINENO" 5 -elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it -is in your PATH or set the PKG_CONFIG environment variable to the full -path to pkg-config. -Alternatively, you may set the environment variables glib_CFLAGS -and glib_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details. -To get pkg-config, see <http://pkg-config.freedesktop.org/>. -See \`config.log' for more details" "$LINENO" 5 ; } + # checking for ocamlbuild + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ocamlbuild", so it can be a program name with args. +set dummy ${ac_tool_prefix}ocamlbuild; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_OCAMLBUILD+set}" = set; then : + $as_echo_n "(cached) " >&6 else - glib_CFLAGS=$pkg_cv_glib_CFLAGS - glib_LIBS=$pkg_cv_glib_LIBS - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - -fi - -# Check library path -if test "\${exec_prefix}/lib" = "$libdir"; then : - if test "$exec_prefix" = "NONE" && test "$prefix" != "NONE"; then : - exec_prefix=$prefix -fi - if test "$exec_prefix" = "NONE"; then : - exec_prefix=$ac_default_prefix -fi - if test -d "${exec_prefix}/lib64"; then : - - LIB_PATH="lib64" - + if test -n "$OCAMLBUILD"; then + ac_cv_prog_OCAMLBUILD="$OCAMLBUILD" # Let the user override the test. else - - LIB_PATH="lib" +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_OCAMLBUILD="${ac_tool_prefix}ocamlbuild" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS fi - -else - - LIB_PATH="${libdir:`expr length "$exec_prefix" + 1`}" - fi - - -# Checks for libraries. -ac_fn_c_check_header_mongrel "$LINENO" "bzlib.h" "ac_cv_header_bzlib_h" "$ac_includes_default" -if test "x$ac_cv_header_bzlib_h" = x""yes; then : - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BZ2_bzDecompressInit in -lbz2" >&5 -$as_echo_n "checking for BZ2_bzDecompressInit in -lbz2... " >&6; } -if test "${ac_cv_lib_bz2_BZ2_bzDecompressInit+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lbz2 $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char BZ2_bzDecompressInit (); -int -main () -{ -return BZ2_bzDecompressInit (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_bz2_BZ2_bzDecompressInit=yes +OCAMLBUILD=$ac_cv_prog_OCAMLBUILD +if test -n "$OCAMLBUILD"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCAMLBUILD" >&5 +$as_echo "$OCAMLBUILD" >&6; } else - ac_cv_lib_bz2_BZ2_bzDecompressInit=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bz2_BZ2_bzDecompressInit" >&5 -$as_echo "$ac_cv_lib_bz2_BZ2_bzDecompressInit" >&6; } -if test "x$ac_cv_lib_bz2_BZ2_bzDecompressInit" = x""yes; then : - zlib="$zlib -DHAVE_BZLIB -lbz2" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi fi - - -ac_fn_c_check_header_mongrel "$LINENO" "lzma.h" "ac_cv_header_lzma_h" "$ac_includes_default" -if test "x$ac_cv_header_lzma_h" = x""yes; then : - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for lzma_stream_decoder in -llzma" >&5 -$as_echo_n "checking for lzma_stream_decoder in -llzma... " >&6; } -if test "${ac_cv_lib_lzma_lzma_stream_decoder+set}" = set; then : +if test -z "$ac_cv_prog_OCAMLBUILD"; then + ac_ct_OCAMLBUILD=$OCAMLBUILD + # Extract the first word of "ocamlbuild", so it can be a program name with args. +set dummy ocamlbuild; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_OCAMLBUILD+set}" = set; then : $as_echo_n "(cached) " >&6 else - ac_check_lib_save_LIBS=$LIBS -LIBS="-llzma $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char lzma_stream_decoder (); -int -main () -{ -return lzma_stream_decoder (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_lzma_lzma_stream_decoder=yes + if test -n "$ac_ct_OCAMLBUILD"; then + ac_cv_prog_ac_ct_OCAMLBUILD="$ac_ct_OCAMLBUILD" # Let the user override the test. else - ac_cv_lib_lzma_lzma_stream_decoder=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_OCAMLBUILD="ocamlbuild" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lzma_lzma_stream_decoder" >&5 -$as_echo "$ac_cv_lib_lzma_lzma_stream_decoder" >&6; } -if test "x$ac_cv_lib_lzma_lzma_stream_decoder" = x""yes; then : - zlib="$zlib -DHAVE_LZMA -llzma" +ac_ct_OCAMLBUILD=$ac_cv_prog_ac_ct_OCAMLBUILD +if test -n "$ac_ct_OCAMLBUILD"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OCAMLBUILD" >&5 +$as_echo "$ac_ct_OCAMLBUILD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi - + if test "x$ac_ct_OCAMLBUILD" = x; then + OCAMLBUILD="no" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OCAMLBUILD=$ac_ct_OCAMLBUILD + fi +else + OCAMLBUILD="$ac_cv_prog_OCAMLBUILD" fi -ac_fn_c_check_header_mongrel "$LINENO" "lzo/lzo1x.h" "ac_cv_header_lzo_lzo1x_h" "$ac_includes_default" -if test "x$ac_cv_header_lzo_lzo1x_h" = x""yes; then : + if test "x$OCAMLC" = "xno"; then : -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for lzo1x_decompress in -llzo2" >&5 -$as_echo_n "checking for lzo1x_decompress in -llzo2... " >&6; } -if test "${ac_cv_lib_lzo2_lzo1x_decompress+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-llzo2 $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ + if test "x$enable_ocamltools" = "xyes"; then : -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char lzo1x_decompress (); -int -main () -{ -return lzo1x_decompress (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_lzo2_lzo1x_decompress=yes -else - ac_cv_lib_lzo2_lzo1x_decompress=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS + as_fn_error $? "Ocaml tools enabled, but unable to find Ocaml" "$LINENO" 5 fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lzo2_lzo1x_decompress" >&5 -$as_echo "$ac_cv_lib_lzo2_lzo1x_decompress" >&6; } -if test "x$ac_cv_lib_lzo2_lzo1x_decompress" = x""yes; then : - zlib="$zlib -DHAVE_LZO1X -llzo2" + ocamltools="n" + fi +fi +# Extract the first word of "bash", so it can be a program name with args. +set dummy bash; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_path_BASH+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + case $BASH in + [\\/]* | ?:[\\/]*) + ac_cv_path_BASH="$BASH" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_BASH="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + test -z "$ac_cv_path_BASH" && ac_cv_path_BASH="no" + ;; +esac +fi +BASH=$ac_cv_path_BASH +if test -n "$BASH"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BASH" >&5 +$as_echo "$BASH" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi +if test x"${BASH}" == x"no" +then + as_fn_error $? "Unable to find bash, please install bash" "$LINENO" 5 +fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for io_setup in -laio" >&5 -$as_echo_n "checking for io_setup in -laio... " >&6; } -if test "${ac_cv_lib_aio_io_setup+set}" = set; then : +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP+fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then : $as_echo_n "(cached) " >&6 else - ac_check_lib_save_LIBS=$LIBS -LIBS="-laio $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + # <limits.h> exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> #endif -char io_setup (); -int -main () -{ -return io_setup (); - ; - return 0; -} + Syntax error _ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_aio_io_setup=yes +if ac_fn_c_try_cpp "$LINENO"; then : + else - ac_cv_lib_aio_io_setup=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS + # Broken: fails on valid input. +continue fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_aio_io_setup" >&5 -$as_echo "$ac_cv_lib_aio_io_setup" >&6; } -if test "x$ac_cv_lib_aio_io_setup" = x""yes; then : - system_aio="y" +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <ac_nonexistent.h> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue else - system_aio="n" + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break fi + done + ac_cv_prog_CPP=$CPP -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for MD5 in -lcrypto" >&5 -$as_echo_n "checking for MD5 in -lcrypto... " >&6; } -if test "${ac_cv_lib_crypto_MD5+set}" = set; then : - $as_echo_n "(cached) " >&6 +fi + CPP=$ac_cv_prog_CPP else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lcrypto $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + # <limits.h> exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> #endif -char MD5 (); -int -main () -{ -return MD5 (); - ; - return 0; -} + Syntax error _ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_crypto_MD5=yes +if ac_fn_c_try_cpp "$LINENO"; then : + else - ac_cv_lib_crypto_MD5=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS + # Broken: fails on valid input. +continue fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_MD5" >&5 -$as_echo "$ac_cv_lib_crypto_MD5" >&6; } -if test "x$ac_cv_lib_crypto_MD5" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBCRYPTO 1 +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <ac_nonexistent.h> _ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext - LIBS="-lcrypto $LIBS" +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : else - as_fn_error $? "Could not find libcrypto" "$LINENO" 5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5 ; } fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ext2fs_open2 in -lext2fs" >&5 -$as_echo_n "checking for ext2fs_open2 in -lext2fs... " >&6; } -if test "${ac_cv_lib_ext2fs_ext2fs_open2+set}" = set; then : +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if test "${ac_cv_path_GREP+set}" = set; then : $as_echo_n "(cached) " >&6 else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lext2fs $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char ext2fs_open2 (); -int -main () -{ -return ext2fs_open2 (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_ext2fs_ext2fs_open2=yes + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi else - ac_cv_lib_ext2fs_ext2fs_open2=no + ac_cv_path_GREP=$GREP fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS + fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ext2fs_ext2fs_open2" >&5 -$as_echo "$ac_cv_lib_ext2fs_ext2fs_open2" >&6; } -if test "x$ac_cv_lib_ext2fs_ext2fs_open2" = x""yes; then : - libext2fs="y" +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if test "${ac_cv_path_EGREP+set}" = set; then : + $as_echo_n "(cached) " >&6 else - libext2fs="n" + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcry_md_hash_buffer in -lgcrypt" >&5 -$as_echo_n "checking for gcry_md_hash_buffer in -lgcrypt... " >&6; } -if test "${ac_cv_lib_gcrypt_gcry_md_hash_buffer+set}" = set; then : + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if test "${ac_cv_header_stdc+set}" = set; then : $as_echo_n "(cached) " >&6 else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lgcrypt $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <float.h> -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char gcry_md_hash_buffer (); int main () { -return gcry_md_hash_buffer (); + ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_gcrypt_gcry_md_hash_buffer=yes +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes else - ac_cv_lib_gcrypt_gcry_md_hash_buffer=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS + ac_cv_header_stdc=no fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gcrypt_gcry_md_hash_buffer" >&5 -$as_echo "$ac_cv_lib_gcrypt_gcry_md_hash_buffer" >&6; } -if test "x$ac_cv_lib_gcrypt_gcry_md_hash_buffer" = x""yes; then : - libgcrypt="y" +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <string.h> + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + else - libgcrypt="n" + ac_cv_header_stdc=no +fi +rm -f conftest* + fi +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdlib.h> +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread flag" >&5 -$as_echo_n "checking for pthread flag... " >&6; } -if test "${ax_cv_pthread_flags+set}" = set; then : - $as_echo_n "(cached) " >&6 else + ac_cv_header_stdc=no +fi +rm -f conftest* - ax_cv_pthread_flags=-pthread +fi - PTHREAD_CFLAGS="$ax_cv_pthread_flags" - PTHREAD_LDFLAGS="$ax_cv_pthread_flags" - PTHREAD_LIBS="" +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <ctype.h> +#include <stdlib.h> +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : - saved_CFLAGS="$CFLAGS" +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi - saved_LDFLAGS="$LDFLAGS" +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then - saved_LIBS="$LIBS" +$as_echo "#define STDC_HEADERS 1" >>confdefs.h +fi - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF - LDFLAGS="$LDFLAGS $PTHREAD_LDFLAGS" +fi - LIBS="$LIBS $PTHREAD_LIBS" +done - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <pthread.h> -int main(void) { - pthread_atfork(0,0,0); - pthread_create(0,0,0,0); -} +if test "x$pythontools" = "xy"; then : -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : + if echo "$PYTHON" | grep -q "^/"; then : + PYTHONPATH=$PYTHON + PYTHON=`basename $PYTHONPATH` + +elif test -z "$PYTHON"; then : + PYTHON="python" else - ax_cv_pthread_flags=failed + as_fn_error $? "PYTHON specified, but is not an absolute path" "$LINENO" 5 fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext + # Extract the first word of "$PYTHON", so it can be a program name with args. +set dummy $PYTHON; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_path_PYTHONPATH+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + case $PYTHONPATH in + [\\/]* | ?:[\\/]*) + ac_cv_path_PYTHONPATH="$PYTHONPATH" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_PYTHONPATH="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS - CFLAGS="$saved_CFLAGS" + test -z "$ac_cv_path_PYTHONPATH" && ac_cv_path_PYTHONPATH="no" + ;; +esac +fi +PYTHONPATH=$ac_cv_path_PYTHONPATH +if test -n "$PYTHONPATH"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHONPATH" >&5 +$as_echo "$PYTHONPATH" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi - LDFLAGS="$saved_LDFLAGS" - LIBS="$saved_LIBS" +if test x"${PYTHONPATH}" == x"no" +then + as_fn_error $? "Unable to find $PYTHON, please install $PYTHON" "$LINENO" 5 +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for python version >= 2.3 " >&5 +$as_echo_n "checking for python version >= 2.3 ... " >&6; } +`$PYTHON -c 'import sys; sys.exit(eval("sys.version_info < (2, 3)"))'` +if test "$?" != "0" +then + python_version=`$PYTHON -V 2>&1` + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + as_fn_error $? "$python_version is too old, minimum required version is 2.3" "$LINENO" 5 +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi +ac_previous_cppflags=$CPPFLAGS +ac_previous_ldflags=$LDFLAGS +ac_python_version=`$PYTHON -c 'import distutils.sysconfig; \ + print distutils.sysconfig.get_config_var("VERSION")'` +# Extract the first word of "$PYTHON-config", so it can be a program name with args. +set dummy $PYTHON-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_path_pyconfig+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + case $pyconfig in + [\\/]* | ?:[\\/]*) + ac_cv_path_pyconfig="$pyconfig" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_pyconfig="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + test -z "$ac_cv_path_pyconfig" && ac_cv_path_pyconfig="no" + ;; +esac +fi +pyconfig=$ac_cv_path_pyconfig +if test -n "$pyconfig"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $pyconfig" >&5 +$as_echo "$pyconfig" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_pthread_flags" >&5 -$as_echo "$ax_cv_pthread_flags" >&6; } - if test "x$ax_cv_pthread_flags" = xfailed; then - as_fn_error $? "-pthread does not work" "$LINENO" 5 - fi - - PTHREAD_CFLAGS="$ax_cv_pthread_flags" - PTHREAD_LDFLAGS="$ax_cv_pthread_flags" - PTHREAD_LIBS="" +if test x"$pyconfig" == x"no"; then : -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lrt" >&5 -$as_echo_n "checking for clock_gettime in -lrt... " >&6; } -if test "${ac_cv_lib_rt_clock_gettime+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lrt $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ + CPPFLAGS="$CFLAGS `$PYTHON -c 'import distutils.sysconfig; \ + print "-I" + distutils.sysconfig.get_config_var("INCLUDEPY")'`" + CPPFLAGS="$CPPFLAGS `$PYTHON -c 'import distutils.sysconfig; \ + print distutils.sysconfig.get_config_var("CFLAGS")'`" + LDFLAGS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \ + print distutils.sysconfig.get_config_var("LIBS")'`" + LDFLAGS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \ + print distutils.sysconfig.get_config_var("SYSLIBS")'`" + LDFLAGS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \ + print "-L" + distutils.sysconfig.get_python_lib(plat_specific=1,\ + standard_lib=1) + "/config"'`" + LDFLAGS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \ + print distutils.sysconfig.get_config_var("LINKFORSHARED")'`" + LDFLAGS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \ + print distutils.sysconfig.get_config_var("LDFLAGS")'`" -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char clock_gettime (); -int -main () -{ -return clock_gettime (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_rt_clock_gettime=yes else - ac_cv_lib_rt_clock_gettime=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_clock_gettime" >&5 -$as_echo "$ac_cv_lib_rt_clock_gettime" >&6; } -if test "x$ac_cv_lib_rt_clock_gettime" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBRT 1 -_ACEOF - LIBS="-lrt $LIBS" + CPPFLAGS="$CFLAGS `$PYTHON-config --cflags`" + LDFLAGS="$LDFLAGS `$PYTHON-config --ldflags`" fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for yajl_alloc in -lyajl" >&5 -$as_echo_n "checking for yajl_alloc in -lyajl... " >&6; } -if test "${ac_cv_lib_yajl_yajl_alloc+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lyajl $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ +ac_fn_c_check_header_mongrel "$LINENO" "Python.h" "ac_cv_header_Python_h" "$ac_includes_default" +if test "x$ac_cv_header_Python_h" = x""yes; then : -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char yajl_alloc (); -int -main () -{ -return yajl_alloc (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_yajl_yajl_alloc=yes else - ac_cv_lib_yajl_yajl_alloc=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS + as_fn_error $? "Unable to find Python development headers" "$LINENO" 5 fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_yajl_yajl_alloc" >&5 -$as_echo "$ac_cv_lib_yajl_yajl_alloc" >&6; } -if test "x$ac_cv_lib_yajl_yajl_alloc" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBYAJL 1 -_ACEOF - - LIBS="-lyajl $LIBS" -else - as_fn_error $? "Could not find yajl" "$LINENO" 5 -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for deflateCopy in -lz" >&5 -$as_echo_n "checking for deflateCopy in -lz... " >&6; } -if test "${ac_cv_lib_z_deflateCopy+set}" = set; then : +as_ac_Lib=`$as_echo "ac_cv_lib_python$ac_python_version''_PyArg_ParseTuple" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PyArg_ParseTuple in -lpython$ac_python_version" >&5 +$as_echo_n "checking for PyArg_ParseTuple in -lpython$ac_python_version... " >&6; } +if eval "test \"\${$as_ac_Lib+set}\"" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS -LIBS="-lz $LIBS" +LIBS="-lpython$ac_python_version $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -7632,1893 +5377,1173 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #ifdef __cplusplus extern "C" #endif -char deflateCopy (); +char PyArg_ParseTuple (); int main () { -return deflateCopy (); +return PyArg_ParseTuple (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_z_deflateCopy=yes + eval "$as_ac_Lib=yes" else - ac_cv_lib_z_deflateCopy=no + eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_deflateCopy" >&5 -$as_echo "$ac_cv_lib_z_deflateCopy" >&6; } -if test "x$ac_cv_lib_z_deflateCopy" = x""yes; then : +eval ac_res=\$$as_ac_Lib + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF -#define HAVE_LIBZ 1 +#define `$as_echo "HAVE_LIBpython$ac_python_version" | $as_tr_cpp` 1 _ACEOF - LIBS="-lz $LIBS" - -else - as_fn_error $? "Could not find zlib" "$LINENO" 5 -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libiconv_open in -liconv" >&5 -$as_echo_n "checking for libiconv_open in -liconv... " >&6; } -if test "${ac_cv_lib_iconv_libiconv_open+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-liconv $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ + LIBS="-lpython$ac_python_version $LIBS" -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char libiconv_open (); -int -main () -{ -return libiconv_open (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_iconv_libiconv_open=yes -else - ac_cv_lib_iconv_libiconv_open=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_iconv_libiconv_open" >&5 -$as_echo "$ac_cv_lib_iconv_libiconv_open" >&6; } -if test "x$ac_cv_lib_iconv_libiconv_open" = x""yes; then : - libiconv="y" else - libiconv="n" + as_fn_error $? "Unable to find a suitable python development library" "$LINENO" 5 fi +CPPFLAGS=$ac_previous_cppflags +LDLFAGS=$ac_previous_ldflags -# Checks for header files. -# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works -# for constant arguments. Useless! -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5 -$as_echo_n "checking for working alloca.h... " >&6; } -if test "${ac_cv_working_alloca_h+set}" = set; then : +fi +# Extract the first word of "xgettext", so it can be a program name with args. +set dummy xgettext; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_path_XGETTEXT+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <alloca.h> -int -main () -{ -char *p = (char *) alloca (2 * sizeof (int)); - if (p) return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_working_alloca_h=yes -else - ac_cv_working_alloca_h=no + case $XGETTEXT in + [\\/]* | ?:[\\/]*) + ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_XGETTEXT="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_path_XGETTEXT" && ac_cv_path_XGETTEXT="no" + ;; +esac fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext +XGETTEXT=$ac_cv_path_XGETTEXT +if test -n "$XGETTEXT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XGETTEXT" >&5 +$as_echo "$XGETTEXT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5 -$as_echo "$ac_cv_working_alloca_h" >&6; } -if test $ac_cv_working_alloca_h = yes; then -$as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h +if test x"${XGETTEXT}" == x"no" +then + as_fn_error $? "Unable to find xgettext, please install xgettext" "$LINENO" 5 fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5 -$as_echo_n "checking for alloca... " >&6; } -if test "${ac_cv_func_alloca_works+set}" = set; then : +# Extract the first word of "as86", so it can be a program name with args. +set dummy as86; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_path_AS86+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __GNUC__ -# define alloca __builtin_alloca -#else -# ifdef _MSC_VER -# include <malloc.h> -# define alloca _alloca -# else -# ifdef HAVE_ALLOCA_H -# include <alloca.h> -# else -# ifdef _AIX - #pragma alloca -# else -# ifndef alloca /* predefined by HP cc +Olibcalls */ -char *alloca (); -# endif -# endif -# endif -# endif -#endif - -int -main () -{ -char *p = (char *) alloca (1); - if (p) return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_func_alloca_works=yes -else - ac_cv_func_alloca_works=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5 -$as_echo "$ac_cv_func_alloca_works" >&6; } - -if test $ac_cv_func_alloca_works = yes; then - -$as_echo "#define HAVE_ALLOCA 1" >>confdefs.h + case $AS86 in + [\\/]* | ?:[\\/]*) + ac_cv_path_AS86="$AS86" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_AS86="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + test -z "$ac_cv_path_AS86" && ac_cv_path_AS86="no" + ;; +esac +fi +AS86=$ac_cv_path_AS86 +if test -n "$AS86"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AS86" >&5 +$as_echo "$AS86" >&6; } else - # The SVR3 libPW and SVR4 libucb both contain incompatible functions -# that cause trouble. Some versions do not even contain alloca or -# contain a buggy version. If you still want to use their alloca, -# use ar to extract alloca.o from them instead of compiling alloca.c. - -ALLOCA=\${LIBOBJDIR}alloca.$ac_objext - -$as_echo "#define C_ALLOCA 1" >>confdefs.h + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5 -$as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; } -if test "${ac_cv_os_cray+set}" = set; then : +if test x"${AS86}" == x"no" +then + as_fn_error $? "Unable to find as86, please install as86" "$LINENO" 5 +fi +# Extract the first word of "ld86", so it can be a program name with args. +set dummy ld86; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_path_LD86+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#if defined CRAY && ! defined CRAY2 -webecray -#else -wenotbecray -#endif + case $LD86 in + [\\/]* | ?:[\\/]*) + ac_cv_path_LD86="$LD86" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_LD86="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "webecray" >/dev/null 2>&1; then : - ac_cv_os_cray=yes -else - ac_cv_os_cray=no + test -z "$ac_cv_path_LD86" && ac_cv_path_LD86="no" + ;; +esac fi -rm -f conftest* - +LD86=$ac_cv_path_LD86 +if test -n "$LD86"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD86" >&5 +$as_echo "$LD86" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5 -$as_echo "$ac_cv_os_cray" >&6; } -if test $ac_cv_os_cray = yes; then - for ac_func in _getb67 GETB67 getb67; do - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : - -cat >>confdefs.h <<_ACEOF -#define CRAY_STACKSEG_END $ac_func -_ACEOF - break -fi - done +if test x"${LD86}" == x"no" +then + as_fn_error $? "Unable to find ld86, please install ld86" "$LINENO" 5 fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5 -$as_echo_n "checking stack direction for C alloca... " >&6; } -if test "${ac_cv_c_stack_direction+set}" = set; then : +# Extract the first word of "bcc", so it can be a program name with args. +set dummy bcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_path_BCC+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test "$cross_compiling" = yes; then : - ac_cv_c_stack_direction=0 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -find_stack_direction () -{ - static char *addr = 0; - auto char dummy; - if (addr == 0) - { - addr = &dummy; - return find_stack_direction (); - } - else - return (&dummy > addr) ? 1 : -1; -} + case $BCC in + [\\/]* | ?:[\\/]*) + ac_cv_path_BCC="$BCC" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_BCC="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS -int -main () -{ - return find_stack_direction () < 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_c_stack_direction=1 -else - ac_cv_c_stack_direction=-1 -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + test -z "$ac_cv_path_BCC" && ac_cv_path_BCC="no" + ;; +esac fi - +BCC=$ac_cv_path_BCC +if test -n "$BCC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BCC" >&5 +$as_echo "$BCC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5 -$as_echo "$ac_cv_c_stack_direction" >&6; } -cat >>confdefs.h <<_ACEOF -#define STACK_DIRECTION $ac_cv_c_stack_direction -_ACEOF +if test x"${BCC}" == x"no" +then + as_fn_error $? "Unable to find bcc, please install bcc" "$LINENO" 5 fi +# Extract the first word of "iasl", so it can be a program name with args. +set dummy iasl; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_path_IASL+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + case $IASL in + [\\/]* | ?:[\\/]*) + ac_cv_path_IASL="$IASL" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_IASL="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS -for ac_header in \ - arpa/inet.h fcntl.h inttypes.h libintl.h limits.h malloc.h \ - netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h \ - strings.h sys/file.h sys/ioctl.h sys/mount.h sys/param.h \ - sys/socket.h sys/statvfs.h sys/time.h syslog.h termios.h \ - unistd.h yajl/yajl_version.h \ + test -z "$ac_cv_path_IASL" && ac_cv_path_IASL="no" + ;; +esac +fi +IASL=$ac_cv_path_IASL +if test -n "$IASL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $IASL" >&5 +$as_echo "$IASL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF +if test x"${IASL}" == x"no" +then + as_fn_error $? "Unable to find iasl, please install iasl" "$LINENO" 5 fi -done - +ac_fn_c_check_header_mongrel "$LINENO" "uuid/uuid.h" "ac_cv_header_uuid_uuid_h" "$ac_includes_default" +if test "x$ac_cv_header_uuid_uuid_h" = x""yes; then : -# Checks for typedefs, structures, and compiler characteristics. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5 -$as_echo_n "checking for stdbool.h that conforms to C99... " >&6; } -if test "${ac_cv_header_stdbool_h+set}" = set; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_clear in -luuid" >&5 +$as_echo_n "checking for uuid_clear in -luuid... " >&6; } +if test "${ac_cv_lib_uuid_uuid_clear+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + ac_check_lib_save_LIBS=$LIBS +LIBS="-luuid $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include <stdbool.h> -#ifndef bool - "error: bool is not defined" -#endif -#ifndef false - "error: false is not defined" -#endif -#if false - "error: false is not 0" -#endif -#ifndef true - "error: true is not defined" -#endif -#if true != 1 - "error: true is not 1" -#endif -#ifndef __bool_true_false_are_defined - "error: __bool_true_false_are_defined is not defined" +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" #endif - - struct s { _Bool s: 1; _Bool t; } s; - - char a[true == 1 ? 1 : -1]; - char b[false == 0 ? 1 : -1]; - char c[__bool_true_false_are_defined == 1 ? 1 : -1]; - char d[(bool) 0.5 == true ? 1 : -1]; - bool e = &s; - char f[(_Bool) 0.0 == false ? 1 : -1]; - char g[true]; - char h[sizeof (_Bool)]; - char i[sizeof s.t]; - enum { j = false, k = true, l = false * true, m = true * 256 }; - /* The following fails for - HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ - _Bool n[m]; - char o[sizeof n == m * sizeof n[0] ? 1 : -1]; - char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; -# if defined __xlc__ || defined __GNUC__ - /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 - reported by James Lemley on 2005-10-05; see - http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html - This test is not quite right, since xlc is allowed to - reject this program, as the initializer for xlcbug is - not one of the forms that C requires support for. - However, doing the test right would require a runtime - test, and that would make cross-compilation harder. - Let us hope that IBM fixes the xlc bug, and also adds - support for this kind of constant expression. In the - meantime, this test will reject xlc, which is OK, since - our stdbool.h substitute should suffice. We also test - this with GCC, where it should work, to detect more - quickly whether someone messes up the test in the - future. */ - char digs[] = "0123456789"; - int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1); -# endif - /* Catch a bug in an HP-UX C compiler. See - http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html - http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html - */ - _Bool q = true; - _Bool *pq = &q; - +char uuid_clear (); int main () { - - *pq |= q; - *pq |= ! q; - /* Refer to every declared value, to avoid compiler optimizations. */ - return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l - + !m + !n + !o + !p + !q + !pq); - +return uuid_clear (); ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_header_stdbool_h=yes -else - ac_cv_header_stdbool_h=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5 -$as_echo "$ac_cv_header_stdbool_h" >&6; } -ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default" -if test "x$ac_cv_type__Bool" = x""yes; then : - -cat >>confdefs.h <<_ACEOF -#define HAVE__BOOL 1 -_ACEOF - - -fi - -if test $ac_cv_header_stdbool_h = yes; then - -$as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uid_t in sys/types.h" >&5 -$as_echo_n "checking for uid_t in sys/types.h... " >&6; } -if test "${ac_cv_type_uid_t+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <sys/types.h> - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "uid_t" >/dev/null 2>&1; then : - ac_cv_type_uid_t=yes -else - ac_cv_type_uid_t=no -fi -rm -f conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_uid_t" >&5 -$as_echo "$ac_cv_type_uid_t" >&6; } -if test $ac_cv_type_uid_t = no; then - -$as_echo "#define uid_t int" >>confdefs.h - - -$as_echo "#define gid_t int" >>confdefs.h - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 -$as_echo_n "checking for inline... " >&6; } -if test "${ac_cv_c_inline+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_c_inline=no -for ac_kw in inline __inline__ __inline; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifndef __cplusplus -typedef int foo_t; -static $ac_kw foo_t static_foo () {return 0; } -$ac_kw foo_t foo () {return 0; } -#endif - -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_c_inline=$ac_kw +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_uuid_uuid_clear=yes +else + ac_cv_lib_uuid_uuid_clear=no fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - test "$ac_cv_c_inline" != no && break -done - +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_uuid_uuid_clear" >&5 +$as_echo "$ac_cv_lib_uuid_uuid_clear" >&6; } +if test "x$ac_cv_lib_uuid_uuid_clear" = x""yes; then : + libuuid="y" fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 -$as_echo "$ac_cv_c_inline" >&6; } -case $ac_cv_c_inline in - inline | yes) ;; - *) - case $ac_cv_c_inline in - no) ac_val=;; - *) ac_val=$ac_cv_c_inline;; - esac - cat >>confdefs.h <<_ACEOF -#ifndef __cplusplus -#define inline $ac_val -#endif -_ACEOF - ;; -esac -ac_fn_c_find_intX_t "$LINENO" "16" "ac_cv_c_int16_t" -case $ac_cv_c_int16_t in #( - no|yes) ;; #( - *) +fi -cat >>confdefs.h <<_ACEOF -#define int16_t $ac_cv_c_int16_t -_ACEOF -;; -esac -ac_fn_c_find_intX_t "$LINENO" "32" "ac_cv_c_int32_t" -case $ac_cv_c_int32_t in #( - no|yes) ;; #( - *) +ac_fn_c_check_header_mongrel "$LINENO" "uuid.h" "ac_cv_header_uuid_h" "$ac_includes_default" +if test "x$ac_cv_header_uuid_h" = x""yes; then : + libuuid="y" +fi -cat >>confdefs.h <<_ACEOF -#define int32_t $ac_cv_c_int32_t -_ACEOF -;; -esac -ac_fn_c_find_intX_t "$LINENO" "64" "ac_cv_c_int64_t" -case $ac_cv_c_int64_t in #( - no|yes) ;; #( - *) +if test "$libuuid" != "y"; then : -cat >>confdefs.h <<_ACEOF -#define int64_t $ac_cv_c_int64_t -_ACEOF -;; -esac + as_fn_error $? "cannot find a valid uuid library" "$LINENO" 5 -ac_fn_c_find_intX_t "$LINENO" "8" "ac_cv_c_int8_t" -case $ac_cv_c_int8_t in #( - no|yes) ;; #( - *) +fi -cat >>confdefs.h <<_ACEOF -#define int8_t $ac_cv_c_int8_t -_ACEOF -;; -esac -ac_fn_c_check_type "$LINENO" "mode_t" "ac_cv_type_mode_t" "$ac_includes_default" -if test "x$ac_cv_type_mode_t" = x""yes; then : +ac_fn_c_check_header_mongrel "$LINENO" "curses.h" "ac_cv_header_curses_h" "$ac_includes_default" +if test "x$ac_cv_header_curses_h" = x""yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for clear in -lcurses" >&5 +$as_echo_n "checking for clear in -lcurses... " >&6; } +if test "${ac_cv_lib_curses_clear+set}" = set; then : + $as_echo_n "(cached) " >&6 else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lcurses $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ -cat >>confdefs.h <<_ACEOF -#define mode_t int +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char clear (); +int +main () +{ +return clear (); + ; + return 0; +} _ACEOF - +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_curses_clear=yes +else + ac_cv_lib_curses_clear=no fi - -ac_fn_c_check_type "$LINENO" "off_t" "ac_cv_type_off_t" "$ac_includes_default" -if test "x$ac_cv_type_off_t" = x""yes; then : - +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_clear" >&5 +$as_echo "$ac_cv_lib_curses_clear" >&6; } +if test "x$ac_cv_lib_curses_clear" = x""yes; then : + curses="y" else - -cat >>confdefs.h <<_ACEOF -#define off_t long int -_ACEOF - + curses="n" fi -ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default" -if test "x$ac_cv_type_pid_t" = x""yes; then : else + curses="n" +fi -cat >>confdefs.h <<_ACEOF -#define pid_t int -_ACEOF -fi +ac_fn_c_check_header_mongrel "$LINENO" "ncurses.h" "ac_cv_header_ncurses_h" "$ac_includes_default" +if test "x$ac_cv_header_ncurses_h" = x""yes; then : -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C/C++ restrict keyword" >&5 -$as_echo_n "checking for C/C++ restrict keyword... " >&6; } -if test "${ac_cv_c_restrict+set}" = set; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for clear in -lncurses" >&5 +$as_echo_n "checking for clear in -lncurses... " >&6; } +if test "${ac_cv_lib_ncurses_clear+set}" = set; then : $as_echo_n "(cached) " >&6 else - ac_cv_c_restrict=no - # The order here caters to the fact that C++ does not require restrict. - for ac_kw in __restrict __restrict__ _Restrict restrict; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + ac_check_lib_save_LIBS=$LIBS +LIBS="-lncurses $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -typedef int * int_ptr; - int foo (int_ptr $ac_kw ip) { - return ip[0]; - } + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char clear (); int main () { -int s[1]; - int * $ac_kw t = s; - t[0] = 0; - return foo(t) +return clear (); ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_c_restrict=$ac_kw +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_ncurses_clear=yes +else + ac_cv_lib_ncurses_clear=no fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - test "$ac_cv_c_restrict" != no && break - done - +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_restrict" >&5 -$as_echo "$ac_cv_c_restrict" >&6; } - - case $ac_cv_c_restrict in - restrict) ;; - no) $as_echo "#define restrict /**/" >>confdefs.h - ;; - *) cat >>confdefs.h <<_ACEOF -#define restrict $ac_cv_c_restrict -_ACEOF - ;; - esac - -ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" -if test "x$ac_cv_type_size_t" = x""yes; then : - +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncurses_clear" >&5 +$as_echo "$ac_cv_lib_ncurses_clear" >&6; } +if test "x$ac_cv_lib_ncurses_clear" = x""yes; then : + ncurses="y" else - -cat >>confdefs.h <<_ACEOF -#define size_t unsigned int -_ACEOF - + ncurses="n" fi -ac_fn_c_check_type "$LINENO" "ssize_t" "ac_cv_type_ssize_t" "$ac_includes_default" -if test "x$ac_cv_type_ssize_t" = x""yes; then : else - -cat >>confdefs.h <<_ACEOF -#define ssize_t int -_ACEOF - + ncurses="n" fi -ac_fn_c_check_member "$LINENO" "struct stat" "st_blksize" "ac_cv_member_struct_stat_st_blksize" "$ac_includes_default" -if test "x$ac_cv_member_struct_stat_st_blksize" = x""yes; then : -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 -_ACEOF +if test "$curses" = "n" && test "$ncurses" = "n"; then : + as_fn_error $? "Unable to find a suitable curses library" "$LINENO" 5 fi +# Prefer ncurses over curses if both are present +if test "$ncurses" = "y"; then : -ac_fn_c_check_member "$LINENO" "struct stat" "st_blocks" "ac_cv_member_struct_stat_st_blocks" "$ac_includes_default" -if test "x$ac_cv_member_struct_stat_st_blocks" = x""yes; then : - -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_STAT_ST_BLOCKS 1 -_ACEOF + CURSES_LIBS="-lncurses" +$as_echo "#define INCLUDE_CURSES_H <ncurses.h>" >>confdefs.h -$as_echo "#define HAVE_ST_BLOCKS 1" >>confdefs.h else - case " $LIBOBJS " in - *" fileblocks.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS fileblocks.$ac_objext" - ;; -esac - -fi - -ac_fn_c_check_member "$LINENO" "struct stat" "st_rdev" "ac_cv_member_struct_stat_st_rdev" "$ac_includes_default" -if test "x$ac_cv_member_struct_stat_st_rdev" = x""yes; then : + CURSES_LIBS="-lcurses" -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_STAT_ST_RDEV 1 -_ACEOF +$as_echo "#define INCLUDE_CURSES_H <curses.h>" >>confdefs.h fi -ac_fn_c_find_uintX_t "$LINENO" "16" "ac_cv_c_uint16_t" -case $ac_cv_c_uint16_t in #( - no|yes) ;; #( - *) -cat >>confdefs.h <<_ACEOF -#define uint16_t $ac_cv_c_uint16_t -_ACEOF -;; - esac -ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t" -case $ac_cv_c_uint32_t in #( - no|yes) ;; #( - *) -$as_echo "#define _UINT32_T 1" >>confdefs.h -cat >>confdefs.h <<_ACEOF -#define uint32_t $ac_cv_c_uint32_t -_ACEOF -;; - esac -ac_fn_c_find_uintX_t "$LINENO" "64" "ac_cv_c_uint64_t" -case $ac_cv_c_uint64_t in #( - no|yes) ;; #( +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. +set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_path_PKG_CONFIG+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + case $PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. + ;; *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS -$as_echo "#define _UINT64_T 1" >>confdefs.h - + ;; +esac +fi +PKG_CONFIG=$ac_cv_path_PKG_CONFIG +if test -n "$PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 +$as_echo "$PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi -cat >>confdefs.h <<_ACEOF -#define uint64_t $ac_cv_c_uint64_t -_ACEOF -;; - esac -ac_fn_c_find_uintX_t "$LINENO" "8" "ac_cv_c_uint8_t" -case $ac_cv_c_uint8_t in #( - no|yes) ;; #( +fi +if test -z "$ac_cv_path_PKG_CONFIG"; then + ac_pt_PKG_CONFIG=$PKG_CONFIG + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + case $ac_pt_PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. + ;; *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS -$as_echo "#define _UINT8_T 1" >>confdefs.h - - -cat >>confdefs.h <<_ACEOF -#define uint8_t $ac_cv_c_uint8_t -_ACEOF -;; - esac - -ac_fn_c_check_type "$LINENO" "ptrdiff_t" "ac_cv_type_ptrdiff_t" "$ac_includes_default" -if test "x$ac_cv_type_ptrdiff_t" = x""yes; then : - -cat >>confdefs.h <<_ACEOF -#define HAVE_PTRDIFF_T 1 -_ACEOF - - + ;; +esac +fi +ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG +if test -n "$ac_pt_PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 +$as_echo "$ac_pt_PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi - -# Checks for library functions. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for error_at_line" >&5 -$as_echo_n "checking for error_at_line... " >&6; } -if test "${ac_cv_lib_error_at_line+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <error.h> -int -main () -{ -error_at_line (0, 0, "", 0, "an error occurred"); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_error_at_line=yes + if test "x$ac_pt_PKG_CONFIG" = x; then + PKG_CONFIG="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + PKG_CONFIG=$ac_pt_PKG_CONFIG + fi else - ac_cv_lib_error_at_line=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext + PKG_CONFIG="$ac_cv_path_PKG_CONFIG" fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_error_at_line" >&5 -$as_echo "$ac_cv_lib_error_at_line" >&6; } -if test $ac_cv_lib_error_at_line = no; then - case " $LIBOBJS " in - *" error.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS error.$ac_objext" - ;; -esac fi - -for ac_header in vfork.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "vfork.h" "ac_cv_header_vfork_h" "$ac_includes_default" -if test "x$ac_cv_header_vfork_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_VFORK_H 1 -_ACEOF - +if test -n "$PKG_CONFIG"; then + _pkg_min_version=0.9.0 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 +$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG="" + fi fi -done - -for ac_func in fork vfork -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for glib" >&5 +$as_echo_n "checking for glib... " >&6; } -if test "x$ac_cv_func_fork" = xyes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working fork" >&5 -$as_echo_n "checking for working fork... " >&6; } -if test "${ac_cv_func_fork_works+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_func_fork_works=cross +if test -n "$glib_CFLAGS"; then + pkg_cv_glib_CFLAGS="$glib_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"glib-2.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "glib-2.0") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_glib_CFLAGS=`$PKG_CONFIG --cflags "glib-2.0" 2>/dev/null` else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ - - /* By Ruediger Kuhlmann. */ - return fork () < 0; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_func_fork_works=yes + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$glib_LIBS"; then + pkg_cv_glib_LIBS="$glib_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"glib-2.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "glib-2.0") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_glib_LIBS=`$PKG_CONFIG --libs "glib-2.0" 2>/dev/null` else - ac_cv_func_fork_works=no + pkg_failed=yes fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + else + pkg_failed=untried fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_fork_works" >&5 -$as_echo "$ac_cv_func_fork_works" >&6; } + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes else - ac_cv_func_fork_works=$ac_cv_func_fork + _pkg_short_errors_supported=no fi -if test "x$ac_cv_func_fork_works" = xcross; then - case $host in - *-*-amigaos* | *-*-msdosdjgpp*) - # Override, as these systems have only a dummy fork() stub - ac_cv_func_fork_works=no - ;; - *) - ac_cv_func_fork_works=yes - ;; - esac - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&5 -$as_echo "$as_me: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&2;} -fi -ac_cv_func_vfork_works=$ac_cv_func_vfork -if test "x$ac_cv_func_vfork" = xyes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working vfork" >&5 -$as_echo_n "checking for working vfork... " >&6; } -if test "${ac_cv_func_vfork_works+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_func_vfork_works=cross -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -/* Thanks to Paul Eggert for this test. */ -$ac_includes_default -#include <sys/wait.h> -#ifdef HAVE_VFORK_H -# include <vfork.h> -#endif -/* On some sparc systems, changes by the child to local and incoming - argument registers are propagated back to the parent. The compiler - is told about this with #include <vfork.h>, but some compilers - (e.g. gcc -O) don't grok <vfork.h>. Test for this by using a - static variable whose address is put into a register that is - clobbered by the vfork. */ -static void -#ifdef __cplusplus -sparc_address_test (int arg) -# else -sparc_address_test (arg) int arg; -#endif -{ - static pid_t child; - if (!child) { - child = vfork (); - if (child < 0) { - perror ("vfork"); - _exit(2); - } - if (!child) { - arg = getpid(); - write(-1, "", 0); - _exit (arg); - } - } -} + if test $_pkg_short_errors_supported = yes; then + glib_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "glib-2.0" 2>&1` + else + glib_PKG_ERRORS=`$PKG_CONFIG --print-errors "glib-2.0" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$glib_PKG_ERRORS" >&5 -int -main () -{ - pid_t parent = getpid (); - pid_t child; - - sparc_address_test (0); - - child = vfork (); - - if (child == 0) { - /* Here is another test for sparc vfork register problems. This - test uses lots of local variables, at least as many local - variables as main has allocated so far including compiler - temporaries. 4 locals are enough for gcc 1.40.3 on a Solaris - 4.1.3 sparc, but we use 8 to be safe. A buggy compiler should - reuse the register of parent for one of the local variables, - since it will think that parent can't possibly be used any more - in this routine. Assigning to the local variable will thus - munge parent in the parent process. */ - pid_t - p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(), - p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid(); - /* Convince the compiler that p..p7 are live; otherwise, it might - use the same hardware register for all 8 local variables. */ - if (p != p1 || p != p2 || p != p3 || p != p4 - || p != p5 || p != p6 || p != p7) - _exit(1); - - /* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent - from child file descriptors. If the child closes a descriptor - before it execs or exits, this munges the parent's descriptor - as well. Test for this by closing stdout in the child. */ - _exit(close(fileno(stdout)) != 0); - } else { - int status; - struct stat st; + as_fn_error $? "Package requirements (glib-2.0) were not met: - while (wait(&status) != child) - ; - return ( - /* Was there some problem with vforking? */ - child < 0 +$glib_PKG_ERRORS - /* Did the child fail? (This shouldn't happen.) */ - || status +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. - /* Did the vfork/compiler bug occur? */ - || parent != getpid() +Alternatively, you may set the environment variables glib_CFLAGS +and glib_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. - /* Did the file descriptor bug occur? */ - || fstat(fileno(stdout), &st) != 0 - ); - } -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_func_vfork_works=yes +Alternatively, you may set the environment variables glib_CFLAGS +and glib_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see <http://pkg-config.freedesktop.org/>. +See \`config.log' for more details" "$LINENO" 5 ; } else - ac_cv_func_vfork_works=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi + glib_CFLAGS=$pkg_cv_glib_CFLAGS + glib_LIBS=$pkg_cv_glib_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_vfork_works" >&5 -$as_echo "$ac_cv_func_vfork_works" >&6; } -fi; -if test "x$ac_cv_func_fork_works" = xcross; then - ac_cv_func_vfork_works=$ac_cv_func_vfork - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&5 -$as_echo "$as_me: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&2;} +# Check library path +if test "\${exec_prefix}/lib" = "$libdir"; then : + if test "$exec_prefix" = "NONE" && test "$prefix" != "NONE"; then : + exec_prefix=$prefix fi + if test "$exec_prefix" = "NONE"; then : + exec_prefix=$ac_default_prefix +fi + if test -d "${exec_prefix}/lib64"; then : -if test "x$ac_cv_func_vfork_works" = xyes; then - -$as_echo "#define HAVE_WORKING_VFORK 1" >>confdefs.h + LIB_PATH="lib64" else -$as_echo "#define vfork fork" >>confdefs.h + LIB_PATH="lib" fi -if test "x$ac_cv_func_fork_works" = xyes; then -$as_echo "#define HAVE_WORKING_FORK 1" >>confdefs.h +else -fi + LIB_PATH="${libdir:`expr length "$exec_prefix" + 1`}" -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGEFILE_SOURCE value needed for large files" >&5 -$as_echo_n "checking for _LARGEFILE_SOURCE value needed for large files... " >&6; } -if test "${ac_cv_sys_largefile_source+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - while :; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <sys/types.h> /* for off_t */ - #include <stdio.h> -int -main () -{ -int (*fp) (FILE *, off_t, int) = fseeko; - return fseeko (stdin, 0, 0) && fp (stdin, 0, 0); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_sys_largefile_source=no; break -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#define _LARGEFILE_SOURCE 1 -#include <sys/types.h> /* for off_t */ - #include <stdio.h> -int -main () -{ -int (*fp) (FILE *, off_t, int) = fseeko; - return fseeko (stdin, 0, 0) && fp (stdin, 0, 0); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_sys_largefile_source=1; break fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - ac_cv_sys_largefile_source=unknown - break -done -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_source" >&5 -$as_echo "$ac_cv_sys_largefile_source" >&6; } -case $ac_cv_sys_largefile_source in #( - no | unknown) ;; - *) -cat >>confdefs.h <<_ACEOF -#define _LARGEFILE_SOURCE $ac_cv_sys_largefile_source -_ACEOF -;; -esac -rm -rf conftest* - -# We used to try defining _XOPEN_SOURCE=500 too, to work around a bug -# in glibc 2.1.3, but that breaks too many other things. -# If you want fseeko and ftello with glibc, upgrade to a fixed glibc. -if test $ac_cv_sys_largefile_source != unknown; then -$as_echo "#define HAVE_FSEEKO 1" >>confdefs.h -fi +# Checks for libraries. +ac_fn_c_check_header_mongrel "$LINENO" "bzlib.h" "ac_cv_header_bzlib_h" "$ac_includes_default" +if test "x$ac_cv_header_bzlib_h" = x""yes; then : -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether lstat correctly handles trailing slash" >&5 -$as_echo_n "checking whether lstat correctly handles trailing slash... " >&6; } -if test "${ac_cv_func_lstat_dereferences_slashed_symlink+set}" = set; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BZ2_bzDecompressInit in -lbz2" >&5 +$as_echo_n "checking for BZ2_bzDecompressInit in -lbz2... " >&6; } +if test "${ac_cv_lib_bz2_BZ2_bzDecompressInit+set}" = set; then : $as_echo_n "(cached) " >&6 else - rm -f conftest.sym conftest.file -echo >conftest.file -if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then - if test "$cross_compiling" = yes; then : - ac_cv_func_lstat_dereferences_slashed_symlink=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + ac_check_lib_save_LIBS=$LIBS +LIBS="-lbz2 $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -$ac_includes_default + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char BZ2_bzDecompressInit (); int main () { -struct stat sbuf; - /* Linux will dereference the symlink and fail, as required by POSIX. - That is better in the sense that it means we will not - have to compile and use the lstat wrapper. */ - return lstat ("conftest.sym/", &sbuf) == 0; +return BZ2_bzDecompressInit (); ; return 0; } _ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_func_lstat_dereferences_slashed_symlink=yes -else - ac_cv_func_lstat_dereferences_slashed_symlink=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_bz2_BZ2_bzDecompressInit=yes else - # If the `ln -s' command failed, then we probably don't even - # have an lstat function. - ac_cv_func_lstat_dereferences_slashed_symlink=no + ac_cv_lib_bz2_BZ2_bzDecompressInit=no fi -rm -f conftest.sym conftest.file - +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bz2_BZ2_bzDecompressInit" >&5 +$as_echo "$ac_cv_lib_bz2_BZ2_bzDecompressInit" >&6; } +if test "x$ac_cv_lib_bz2_BZ2_bzDecompressInit" = x""yes; then : + zlib="$zlib -DHAVE_BZLIB -lbz2" fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_lstat_dereferences_slashed_symlink" >&5 -$as_echo "$ac_cv_func_lstat_dereferences_slashed_symlink" >&6; } - -test $ac_cv_func_lstat_dereferences_slashed_symlink = yes && -cat >>confdefs.h <<_ACEOF -#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1 -_ACEOF +fi -if test "x$ac_cv_func_lstat_dereferences_slashed_symlink" = xno; then - case " $LIBOBJS " in - *" lstat.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS lstat.$ac_objext" - ;; -esac -fi +ac_fn_c_check_header_mongrel "$LINENO" "lzma.h" "ac_cv_header_lzma_h" "$ac_includes_default" +if test "x$ac_cv_header_lzma_h" = x""yes; then : -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether sys/types.h defines makedev" >&5 -$as_echo_n "checking whether sys/types.h defines makedev... " >&6; } -if test "${ac_cv_header_sys_types_h_makedev+set}" = set; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for lzma_stream_decoder in -llzma" >&5 +$as_echo_n "checking for lzma_stream_decoder in -llzma... " >&6; } +if test "${ac_cv_lib_lzma_lzma_stream_decoder+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + ac_check_lib_save_LIBS=$LIBS +LIBS="-llzma $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include <sys/types.h> + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char lzma_stream_decoder (); int main () { -return makedev(0, 0); +return lzma_stream_decoder (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - ac_cv_header_sys_types_h_makedev=yes + ac_cv_lib_lzma_lzma_stream_decoder=yes else - ac_cv_header_sys_types_h_makedev=no + ac_cv_lib_lzma_lzma_stream_decoder=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_sys_types_h_makedev" >&5 -$as_echo "$ac_cv_header_sys_types_h_makedev" >&6; } - -if test $ac_cv_header_sys_types_h_makedev = no; then -ac_fn_c_check_header_mongrel "$LINENO" "sys/mkdev.h" "ac_cv_header_sys_mkdev_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_mkdev_h" = x""yes; then : - -$as_echo "#define MAJOR_IN_MKDEV 1" >>confdefs.h - +LIBS=$ac_check_lib_save_LIBS fi - - - - if test $ac_cv_header_sys_mkdev_h = no; then - ac_fn_c_check_header_mongrel "$LINENO" "sys/sysmacros.h" "ac_cv_header_sys_sysmacros_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_sysmacros_h" = x""yes; then : - -$as_echo "#define MAJOR_IN_SYSMACROS 1" >>confdefs.h - +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lzma_lzma_stream_decoder" >&5 +$as_echo "$ac_cv_lib_lzma_lzma_stream_decoder" >&6; } +if test "x$ac_cv_lib_lzma_lzma_stream_decoder" = x""yes; then : + zlib="$zlib -DHAVE_LZMA -llzma" fi - fi fi -for ac_header in stdlib.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" -if test "x$ac_cv_header_stdlib_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_STDLIB_H 1 -_ACEOF - -fi -done +ac_fn_c_check_header_mongrel "$LINENO" "lzo/lzo1x.h" "ac_cv_header_lzo_lzo1x_h" "$ac_includes_default" +if test "x$ac_cv_header_lzo_lzo1x_h" = x""yes; then : -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible malloc" >&5 -$as_echo_n "checking for GNU libc compatible malloc... " >&6; } -if test "${ac_cv_func_malloc_0_nonnull+set}" = set; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for lzo1x_decompress in -llzo2" >&5 +$as_echo_n "checking for lzo1x_decompress in -llzo2... " >&6; } +if test "${ac_cv_lib_lzo2_lzo1x_decompress+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test "$cross_compiling" = yes; then : - ac_cv_func_malloc_0_nonnull=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + ac_check_lib_save_LIBS=$LIBS +LIBS="-llzo2 $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#if defined STDC_HEADERS || defined HAVE_STDLIB_H -# include <stdlib.h> -#else -char *malloc (); -#endif +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char lzo1x_decompress (); int main () { -return ! malloc (0); +return lzo1x_decompress (); ; return 0; } _ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_func_malloc_0_nonnull=yes +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_lzo2_lzo1x_decompress=yes else - ac_cv_func_malloc_0_nonnull=no + ac_cv_lib_lzo2_lzo1x_decompress=no fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS fi - +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lzo2_lzo1x_decompress" >&5 +$as_echo "$ac_cv_lib_lzo2_lzo1x_decompress" >&6; } +if test "x$ac_cv_lib_lzo2_lzo1x_decompress" = x""yes; then : + zlib="$zlib -DHAVE_LZO1X -llzo2" fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_malloc_0_nonnull" >&5 -$as_echo "$ac_cv_func_malloc_0_nonnull" >&6; } -if test $ac_cv_func_malloc_0_nonnull = yes; then : - -$as_echo "#define HAVE_MALLOC 1" >>confdefs.h - -else - $as_echo "#define HAVE_MALLOC 0" >>confdefs.h - - case " $LIBOBJS " in - *" malloc.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS malloc.$ac_objext" - ;; -esac - -$as_echo "#define malloc rpl_malloc" >>confdefs.h fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 -$as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } -if test "${ac_cv_header_time+set}" = set; then : + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for io_setup in -laio" >&5 +$as_echo_n "checking for io_setup in -laio... " >&6; } +if test "${ac_cv_lib_aio_io_setup+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + ac_check_lib_save_LIBS=$LIBS +LIBS="-laio $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include <sys/types.h> -#include <sys/time.h> -#include <time.h> +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char io_setup (); int main () { -if ((struct tm *) 0) -return 0; +return io_setup (); ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_header_time=yes +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_aio_io_setup=yes else - ac_cv_header_time=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 -$as_echo "$ac_cv_header_time" >&6; } -if test $ac_cv_header_time = yes; then - -$as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h - + ac_cv_lib_aio_io_setup=no fi - - - - - for ac_header in $ac_header_list -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default -" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS fi - -done - - - - - - - - - for ac_func in $ac_func_list -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_aio_io_setup" >&5 +$as_echo "$ac_cv_lib_aio_io_setup" >&6; } +if test "x$ac_cv_lib_aio_io_setup" = x""yes; then : + system_aio="y" +else + system_aio="n" fi -done - - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working mktime" >&5 -$as_echo_n "checking for working mktime... " >&6; } -if test "${ac_cv_func_working_mktime+set}" = set; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for MD5 in -lcrypto" >&5 +$as_echo_n "checking for MD5 in -lcrypto... " >&6; } +if test "${ac_cv_lib_crypto_MD5+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test "$cross_compiling" = yes; then : - ac_cv_func_working_mktime=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + ac_check_lib_save_LIBS=$LIBS +LIBS="-lcrypto $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -/* Test program from Paul Eggert and Tony Leneis. */ -#ifdef TIME_WITH_SYS_TIME -# include <sys/time.h> -# include <time.h> -#else -# ifdef HAVE_SYS_TIME_H -# include <sys/time.h> -# else -# include <time.h> -# endif -#endif - -#include <limits.h> -#include <stdlib.h> -#ifdef HAVE_UNISTD_H -# include <unistd.h> -#endif - -#ifndef HAVE_ALARM -# define alarm(X) /* empty */ +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" #endif - -/* Work around redefinition to rpl_putenv by other config tests. */ -#undef putenv - -static time_t time_t_max; -static time_t time_t_min; - -/* Values we'll use to set the TZ environment variable. */ -static const char *tz_strings[] = { - (const char *) 0, "TZ=GMT0", "TZ=JST-9", - "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00" -}; -#define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0])) - -/* Return 0 if mktime fails to convert a date in the spring-forward gap. - Based on a problem report from Andreas Jaeger. */ -static int -spring_forward_gap () -{ - /* glibc (up to about 1998-10-07) failed this test. */ - struct tm tm; - - /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0" - instead of "TZ=America/Vancouver" in order to detect the bug even - on systems that don't support the Olson extension, or don't have the - full zoneinfo tables installed. */ - putenv ((char*) "TZ=PST8PDT,M4.1.0,M10.5.0"); - - tm.tm_year = 98; - tm.tm_mon = 3; - tm.tm_mday = 5; - tm.tm_hour = 2; - tm.tm_min = 0; - tm.tm_sec = 0; - tm.tm_isdst = -1; - return mktime (&tm) != (time_t) -1; -} - -static int -mktime_test1 (time_t now) -{ - struct tm *lt; - return ! (lt = localtime (&now)) || mktime (lt) == now; -} - -static int -mktime_test (time_t now) -{ - return (mktime_test1 (now) - && mktime_test1 ((time_t) (time_t_max - now)) - && mktime_test1 ((time_t) (time_t_min + now))); -} - -static int -irix_6_4_bug () -{ - /* Based on code from Ariel Faigon. */ - struct tm tm; - tm.tm_year = 96; - tm.tm_mon = 3; - tm.tm_mday = 0; - tm.tm_hour = 0; - tm.tm_min = 0; - tm.tm_sec = 0; - tm.tm_isdst = -1; - mktime (&tm); - return tm.tm_mon == 2 && tm.tm_mday == 31; -} - -static int -bigtime_test (int j) -{ - struct tm tm; - time_t now; - tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j; - now = mktime (&tm); - if (now != (time_t) -1) - { - struct tm *lt = localtime (&now); - if (! (lt - && lt->tm_year == tm.tm_year - && lt->tm_mon == tm.tm_mon - && lt->tm_mday == tm.tm_mday - && lt->tm_hour == tm.tm_hour - && lt->tm_min == tm.tm_min - && lt->tm_sec == tm.tm_sec - && lt->tm_yday == tm.tm_yday - && lt->tm_wday == tm.tm_wday - && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst) - == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst)))) - return 0; - } - return 1; -} - -static int -year_2050_test () -{ - /* The correct answer for 2050-02-01 00:00:00 in Pacific time, - ignoring leap seconds. */ - unsigned long int answer = 2527315200UL; - - struct tm tm; - time_t t; - tm.tm_year = 2050 - 1900; - tm.tm_mon = 2 - 1; - tm.tm_mday = 1; - tm.tm_hour = tm.tm_min = tm.tm_sec = 0; - tm.tm_isdst = -1; - - /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0" - instead of "TZ=America/Vancouver" in order to detect the bug even - on systems that don't support the Olson extension, or don't have the - full zoneinfo tables installed. */ - putenv ((char*) "TZ=PST8PDT,M4.1.0,M10.5.0"); - - t = mktime (&tm); - - /* Check that the result is either a failure, or close enough - to the correct answer that we can assume the discrepancy is - due to leap seconds. */ - return (t == (time_t) -1 - || (0 < t && answer - 120 <= t && t <= answer + 120)); -} - +char MD5 (); int main () { - time_t t, delta; - int i, j; - - /* This test makes some buggy mktime implementations loop. - Give up after 60 seconds; a mktime slower than that - isn't worth using anyway. */ - alarm (60); - - for (;;) - { - t = (time_t_max << 1) + 1; - if (t <= time_t_max) - break; - time_t_max = t; - } - time_t_min = - ((time_t) ~ (time_t) 0 == (time_t) -1) - time_t_max; - - delta = time_t_max / 997; /* a suitable prime number */ - for (i = 0; i < N_STRINGS; i++) - { - if (tz_strings[i]) - putenv ((char*) tz_strings[i]); - - for (t = 0; t <= time_t_max - delta; t += delta) - if (! mktime_test (t)) - return 1; - if (! (mktime_test ((time_t) 1) - && mktime_test ((time_t) (60 * 60)) - && mktime_test ((time_t) (60 * 60 * 24)))) - return 1; - - for (j = 1; ; j <<= 1) - if (! bigtime_test (j)) - return 1; - else if (INT_MAX / 2 < j) - break; - if (! bigtime_test (INT_MAX)) - return 1; - } - return ! (irix_6_4_bug () && spring_forward_gap () && year_2050_test ()); +return MD5 (); + ; + return 0; } _ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_func_working_mktime=yes +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_crypto_MD5=yes else - ac_cv_func_working_mktime=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - + ac_cv_lib_crypto_MD5=no fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_working_mktime" >&5 -$as_echo "$ac_cv_func_working_mktime" >&6; } -if test $ac_cv_func_working_mktime = no; then - case " $LIBOBJS " in - *" mktime.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS mktime.$ac_objext" - ;; -esac - +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS fi - - - - - - -for ac_func in getpagesize -do : - ac_fn_c_check_func "$LINENO" "getpagesize" "ac_cv_func_getpagesize" -if test "x$ac_cv_func_getpagesize" = x""yes; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_MD5" >&5 +$as_echo "$ac_cv_lib_crypto_MD5" >&6; } +if test "x$ac_cv_lib_crypto_MD5" = x""yes; then : cat >>confdefs.h <<_ACEOF -#define HAVE_GETPAGESIZE 1 +#define HAVE_LIBCRYPTO 1 _ACEOF + LIBS="-lcrypto $LIBS" + +else + as_fn_error $? "Could not find libcrypto" "$LINENO" 5 fi -done -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working mmap" >&5 -$as_echo_n "checking for working mmap... " >&6; } -if test "${ac_cv_func_mmap_fixed_mapped+set}" = set; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ext2fs_open2 in -lext2fs" >&5 +$as_echo_n "checking for ext2fs_open2 in -lext2fs... " >&6; } +if test "${ac_cv_lib_ext2fs_ext2fs_open2+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test "$cross_compiling" = yes; then : - ac_cv_func_mmap_fixed_mapped=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + ac_check_lib_save_LIBS=$LIBS +LIBS="-lext2fs $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -$ac_includes_default -/* malloc might have been renamed as rpl_malloc. */ -#undef malloc - -/* Thanks to Mike Haertel and Jim Avera for this test. - Here is a matrix of mmap possibilities: - mmap private not fixed - mmap private fixed at somewhere currently unmapped - mmap private fixed at somewhere already mapped - mmap shared not fixed - mmap shared fixed at somewhere currently unmapped - mmap shared fixed at somewhere already mapped - For private mappings, we should verify that changes cannot be read() - back from the file, nor mmap's back from the file at a different - address. (There have been systems where private was not correctly - implemented like the infamous i386 svr4.0, and systems where the - VM page cache was not coherent with the file system buffer cache - like early versions of FreeBSD and possibly contemporary NetBSD.) - For shared mappings, we should conversely verify that changes get - propagated back to all the places they're supposed to be. - - Grep wants private fixed already mapped. - The main things grep needs to know about mmap are: - * does it exist and is it safe to write into the mmap'd area - * how to use it (BSD variants) */ - -#include <fcntl.h> -#include <sys/mman.h> - -#if !defined STDC_HEADERS && !defined HAVE_STDLIB_H -char *malloc (); -#endif - -/* This mess was copied from the GNU getpagesize.h. */ -#ifndef HAVE_GETPAGESIZE -# ifdef _SC_PAGESIZE -# define getpagesize() sysconf(_SC_PAGESIZE) -# else /* no _SC_PAGESIZE */ -# ifdef HAVE_SYS_PARAM_H -# include <sys/param.h> -# ifdef EXEC_PAGESIZE -# define getpagesize() EXEC_PAGESIZE -# else /* no EXEC_PAGESIZE */ -# ifdef NBPG -# define getpagesize() NBPG * CLSIZE -# ifndef CLSIZE -# define CLSIZE 1 -# endif /* no CLSIZE */ -# else /* no NBPG */ -# ifdef NBPC -# define getpagesize() NBPC -# else /* no NBPC */ -# ifdef PAGESIZE -# define getpagesize() PAGESIZE -# endif /* PAGESIZE */ -# endif /* no NBPC */ -# endif /* no NBPG */ -# endif /* no EXEC_PAGESIZE */ -# else /* no HAVE_SYS_PARAM_H */ -# define getpagesize() 8192 /* punt totally */ -# endif /* no HAVE_SYS_PARAM_H */ -# endif /* no _SC_PAGESIZE */ - -#endif /* no HAVE_GETPAGESIZE */ +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char ext2fs_open2 (); int main () { - char *data, *data2, *data3; - const char *cdata2; - int i, pagesize; - int fd, fd2; - - pagesize = getpagesize (); - - /* First, make a file with some known garbage in it. */ - data = (char *) malloc (pagesize); - if (!data) - return 1; - for (i = 0; i < pagesize; ++i) - *(data + i) = rand (); - umask (0); - fd = creat ("conftest.mmap", 0600); - if (fd < 0) - return 2; - if (write (fd, data, pagesize) != pagesize) - return 3; - close (fd); - - /* Next, check that the tail of a page is zero-filled. File must have - non-zero length, otherwise we risk SIGBUS for entire page. */ - fd2 = open ("conftest.txt", O_RDWR | O_CREAT | O_TRUNC, 0600); - if (fd2 < 0) - return 4; - cdata2 = ""; - if (write (fd2, cdata2, 1) != 1) - return 5; - data2 = (char *) mmap (0, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd2, 0L); - if (data2 == MAP_FAILED) - return 6; - for (i = 0; i < pagesize; ++i) - if (*(data2 + i)) - return 7; - close (fd2); - if (munmap (data2, pagesize)) - return 8; - - /* Next, try to mmap the file at a fixed address which already has - something else allocated at it. If we can, also make sure that - we see the same garbage. */ - fd = open ("conftest.mmap", O_RDWR); - if (fd < 0) - return 9; - if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_FIXED, fd, 0L)) - return 10; - for (i = 0; i < pagesize; ++i) - if (*(data + i) != *(data2 + i)) - return 11; - - /* Finally, make sure that changes to the mapped area do not - percolate back to the file as seen by read(). (This is a bug on - some variants of i386 svr4.0.) */ - for (i = 0; i < pagesize; ++i) - *(data2 + i) = *(data2 + i) + 1; - data3 = (char *) malloc (pagesize); - if (!data3) - return 12; - if (read (fd, data3, pagesize) != pagesize) - return 13; - for (i = 0; i < pagesize; ++i) - if (*(data + i) != *(data3 + i)) - return 14; - close (fd); +return ext2fs_open2 (); + ; return 0; } _ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_func_mmap_fixed_mapped=yes +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_ext2fs_ext2fs_open2=yes else - ac_cv_func_mmap_fixed_mapped=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - + ac_cv_lib_ext2fs_ext2fs_open2=no fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_mmap_fixed_mapped" >&5 -$as_echo "$ac_cv_func_mmap_fixed_mapped" >&6; } -if test $ac_cv_func_mmap_fixed_mapped = yes; then - -$as_echo "#define HAVE_MMAP 1" >>confdefs.h - +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS fi -rm -f conftest.mmap conftest.txt - -for ac_header in stdlib.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" -if test "x$ac_cv_header_stdlib_h" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_STDLIB_H 1 -_ACEOF - +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ext2fs_ext2fs_open2" >&5 +$as_echo "$ac_cv_lib_ext2fs_ext2fs_open2" >&6; } +if test "x$ac_cv_lib_ext2fs_ext2fs_open2" = x""yes; then : + libext2fs="y" +else + libext2fs="n" fi -done -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible realloc" >&5 -$as_echo_n "checking for GNU libc compatible realloc... " >&6; } -if test "${ac_cv_func_realloc_0_nonnull+set}" = set; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcry_md_hash_buffer in -lgcrypt" >&5 +$as_echo_n "checking for gcry_md_hash_buffer in -lgcrypt... " >&6; } +if test "${ac_cv_lib_gcrypt_gcry_md_hash_buffer+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test "$cross_compiling" = yes; then : - ac_cv_func_realloc_0_nonnull=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + ac_check_lib_save_LIBS=$LIBS +LIBS="-lgcrypt $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#if defined STDC_HEADERS || defined HAVE_STDLIB_H -# include <stdlib.h> -#else -char *realloc (); -#endif +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char gcry_md_hash_buffer (); int main () { -return ! realloc (0, 0); +return gcry_md_hash_buffer (); ; return 0; } _ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_func_realloc_0_nonnull=yes +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_gcrypt_gcry_md_hash_buffer=yes else - ac_cv_func_realloc_0_nonnull=no + ac_cv_lib_gcrypt_gcry_md_hash_buffer=no fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS fi - +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gcrypt_gcry_md_hash_buffer" >&5 +$as_echo "$ac_cv_lib_gcrypt_gcry_md_hash_buffer" >&6; } +if test "x$ac_cv_lib_gcrypt_gcry_md_hash_buffer" = x""yes; then : + libgcrypt="y" +else + libgcrypt="n" fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_realloc_0_nonnull" >&5 -$as_echo "$ac_cv_func_realloc_0_nonnull" >&6; } -if test $ac_cv_func_realloc_0_nonnull = yes; then : -$as_echo "#define HAVE_REALLOC 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread flag" >&5 +$as_echo_n "checking for pthread flag... " >&6; } +if test "${ax_cv_pthread_flags+set}" = set; then : + $as_echo_n "(cached) " >&6 else - $as_echo "#define HAVE_REALLOC 0" >>confdefs.h - case " $LIBOBJS " in - *" realloc.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS realloc.$ac_objext" - ;; -esac + ax_cv_pthread_flags=-pthread + + PTHREAD_CFLAGS="$ax_cv_pthread_flags" + PTHREAD_LDFLAGS="$ax_cv_pthread_flags" + PTHREAD_LIBS="" + + + saved_CFLAGS="$CFLAGS" + + saved_LDFLAGS="$LDFLAGS" + + saved_LIBS="$LIBS" + + + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + + LDFLAGS="$LDFLAGS $PTHREAD_LDFLAGS" + + LIBS="$LIBS $PTHREAD_LIBS" + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include <pthread.h> +int main(void) { + pthread_atfork(0,0,0); + pthread_create(0,0,0,0); +} + +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + +else + ax_cv_pthread_flags=failed +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + + CFLAGS="$saved_CFLAGS" + + LDFLAGS="$saved_LDFLAGS" + LIBS="$saved_LIBS" -$as_echo "#define realloc rpl_realloc" >>confdefs.h fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_pthread_flags" >&5 +$as_echo "$ax_cv_pthread_flags" >&6; } + if test "x$ax_cv_pthread_flags" = xfailed; then + as_fn_error $? "-pthread does not work" "$LINENO" 5 + fi + + PTHREAD_CFLAGS="$ax_cv_pthread_flags" + PTHREAD_LDFLAGS="$ax_cv_pthread_flags" + PTHREAD_LIBS="" + -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working strnlen" >&5 -$as_echo_n "checking for working strnlen... " >&6; } -if test "${ac_cv_func_strnlen_working+set}" = set; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for yajl_alloc in -lyajl" >&5 +$as_echo_n "checking for yajl_alloc in -lyajl... " >&6; } +if test "${ac_cv_lib_yajl_yajl_alloc+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test "$cross_compiling" = yes; then : - ac_cv_func_strnlen_working=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + ac_check_lib_save_LIBS=$LIBS +LIBS="-lyajl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -$ac_includes_default + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char yajl_alloc (); int main () { - -#define S "foobar" -#define S_LEN (sizeof S - 1) - - /* At least one implementation is buggy: that of AIX 4.3 would - give strnlen (S, 1) == 3. */ - - int i; - for (i = 0; i < S_LEN + 1; ++i) - { - int expected = i <= S_LEN ? i : S_LEN; - if (strnlen (S, i) != expected) - return 1; - } - return 0; - +return yajl_alloc (); ; return 0; } _ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_func_strnlen_working=yes +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_yajl_yajl_alloc=yes else - ac_cv_func_strnlen_working=no + ac_cv_lib_yajl_yajl_alloc=no fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_yajl_yajl_alloc" >&5 +$as_echo "$ac_cv_lib_yajl_yajl_alloc" >&6; } +if test "x$ac_cv_lib_yajl_yajl_alloc" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBYAJL 1 +_ACEOF -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_strnlen_working" >&5 -$as_echo "$ac_cv_func_strnlen_working" >&6; } -test $ac_cv_func_strnlen_working = no && case " $LIBOBJS " in - *" strnlen.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS strnlen.$ac_objext" - ;; -esac + LIBS="-lyajl $LIBS" +else + as_fn_error $? "Could not find yajl" "$LINENO" 5 +fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working strtod" >&5 -$as_echo_n "checking for working strtod... " >&6; } -if test "${ac_cv_func_strtod+set}" = set; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for deflateCopy in -lz" >&5 +$as_echo_n "checking for deflateCopy in -lz... " >&6; } +if test "${ac_cv_lib_z_deflateCopy+set}" = set; then : $as_echo_n "(cached) " >&6 else - if test "$cross_compiling" = yes; then : - ac_cv_func_strtod=no -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + ac_check_lib_save_LIBS=$LIBS +LIBS="-lz $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -$ac_includes_default -#ifndef strtod -double strtod (); +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" #endif +char deflateCopy (); int -main() +main () { - { - /* Some versions of Linux strtod mis-parse strings with leading '+'. */ - char *string = " +69"; - char *term; - double value; - value = strtod (string, &term); - if (value != 69 || term != (string + 4)) - return 1; - } - - { - /* Under Solaris 2.4, strtod returns the wrong value for the - terminating character under some conditions. */ - char *string = "NaN"; - char *term; - strtod (string, &term); - if (term != string && *(term - 1) == 0) - return 1; - } +return deflateCopy (); + ; return 0; } - _ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_func_strtod=yes +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_z_deflateCopy=yes else - ac_cv_func_strtod=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext + ac_cv_lib_z_deflateCopy=no fi - +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_strtod" >&5 -$as_echo "$ac_cv_func_strtod" >&6; } -if test $ac_cv_func_strtod = no; then - case " $LIBOBJS " in - *" strtod.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS strtod.$ac_objext" - ;; -esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_deflateCopy" >&5 +$as_echo "$ac_cv_lib_z_deflateCopy" >&6; } +if test "x$ac_cv_lib_z_deflateCopy" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBZ 1 +_ACEOF -ac_fn_c_check_func "$LINENO" "pow" "ac_cv_func_pow" -if test "x$ac_cv_func_pow" = x""yes; then : + LIBS="-lz $LIBS" +else + as_fn_error $? "Could not find zlib" "$LINENO" 5 fi -if test $ac_cv_func_pow = no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pow in -lm" >&5 -$as_echo_n "checking for pow in -lm... " >&6; } -if test "${ac_cv_lib_m_pow+set}" = set; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libiconv_open in -liconv" >&5 +$as_echo_n "checking for libiconv_open in -liconv... " >&6; } +if test "${ac_cv_lib_iconv_libiconv_open+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS -LIBS="-lm $LIBS" +LIBS="-liconv $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -9528,55 +6553,45 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #ifdef __cplusplus extern "C" #endif -char pow (); +char libiconv_open (); int main () { -return pow (); +return libiconv_open (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_m_pow=yes + ac_cv_lib_iconv_libiconv_open=yes else - ac_cv_lib_m_pow=no + ac_cv_lib_iconv_libiconv_open=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_pow" >&5 -$as_echo "$ac_cv_lib_m_pow" >&6; } -if test "x$ac_cv_lib_m_pow" = x""yes; then : - POW_LIB=-lm +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_iconv_libiconv_open" >&5 +$as_echo "$ac_cv_lib_iconv_libiconv_open" >&6; } +if test "x$ac_cv_lib_iconv_libiconv_open" = x""yes; then : + libiconv="y" else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot find library containing definition of pow" >&5 -$as_echo "$as_me: WARNING: cannot find library containing definition of pow" >&2;} -fi - + libiconv="n" fi -fi -for ac_func in \ - alarm atexit bzero clock_gettime dup2 fdatasync ftruncate \ - getcwd gethostbyname gethostname getpagesize gettimeofday \ - inet_ntoa isascii localtime_r memchr memmove memset mkdir \ - mkfifo munmap pathconf realpath regcomp rmdir select setenv \ - socket strcasecmp strchr strcspn strdup strerror strndup \ - strpbrk strrchr strspn strstr strtol strtoul strtoull tzset \ - uname \ +# Checks for header files. +for ac_header in yajl/yajl_version.h do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + ac_fn_c_check_header_mongrel "$LINENO" "yajl/yajl_version.h" "ac_cv_header_yajl_yajl_version_h" "$ac_includes_default" +if test "x$ac_cv_header_yajl_yajl_version_h" = x""yes; then : cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +#define HAVE_YAJL_YAJL_VERSION_H 1 _ACEOF fi + done diff --git a/tools/configure.ac b/tools/configure.ac index 57c887d..deb848d 100644 --- a/tools/configure.ac +++ b/tools/configure.ac @@ -19,9 +19,6 @@ recommended, use PREPEND_INCLUDES, PREPEND_LIB, \ APPEND_INCLUDES and APPEND_LIB instead when possible.]) ]) -AC_USE_SYSTEM_EXTENSIONS -AC_CANONICAL_HOST - # M4 Macro includes m4_include([m4/savevar.m4]) m4_include([m4/features.m4]) @@ -75,9 +72,7 @@ AC_ARG_VAR([BCC], [Path to bcc tool]) AC_ARG_VAR([IASL], [Path to iasl tool]) # Checks for programs. -AC_PROG_SED AC_PROG_CC -AC_PROG_LN_S AC_PROG_MAKE_SET AC_PROG_INSTALL AC_PATH_PROG([BISON], [bison]) @@ -137,7 +132,6 @@ AC_SUBST(libext2fs) AC_CHECK_LIB([gcrypt], [gcry_md_hash_buffer], [libgcrypt="y"], [libgcrypt="n"]) AC_SUBST(libgcrypt) AX_CHECK_PTHREAD -AC_CHECK_LIB([rt], [clock_gettime]) AC_CHECK_LIB([yajl], [yajl_alloc], [], [AC_MSG_ERROR([Could not find yajl])]) AC_CHECK_LIB([z], [deflateCopy], [], [AC_MSG_ERROR([Could not find zlib])]) @@ -145,58 +139,6 @@ AC_CHECK_LIB([iconv], [libiconv_open], [libiconv="y"], [libiconv="n"]) AC_SUBST(libiconv) # Checks for header files. -AC_FUNC_ALLOCA -AC_CHECK_HEADERS([ \ - arpa/inet.h fcntl.h inttypes.h libintl.h limits.h malloc.h \ - netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h \ - strings.h sys/file.h sys/ioctl.h sys/mount.h sys/param.h \ - sys/socket.h sys/statvfs.h sys/time.h syslog.h termios.h \ - unistd.h yajl/yajl_version.h \ - ]) - -# Checks for typedefs, structures, and compiler characteristics. -AC_HEADER_STDBOOL -AC_TYPE_UID_T -AC_C_INLINE -AC_TYPE_INT16_T -AC_TYPE_INT32_T -AC_TYPE_INT64_T -AC_TYPE_INT8_T -AC_TYPE_MODE_T -AC_TYPE_OFF_T -AC_TYPE_PID_T -AC_C_RESTRICT -AC_TYPE_SIZE_T -AC_TYPE_SSIZE_T -AC_CHECK_MEMBERS([struct stat.st_blksize]) -AC_STRUCT_ST_BLOCKS -AC_CHECK_MEMBERS([struct stat.st_rdev]) -AC_TYPE_UINT16_T -AC_TYPE_UINT32_T -AC_TYPE_UINT64_T -AC_TYPE_UINT8_T -AC_CHECK_TYPES([ptrdiff_t]) - -# Checks for library functions. -AC_FUNC_ERROR_AT_LINE -AC_FUNC_FORK -AC_FUNC_FSEEKO -AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK -AC_HEADER_MAJOR -AC_FUNC_MALLOC -AC_FUNC_MKTIME -AC_FUNC_MMAP -AC_FUNC_REALLOC -AC_FUNC_STRNLEN -AC_FUNC_STRTOD -AC_CHECK_FUNCS([ \ - alarm atexit bzero clock_gettime dup2 fdatasync ftruncate \ - getcwd gethostbyname gethostname getpagesize gettimeofday \ - inet_ntoa isascii localtime_r memchr memmove memset mkdir \ - mkfifo munmap pathconf realpath regcomp rmdir select setenv \ - socket strcasecmp strchr strcspn strdup strerror strndup \ - strpbrk strrchr strspn strstr strtol strtoul strtoull tzset \ - uname \ - ]) +AC_CHECK_HEADERS([yajl/yajl_version.h]) AC_OUTPUT() -- 1.7.2.5 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
We may need to #include <libutil.h>, and/or link with -lutil, to use openpty, login_tty, and the like. Provide INCLUDE_LIBUTIL_H (preprocessor constant, not always defined) and PTYFUNCS_LIBS (makefile variable). We link libxl against PTYFUNCS_LIBS (which comes from autoconf) rather than UTIL_LIBS, and #include <libutil.h> where appropriate. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Changes since v7: * Actually include the call to AX_CHECK_PTYFUNCS in this patch, not the previous one, and regenerate configure accordingly. Changes since v6: * Put failure macro call in correct place so it might actually happen. * Try both with -lutil and without. * Patch now contains update for config.h.in. --- config/Tools.mk.in | 2 + tools/config.h.in | 3 ++ tools/configure | 61 ++++++++++++++++++++++++++++++++++++++++ tools/configure.ac | 2 + tools/libxl/Makefile | 2 +- tools/libxl/libxl_bootloader.c | 4 ++ tools/m4/ptyfuncs.m4 | 28 ++++++++++++++++++ 7 files changed, 101 insertions(+), 1 deletions(-) create mode 100644 tools/m4/ptyfuncs.m4 diff --git a/config/Tools.mk.in b/config/Tools.mk.in index ee6cda3..5b80359 100644 --- a/config/Tools.mk.in +++ b/config/Tools.mk.in @@ -30,6 +30,8 @@ PTHREAD_CFLAGS := @PTHREAD_CFLAGS@ PTHREAD_LDFLAGS := @PTHREAD_LDFLAGS@ PTHREAD_LIBS := @PTHREAD_LIBS@ +PTYFUNCS_LIBS := @PTYFUNCS_LIBS@ + # Download GIT repositories via HTTP or GIT''s own protocol? # GIT''s protocol is faster and more robust, when it works at all (firewalls # may block it). We make it the default, but if your GIT repository downloads diff --git a/tools/config.h.in b/tools/config.h.in index 17c8913..bc1ed10 100644 --- a/tools/config.h.in +++ b/tools/config.h.in @@ -42,6 +42,9 @@ /* Define curses header to use */ #undef INCLUDE_CURSES_H +/* libutil header file name */ +#undef INCLUDE_LIBUTIL_H + /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT diff --git a/tools/configure b/tools/configure index d8918fe..be7feb6 100755 --- a/tools/configure +++ b/tools/configure @@ -598,6 +598,7 @@ ac_includes_default="\ ac_subst_vars=''LTLIBOBJS LIBOBJS libiconv +PTYFUNCS_LIBS PTHREAD_LIBS PTHREAD_LDFLAGS PTHREAD_CFLAGS @@ -2308,6 +2309,8 @@ fi + + # Enable/disable options # Check whether --enable-githttp was given. @@ -6443,6 +6446,64 @@ $as_echo "$ax_cv_pthread_flags" >&6; } + + ac_fn_c_check_header_mongrel "$LINENO" "libutil.h" "ac_cv_header_libutil_h" "$ac_includes_default" +if test "x$ac_cv_header_libutil_h" = x""yes; then : + + +$as_echo "#define INCLUDE_LIBUTIL_H <libutil.h>" >>confdefs.h + + +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for openpty et al" >&5 +$as_echo_n "checking for openpty et al... " >&6; } +if test "${ax_cv_ptyfuncs_libs+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + + for ax_cv_ptyfuncs_libs in -lutil "" NOT_FOUND; do + if test "x$ax_cv_ptyfuncs_libs" = "xNOT_FOUND"; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd'':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd'':" >&2;} +as_fn_error $? "Unable to find library for openpty and login_tty +See \`config.log'' for more details" "$LINENO" 5 ; } + fi + + saved_LIBS="$LIBS" + + LIBS="$LIBS $ax_cv_ptyfuncs_libs" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef INCLUDE_LIBUTIL_H +#include INCLUDE_LIBUTIL_H +#endif +int main(void) { + openpty(0,0,0,0,0); + login_tty(0); +} + +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + + break + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + + LIBS="$saved_LIBS" + + done + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_ptyfuncs_libs" >&5 +$as_echo "$ax_cv_ptyfuncs_libs" >&6; } + PTYFUNCS_LIBS="$ax_cv_ptyfuncs_libs" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for yajl_alloc in -lyajl" >&5 $as_echo_n "checking for yajl_alloc in -lyajl... " >&6; } if test "${ac_cv_lib_yajl_yajl_alloc+set}" = set; then : diff --git a/tools/configure.ac b/tools/configure.ac index deb848d..4e9cb03 100644 --- a/tools/configure.ac +++ b/tools/configure.ac @@ -32,6 +32,7 @@ m4_include([m4/uuid.m4]) m4_include([m4/pkg.m4]) m4_include([m4/curses.m4]) m4_include([m4/pthread.m4]) +m4_include([m4/ptyfuncs.m4]) # Enable/disable options AX_ARG_DEFAULT_DISABLE([githttp], [Download GIT repositories via HTTP]) @@ -132,6 +133,7 @@ AC_SUBST(libext2fs) AC_CHECK_LIB([gcrypt], [gcry_md_hash_buffer], [libgcrypt="y"], [libgcrypt="n"]) AC_SUBST(libgcrypt) AX_CHECK_PTHREAD +AX_CHECK_PTYFUNCS AC_CHECK_LIB([yajl], [yajl_alloc], [], [AC_MSG_ERROR([Could not find yajl])]) AC_CHECK_LIB([z], [deflateCopy], [], [AC_MSG_ERROR([Could not find zlib])]) diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile index 5469454..1261d43 100644 --- a/tools/libxl/Makefile +++ b/tools/libxl/Makefile @@ -20,7 +20,7 @@ LIBUUID_LIBS += -luuid endif LIBXL_LIBS -LIBXL_LIBS = $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore) $(LDLIBS_libblktapctl) $(UTIL_LIBS) $(LIBUUID_LIBS) +LIBXL_LIBS = $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore) $(LDLIBS_libblktapctl) $(PTYFUNCS_LIBS) $(LIBUUID_LIBS) CFLAGS += $(PTHREAD_CFLAGS) LDFLAGS += $(PTHREAD_LDFLAGS) diff --git a/tools/libxl/libxl_bootloader.c b/tools/libxl/libxl_bootloader.c index 2774062..b50944a 100644 --- a/tools/libxl/libxl_bootloader.c +++ b/tools/libxl/libxl_bootloader.c @@ -16,6 +16,10 @@ #include <termios.h> +#ifdef INCLUDE_LIBUTIL_H +#include INCLUDE_LIBUTIL_H +#endif + #include "libxl_internal.h" #define XENCONSOLED_BUF_SIZE 16 diff --git a/tools/m4/ptyfuncs.m4 b/tools/m4/ptyfuncs.m4 new file mode 100644 index 0000000..7581704 --- /dev/null +++ b/tools/m4/ptyfuncs.m4 @@ -0,0 +1,28 @@ +AC_DEFUN([AX_CHECK_PTYFUNCS], [ + AC_CHECK_HEADER([libutil.h],[ + AC_DEFINE([INCLUDE_LIBUTIL_H],[<libutil.h>],[libutil header file name]) + ]) + AC_CACHE_CHECK([for openpty et al], [ax_cv_ptyfuncs_libs], [ + for ax_cv_ptyfuncs_libs in -lutil "" NOT_FOUND; do + if test "x$ax_cv_ptyfuncs_libs" = "xNOT_FOUND"; then + AC_MSG_FAILURE([Unable to find library for openpty and login_tty]) + fi + AX_SAVEVAR_SAVE(LIBS) + LIBS="$LIBS $ax_cv_ptyfuncs_libs" + AC_LINK_IFELSE([ +#ifdef INCLUDE_LIBUTIL_H +#include INCLUDE_LIBUTIL_H +#endif +int main(void) { + openpty(0,0,0,0,0); + login_tty(0); +} +],[ + break + ],[]) + AX_SAVEVAR_RESTORE(LIBS) + done + ]) + PTYFUNCS_LIBS="$ax_cv_ptyfuncs_libs" + AC_SUBST(PTYFUNCS_LIBS) +]) -- 1.7.2.5
These utility functions cope with EINTR AND ENOENT, do error logging, and we provide a recursive version to delete whole directory trees. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> --- tools/libxl/libxl_internal.h | 7 ++++ tools/libxl/libxl_utils.c | 79 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 0 deletions(-) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index d04e856..909e01f 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -433,6 +433,13 @@ _hidden char *libxl__strndup(libxl__gc *gc_opt, const char *c, size_t n); * string. (similar to a gc''d dirname(3)). */ _hidden char *libxl__dirname(libxl__gc *gc_opt, const char *s); +/* Each of these logs errors and returns a libxl error code. + * They do not mind if path is already removed. + * For _file, path must not be a directory; for _directory it must be. */ +_hidden int libxl__remove_file(libxl__gc *gc, const char *path); +_hidden int libxl__remove_directory(libxl__gc *gc, const char *path); +_hidden int libxl__remove_file_or_directory(libxl__gc *gc, const char *path); + _hidden char **libxl__xs_kvs_of_flexarray(libxl__gc *gc, flexarray_t *array, int length); _hidden int libxl__xs_writev(libxl__gc *gc, xs_transaction_t t, diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c index 0cbd85e..1a4874c 100644 --- a/tools/libxl/libxl_utils.c +++ b/tools/libxl/libxl_utils.c @@ -364,6 +364,85 @@ int libxl_read_file_contents(libxl_ctx *ctx, const char *filename, READ_WRITE_EXACTLY(read, 1, /* */) READ_WRITE_EXACTLY(write, 0, const) +int libxl__remove_file(libxl__gc *gc, const char *path) +{ + for (;;) { + int r = unlink(path); + if (!r) return 0; + if (errno == ENOENT) return 0; + if (errno == EINTR) continue; + LOGE(ERROR, "failed to remove file %s", path); + return ERROR_FAIL; + } +} + +int libxl__remove_file_or_directory(libxl__gc *gc, const char *path) +{ + for (;;) { + int r = rmdir(path); + if (!r) return 0; + if (errno == ENOENT) return 0; + if (errno == ENOTEMPTY) return libxl__remove_directory(gc, path); + if (errno == ENOTDIR) return libxl__remove_file(gc, path); + if (errno == EINTR) continue; + LOGE(ERROR, "failed to remove %s", path); + return ERROR_FAIL; + } +} + +int libxl__remove_directory(libxl__gc *gc, const char *dirpath) +{ + int rc = 0; + DIR *d = 0; + + d = opendir(dirpath); + if (!d) { + if (errno == ENOENT) + goto out; + + LOGE(ERROR, "failed to opendir %s for removal", dirpath); + rc = ERROR_FAIL; + goto out; + } + + size_t need = offsetof(struct dirent, d_name) + + pathconf(dirpath, _PC_NAME_MAX) + 1; + struct dirent *de_buf = libxl__zalloc(gc, need); + struct dirent *de; + + for (;;) { + int r = readdir_r(d, de_buf, &de); + if (r) { + LOGE(ERROR, "failed to readdir %s for removal", dirpath); + rc = ERROR_FAIL; + break; + } + if (!de) + break; + + if (!strcmp(de->d_name, ".") || + !strcmp(de->d_name, "..")) + continue; + + const char *subpath = GCSPRINTF("%s/%s", dirpath, de->d_name); + if (libxl__remove_file_or_directory(gc, subpath)) + rc = ERROR_FAIL; + } + + for (;;) { + int r = rmdir(dirpath); + if (!r) break; + if (errno == ENOENT) goto out; + if (errno == EINTR) continue; + LOGE(ERROR, "failed to remove emptied directory %s", dirpath); + rc = ERROR_FAIL; + } + + out: + if (d) closedir(d); + + return rc; +} pid_t libxl_fork(libxl_ctx *ctx) { -- 1.7.2.5
Ian Jackson
2012-May-11 17:57 UTC
[PATCH 07/27] libxl: Introduce libxl__sendmsg_fds and libxl__recvmsg_fds
Provide functions for sending and receiving fds. There used to be fd-sending functionality in libxl_qmp.c before 25298:84ae90427c54, which this implementation is partially derived from. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> --- tools/libxl/libxl_internal.h | 11 ++++ tools/libxl/libxl_utils.c | 104 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+), 0 deletions(-) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 909e01f..e25569c 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1135,6 +1135,17 @@ _hidden void libxl__qmp_cleanup(libxl__gc *gc, uint32_t domid); _hidden int libxl__qmp_initializations(libxl__gc *gc, uint32_t domid, const libxl_domain_config *guest_config); +/* on failure, logs */ +int libxl__sendmsg_fds(libxl__gc *gc, int carrier, + const void *data, size_t datalen, + int nfds, const int fds[], const char *what); + +/* Insists on receiving exactly nfds and datalen. On failure, logs + * and leaves *fds untouched. */ +int libxl__recvmsg_fds(libxl__gc *gc, int carrier, + void *databuf, size_t datalen, + int nfds, int fds[], const char *what); + /* from libxl_json */ #include <yajl/yajl_gen.h> diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c index 1a4874c..19b4615 100644 --- a/tools/libxl/libxl_utils.c +++ b/tools/libxl/libxl_utils.c @@ -579,6 +579,110 @@ void libxl_cputopology_list_free(libxl_cputopology *list, int nr) free(list); } +int libxl__sendmsg_fds(libxl__gc *gc, int carrier, + const void *data, size_t datalen, + int nfds, const int fds[], const char *what) { + struct msghdr msg = { 0 }; + struct cmsghdr *cmsg; + size_t spaceneeded = nfds * sizeof(fds[0]); + char control[CMSG_SPACE(spaceneeded)]; + struct iovec iov; + int r; + + iov.iov_base = (void*)data; + iov.iov_len = datalen; + + /* compose the message */ + msg.msg_iov = &iov; + msg.msg_iovlen = 1; + msg.msg_control = control; + msg.msg_controllen = sizeof(control); + + /* attach open fd */ + cmsg = CMSG_FIRSTHDR(&msg); + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = SCM_RIGHTS; + cmsg->cmsg_len = CMSG_LEN(spaceneeded); + memcpy(CMSG_DATA(cmsg), fds, spaceneeded); + + msg.msg_controllen = cmsg->cmsg_len; + + r = sendmsg(carrier, &msg, 0); + if (r < 0) { + LOGE(ERROR, "failed to send fd-carrying message (%s)", what); + return ERROR_FAIL; + } + + return 0; +} + +int libxl__recvmsg_fds(libxl__gc *gc, int carrier, + void *databuf, size_t datalen, + int nfds, int fds[], const char *what) +{ + struct msghdr msg = { 0 }; + struct cmsghdr *cmsg; + size_t spaceneeded = nfds * sizeof(fds[0]); + char control[CMSG_SPACE(spaceneeded)]; + struct iovec iov; + int r; + + iov.iov_base = databuf; + iov.iov_len = datalen; + + msg.msg_iov = &iov; + msg.msg_iovlen = 1; + msg.msg_control = control; + msg.msg_controllen = sizeof(control); + + for (;;) { + r = recvmsg(carrier, &msg, 0); + if (r < 0) { + if (errno == EINTR) continue; + if (errno == EWOULDBLOCK) return -1; + LOGE(ERROR,"recvmsg failed (%s)", what); + return ERROR_FAIL; + } + if (r == 0) { + LOG(ERROR,"recvmsg got EOF (%s)", what); + return ERROR_FAIL; + } + cmsg = CMSG_FIRSTHDR(&msg); + if (cmsg->cmsg_len <= CMSG_LEN(0)) { + LOG(ERROR,"recvmsg got no control msg" + " when expecting fds (%s)", what); + return ERROR_FAIL; + } + if (cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS) { + LOG(ERROR, "recvmsg got unexpected" + " cmsg_level %d (!=%d) or _type %d (!=%d) (%s)", + cmsg->cmsg_level, SOL_SOCKET, + cmsg->cmsg_type, SCM_RIGHTS, + what); + return ERROR_FAIL; + } + if (cmsg->cmsg_len != CMSG_LEN(spaceneeded) || + msg.msg_controllen != cmsg->cmsg_len) { + LOG(ERROR, "recvmsg got unexpected" + " number of fds or extra control data" + " (%ld bytes'' worth, expected %ld) (%s)", + (long)CMSG_LEN(spaceneeded), (long)cmsg->cmsg_len, + what); + int i, fd; + unsigned char *p; + for (i=0, p=CMSG_DATA(cmsg); + CMSG_SPACE(i * sizeof(fds[0])); + i++, i+=sizeof(fd)) { + memcpy(&fd, p, sizeof(fd)); + close(fd); + } + return ERROR_FAIL; + } + memcpy(fds, CMSG_DATA(cmsg), spaceneeded); + return 0; + } +} + void libxl_dominfo_list_free(libxl_dominfo *list, int nr) { int i; -- 1.7.2.5
Ian Jackson
2012-May-11 17:57 UTC
[PATCH 08/27] libxl: Clean up setdefault in do_domain_create
do_domain_create called libxl__domain_create_info_setdefault twice. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <Ian.Campbell@citrix.com> --- tools/libxl/libxl_create.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 6df20ca..d501102 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -573,9 +573,6 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config, ret = libxl__domain_create_info_setdefault(gc, &d_config->c_info); if (ret) goto error_out; - ret = libxl__domain_create_info_setdefault(gc, &d_config->c_info); - if (ret) goto error_out; - ret = libxl__domain_make(gc, &d_config->c_info, &domid); if (ret) { LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot make domain: %d", ret); -- 1.7.2.5
General facility for ao operations to shovel data between fds. This will be used by the bootloader machinery. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Changes in v7: * assert that the ao is non-null on _init. --- tools/libxl/Makefile | 3 +- tools/libxl/libxl_aoutils.c | 189 ++++++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_internal.h | 40 +++++++++ 3 files changed, 231 insertions(+), 1 deletions(-) create mode 100644 tools/libxl/libxl_aoutils.c diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile index 1261d43..5d9227e 100644 --- a/tools/libxl/Makefile +++ b/tools/libxl/Makefile @@ -64,7 +64,8 @@ LIBXL_LIBS += -lyajl LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \ libxl_dom.o libxl_exec.o libxl_xshelp.o libxl_device.o \ - libxl_internal.o libxl_utils.o libxl_uuid.o libxl_json.o \ + libxl_internal.o libxl_utils.o libxl_uuid.o \ + libxl_json.o libxl_aoutils.o \ libxl_qmp.o libxl_event.o libxl_fork.o $(LIBXL_OBJS-y) LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o diff --git a/tools/libxl/libxl_aoutils.c b/tools/libxl/libxl_aoutils.c new file mode 100644 index 0000000..4c60ad9 --- /dev/null +++ b/tools/libxl/libxl_aoutils.c @@ -0,0 +1,189 @@ +/* + * Copyright (C) 2010 Citrix Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; version 2.1 only. with the special + * exception on linking described in file LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +#include "libxl_osdeps.h" /* must come before any other headers */ + +#include "libxl_internal.h" + +/*----- data copier -----*/ + +void libxl__datacopier_init(libxl__datacopier_state *dc) +{ + assert(dc->ao); + libxl__ev_fd_init(&dc->toread); + libxl__ev_fd_init(&dc->towrite); + LIBXL_TAILQ_INIT(&dc->bufs); +} + +void libxl__datacopier_kill(libxl__datacopier_state *dc) +{ + STATE_AO_GC(dc->ao); + libxl__datacopier_buf *buf, *tbuf; + + libxl__ev_fd_deregister(gc, &dc->toread); + libxl__ev_fd_deregister(gc, &dc->towrite); + LIBXL_TAILQ_FOREACH_SAFE(buf, &dc->bufs, entry, tbuf) + free(buf); + LIBXL_TAILQ_INIT(&dc->bufs); +} + +static void datacopier_callback(libxl__egc *egc, libxl__datacopier_state *dc, + int onwrite, int errnoval) +{ + libxl__datacopier_kill(dc); + dc->callback(egc, dc, onwrite, errnoval); +} + +static void datacopier_writable(libxl__egc *egc, libxl__ev_fd *ev, + int fd, short events, short revents); + +static void datacopier_check_state(libxl__egc *egc, libxl__datacopier_state *dc) +{ + STATE_AO_GC(dc->ao); + int rc; + + if (dc->used) { + if (!libxl__ev_fd_isregistered(&dc->towrite)) { + rc = libxl__ev_fd_register(gc, &dc->towrite, datacopier_writable, + dc->writefd, POLLOUT); + if (rc) { + LOG(ERROR, "unable to establish write event on %s" + " during copy of %s", dc->writewhat, dc->copywhat); + datacopier_callback(egc, dc, -1, 0); + return; + } + } + } else if (!libxl__ev_fd_isregistered(&dc->toread)) { + /* we have had eof */ + datacopier_callback(egc, dc, 0, 0); + return; + } else { + /* nothing buffered, but still reading */ + libxl__ev_fd_deregister(gc, &dc->towrite); + } +} + +static void datacopier_readable(libxl__egc *egc, libxl__ev_fd *ev, + int fd, short events, short revents) { + libxl__datacopier_state *dc = CONTAINER_OF(ev, *dc, toread); + STATE_AO_GC(dc->ao); + + if (revents & ~POLLIN) { + LOG(ERROR, "unexpected poll event 0x%x (should be POLLIN)" + " on %s during copy of %s", revents, dc->readwhat, dc->copywhat); + datacopier_callback(egc, dc, -1, 0); + return; + } + assert(revents & POLLIN); + for (;;) { + while (dc->used >= dc->maxsz) { + libxl__datacopier_buf *rm = LIBXL_TAILQ_FIRST(&dc->bufs); + dc->used -= rm->used; + assert(dc->used >= 0); + LIBXL_TAILQ_REMOVE(&dc->bufs, rm, entry); + free(rm); + } + + libxl__datacopier_buf *buf + LIBXL_TAILQ_LAST(&dc->bufs, libxl__datacopier_bufs); + if (!buf || buf->used >= sizeof(buf->buf)) { + buf = malloc(sizeof(*buf)); + if (!buf) libxl__alloc_failed(CTX, __func__, 1, sizeof(*buf)); + buf->used = 0; + LIBXL_TAILQ_INSERT_TAIL(&dc->bufs, buf, entry); + } + int r = read(ev->fd, + buf->buf + buf->used, + sizeof(buf->buf) - buf->used); + if (r < 0) { + if (errno == EINTR) continue; + if (errno == EWOULDBLOCK) break; + LOGE(ERROR, "error reading %s during copy of %s", + dc->readwhat, dc->copywhat); + datacopier_callback(egc, dc, 0, errno); + return; + } + if (r == 0) { + libxl__ev_fd_deregister(gc, &dc->toread); + break; + } + buf->used += r; + dc->used += r; + assert(buf->used <= sizeof(buf->buf)); + } + datacopier_check_state(egc, dc); +} + +static void datacopier_writable(libxl__egc *egc, libxl__ev_fd *ev, + int fd, short events, short revents) { + libxl__datacopier_state *dc = CONTAINER_OF(ev, *dc, towrite); + STATE_AO_GC(dc->ao); + + if (revents & ~POLLOUT) { + LOG(ERROR, "unexpected poll event 0x%x (should be POLLOUT)" + " on %s during copy of %s", revents, dc->writewhat, dc->copywhat); + datacopier_callback(egc, dc, -1, 0); + return; + } + assert(revents & POLLOUT); + for (;;) { + libxl__datacopier_buf *buf = LIBXL_TAILQ_FIRST(&dc->bufs); + if (!buf) + break; + if (!buf->used) { + LIBXL_TAILQ_REMOVE(&dc->bufs, buf, entry); + free(buf); + continue; + } + int r = write(ev->fd, buf->buf, buf->used); + if (r < 0) { + if (errno == EINTR) continue; + if (errno == EWOULDBLOCK) break; + LOGE(ERROR, "error writing to %s during copy of %s", + dc->writewhat, dc->copywhat); + datacopier_callback(egc, dc, 1, errno); + return; + } + assert(r > 0); + assert(r <= buf->used); + buf->used -= r; + dc->used -= r; + assert(dc->used >= 0); + memmove(buf->buf, buf->buf+r, buf->used); + } + datacopier_check_state(egc, dc); +} + +int libxl__datacopier_start(libxl__datacopier_state *dc) +{ + int rc; + STATE_AO_GC(dc->ao); + + libxl__datacopier_init(dc); + + rc = libxl__ev_fd_register(gc, &dc->toread, datacopier_readable, + dc->readfd, POLLIN); + if (rc) goto out; + + rc = libxl__ev_fd_register(gc, &dc->towrite, datacopier_writable, + dc->writefd, POLLOUT); + if (rc) goto out; + + return 0; + + out: + libxl__datacopier_kill(dc); + return rc; +} + diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index e25569c..be11fbd 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -840,6 +840,7 @@ _hidden int libxl__ev_devstate_wait(libxl__gc *gc, libxl__ev_devstate *ds, */ _hidden int libxl__try_phy_backend(mode_t st_mode); + /* from libxl_pci */ _hidden int libxl__device_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev, int starting); @@ -1473,6 +1474,45 @@ _hidden const char *libxl__xen_script_dir_path(void); _hidden const char *libxl__lock_dir_path(void); _hidden const char *libxl__run_dir_path(void); +/*----- datacopier: copies data from one fd to another -----*/ + +typedef struct libxl__datacopier_state libxl__datacopier_state; +typedef struct libxl__datacopier_buf libxl__datacopier_buf; + +/* onwrite==1 means failure happened when writing, logged, errnoval is valid + * onwrite==0 means failure happened when reading + * errnoval==0 means we got eof and all data was written + * errnoval!=0 means we had a read error, logged + * onwrite==-1 means some other internal failure, errnoval not valid, logged + * in all cases copier is killed before calling this callback */ +typedef void libxl__datacopier_callback(libxl__egc *egc, + libxl__datacopier_state *dc, int onwrite, int errnoval); + +struct libxl__datacopier_buf { + /* private to datacopier */ + LIBXL_TAILQ_ENTRY(libxl__datacopier_buf) entry; + int used; + char buf[1000]; +}; + +struct libxl__datacopier_state { + /* caller must fill these in, and they must all remain valid */ + libxl__ao *ao; + int readfd, writefd; + ssize_t maxsz; + const char *copywhat, *readwhat, *writewhat; /* for error msgs */ + libxl__datacopier_callback *callback; + /* remaining fields are private to datacopier */ + libxl__ev_fd toread, towrite; + ssize_t used; + LIBXL_TAILQ_HEAD(libxl__datacopier_bufs, libxl__datacopier_buf) bufs; +}; + +_hidden void libxl__datacopier_init(libxl__datacopier_state *dc); +_hidden void libxl__datacopier_kill(libxl__datacopier_state *dc); +_hidden int libxl__datacopier_start(libxl__datacopier_state *dc); + + /* * Convenience macros. */ -- 1.7.2.5
General facility for ao operations to open ptys. This will be used by the bootloader machinery. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> --- tools/libxl/libxl_aoutils.c | 127 ++++++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_internal.h | 36 ++++++++++++ 2 files changed, 163 insertions(+), 0 deletions(-) diff --git a/tools/libxl/libxl_aoutils.c b/tools/libxl/libxl_aoutils.c index 4c60ad9..734a5dc 100644 --- a/tools/libxl/libxl_aoutils.c +++ b/tools/libxl/libxl_aoutils.c @@ -187,3 +187,130 @@ int libxl__datacopier_start(libxl__datacopier_state *dc) return rc; } +/*----- openpty -----*/ + +/* implementation */ + +static void openpty_cleanup(libxl__openpty_state *op) +{ + int i; + + for (i=0; i<op->count; i++) { + libxl__openpty_result *res = &op->results[i]; + libxl__carefd_close(res->master); res->master = 0; + libxl__carefd_close(res->slave); res->slave = 0; + } +} + +static void openpty_exited(libxl__egc *egc, libxl__ev_child *child, + pid_t pid, int status) { + libxl__openpty_state *op = CONTAINER_OF(child, *op, child); + STATE_AO_GC(op->ao); + + if (status) { + /* Perhaps the child gave us the fds and then exited nonzero. + * Well that would be odd but we don''t really care. */ + libxl_report_child_exitstatus(CTX, op->rc ? LIBXL__LOG_ERROR + : LIBXL__LOG_WARNING, + "openpty child", pid, status); + } + if (op->rc) + openpty_cleanup(op); + op->callback(egc, op); +} + +int libxl__openptys(libxl__openpty_state *op, + const struct termios *termp, + const struct winsize *winp) { + /* + * This is completely crazy. openpty calls grantpt which the spec + * says may fork, and may not be called with a SIGCHLD handler. + * Now our application may have a SIGCHLD handler so that''s bad. + * We could perhaps block it but we''d need to block it on all + * threads. This is just Too Hard. + * + * So instead, we run openpty in a child process. That child + * process then of course has only our own thread and our own + * signal handlers. We pass the fds back. + * + * Since our only current caller actually wants two ptys, we + * support calling openpty multiple times for a single fork. + */ + STATE_AO_GC(op->ao); + int count = op->count; + int r, i, rc, sockets[2], ptyfds[count][2]; + libxl__carefd *for_child = 0; + pid_t pid = -1; + + for (i=0; i<count; i++) { + ptyfds[i][0] = ptyfds[i][1] = -1; + libxl__openpty_result *res = &op->results[i]; + assert(!res->master); + assert(!res->slave); + } + sockets[0] = sockets[1] = -1; /* 0 is for us, 1 for our child */ + + libxl__carefd_begin(); + r = socketpair(AF_UNIX, SOCK_STREAM, 0, sockets); + if (r) { sockets[0] = sockets[1] = -1; } + for_child = libxl__carefd_opened(CTX, sockets[1]); + if (r) { LOGE(ERROR,"socketpair failed"); rc = ERROR_FAIL; goto out; } + + pid = libxl__ev_child_fork(gc, &op->child, openpty_exited); + if (pid == -1) { + rc = ERROR_FAIL; + goto out; + } + + if (!pid) { + /* child */ + close(sockets[0]); + signal(SIGCHLD, SIG_DFL); + + for (i=0; i<count; i++) { + r = openpty(&ptyfds[i][0], &ptyfds[i][1], NULL, termp, winp); + if (r) { LOGE(ERROR,"openpty failed"); _exit(-1); } + } + rc = libxl__sendmsg_fds(gc, sockets[1], "",1, + 2*count, &ptyfds[0][0], "ptys"); + if (rc) { LOGE(ERROR,"sendmsg to parent failed"); _exit(-1); } + _exit(0); + } + + libxl__carefd_close(for_child); + for_child = 0; + + /* this should be fast so do it synchronously */ + + libxl__carefd_begin(); + char buf[1]; + rc = libxl__recvmsg_fds(gc, sockets[0], buf,1, + 2*count, &ptyfds[0][0], "ptys"); + if (!rc) { + for (i=0; i<count; i++) { + libxl__openpty_result *res = &op->results[i]; + res->master = libxl__carefd_record(CTX, ptyfds[i][0]); + res->slave = libxl__carefd_record(CTX, ptyfds[i][1]); + } + } + /* now the pty fds are in the carefds, if they were ever open */ + libxl__carefd_unlock(); + if (rc) + goto out; + + rc = 0; + + out: + if (sockets[0] >= 0) close(sockets[0]); + libxl__carefd_close(for_child); + if (libxl__ev_child_inuse(&op->child)) { + op->rc = rc; + /* we will get a callback when the child dies */ + return 0; + } + + assert(rc); + openpty_cleanup(op); + return rc; +} + diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index be11fbd..3744a28 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1513,6 +1513,42 @@ _hidden void libxl__datacopier_kill(libxl__datacopier_state *dc); _hidden int libxl__datacopier_start(libxl__datacopier_state *dc); +/*----- openpty -----*/ + +/* + * opens count (>0) ptys like count calls to openpty, and then + * calls back. On entry, all op[].master and op[].slave must be + * 0. On callback, either rc==0 and master and slave are non-0, + * or rc is a libxl error and they are both 0. If libxl__openpty + * returns non-0 no callback will happen and everything is left + * cleaned up. + */ + +typedef struct libxl__openpty_state libxl__openpty_state; +typedef struct libxl__openpty_result libxl__openpty_result; +typedef void libxl__openpty_callback(libxl__egc *egc, libxl__openpty_state *op); + +struct libxl__openpty_state { + /* caller must fill these in, and they must all remain valid */ + libxl__ao *ao; + libxl__openpty_callback *callback; + int count; + libxl__openpty_result *results; /* actual size is count, out parameter */ + /* public, result, caller may only read in callback */ + int rc; + /* private for implementation */ + libxl__ev_child child; +}; + +struct libxl__openpty_result { + libxl__carefd *master, *slave; +}; + +int libxl__openptys(libxl__openpty_state *op, + const struct termios *termp, + const struct winsize *winp); + + /* * Convenience macros. */ -- 1.7.2.5
Convert libxl_run_bootloader to an ao_how-taking function. It''s implemented in terms of libxl__bootloader_run, which can be used internally. The resulting code is pretty much a rewrite. Significant changes include: - We direct the bootloader''s results to a file, not a pipe. This makes it simpler to deal with as we don''t have to read it concurrently along with everything else. - We now issue a warning if we find unexpected statements in the bootloader results. - The arrangements for buffering of bootloader input and output are completely changed. Now we have a fixed limit of 64k on output, and 4k on input, and discard the oldest data when this overflows (which it shouldn''t). There is no timeout any more. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Changes since v6: * Use libxl__ev_child_inuse rather than testing pid directly. * Fix a code style error. * Properly initialise the sub-operations'' aos in _init. * Bugfixes. --- tools/libxl/libxl.c | 4 + tools/libxl/libxl.h | 3 +- tools/libxl/libxl_bootloader.c | 713 +++++++++++++++++++++------------------- tools/libxl/libxl_create.c | 8 +- tools/libxl/libxl_internal.h | 34 ++ 5 files changed, 419 insertions(+), 343 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 939cc02..d5fb186 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -1750,6 +1750,10 @@ int libxl_device_disk_local_detach(libxl_ctx *ctx, libxl_device_disk *disk) * For other device types assume that the blktap2 process is * needed by the soon to be started domain and do nothing. */ + /* + * FIXME + * This appears to leak the disk in failure paths + */ return 0; } diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index fb90aed..3087146 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -495,7 +495,8 @@ int libxl_get_max_cpus(libxl_ctx *ctx); int libxl_run_bootloader(libxl_ctx *ctx, libxl_domain_build_info *info, libxl_device_disk *disk, - uint32_t domid); + uint32_t domid, + libxl_asyncop_how *ao_how); /* 0 means ERROR_ENOMEM, which we have logged */ diff --git a/tools/libxl/libxl_bootloader.c b/tools/libxl/libxl_bootloader.c index b50944a..bdc4cb4 100644 --- a/tools/libxl/libxl_bootloader.c +++ b/tools/libxl/libxl_bootloader.c @@ -15,6 +15,7 @@ #include "libxl_osdeps.h" /* must come before any other headers */ #include <termios.h> +#include <utmp.h> #ifdef INCLUDE_LIBUTIL_H #include INCLUDE_LIBUTIL_H @@ -22,67 +23,80 @@ #include "libxl_internal.h" -#define XENCONSOLED_BUF_SIZE 16 -#define BOOTLOADER_BUF_SIZE 4096 -#define BOOTLOADER_TIMEOUT 1 +#define BOOTLOADER_BUF_OUT 65536 +#define BOOTLOADER_BUF_IN 4096 -static char **make_bootloader_args(libxl__gc *gc, - libxl_domain_build_info *info, - uint32_t domid, - const char *fifo, char *disk) +static void bootloader_gotptys(libxl__egc *egc, libxl__openpty_state *op); +static void bootloader_keystrokes_copyfail(libxl__egc *egc, + libxl__datacopier_state *dc, int onwrite, int errnoval); +static void bootloader_display_copyfail(libxl__egc *egc, + libxl__datacopier_state *dc, int onwrite, int errnoval); +static void bootloader_finished(libxl__egc *egc, libxl__ev_child *child, + pid_t pid, int status); + +/*----- bootloader arguments -----*/ + +static void bootloader_arg(libxl__bootloader_state *bl, const char *arg) +{ + assert(bl->nargs < bl->argsspace); + bl->args[bl->nargs++] = arg; +} + +static void make_bootloader_args(libxl__gc *gc, libxl__bootloader_state *bl) { - flexarray_t *args; - int nr = 0; + const libxl_domain_build_info *info = bl->info; - args = flexarray_make(1, 1); - if (!args) - return NULL; + bl->argsspace = 7 + libxl_string_list_length(&info->u.pv.bootloader_args); - flexarray_set(args, nr++, (char *)info->u.pv.bootloader); + GCNEW_ARRAY(bl->args, bl->argsspace); + +#define ARG(arg) bootloader_arg(bl, (arg)) + + ARG(info->u.pv.bootloader); if (info->u.pv.kernel.path) - flexarray_set(args, nr++, libxl__sprintf(gc, "--kernel=%s", - info->u.pv.kernel.path)); + ARG(libxl__sprintf(gc, "--kernel=%s", info->u.pv.kernel.path)); if (info->u.pv.ramdisk.path) - flexarray_set(args, nr++, libxl__sprintf(gc, "--ramdisk=%s", info->u.pv.ramdisk.path)); + ARG(libxl__sprintf(gc, "--ramdisk=%s", info->u.pv.ramdisk.path)); if (info->u.pv.cmdline && *info->u.pv.cmdline != ''\0'') - flexarray_set(args, nr++, libxl__sprintf(gc, "--args=%s", info->u.pv.cmdline)); + ARG(libxl__sprintf(gc, "--args=%s", info->u.pv.cmdline)); - flexarray_set(args, nr++, libxl__sprintf(gc, "--output=%s", fifo)); - flexarray_set(args, nr++, "--output-format=simple0"); - flexarray_set(args, nr++, libxl__sprintf(gc, "--output-directory=%s", "/var/run/libxl/")); + ARG(libxl__sprintf(gc, "--output=%s", bl->outputpath)); + ARG("--output-format=simple0"); + ARG(libxl__sprintf(gc, "--output-directory=%s", bl->outputdir)); if (info->u.pv.bootloader_args) { char **p = info->u.pv.bootloader_args; while (*p) { - flexarray_set(args, nr++, *p); + ARG(*p); p++; } } - flexarray_set(args, nr++, disk); + ARG(bl->diskpath); - /* Sentinal for execv */ - flexarray_set(args, nr++, NULL); + /* Sentinel for execv */ + ARG(NULL); - return (char **) flexarray_contents(args); /* Frees args */ +#undef ARG } -static int open_xenconsoled_pty(int *master, int *slave, char *slave_path, size_t slave_path_len) +/*----- synchronous subroutines -----*/ + +static int setup_xenconsoled_pty(libxl__egc *egc, libxl__bootloader_state *bl, + char *slave_path, size_t slave_path_len) { + STATE_AO_GC(bl->ao); struct termios termattr; - int ret; - - ret = openpty(master, slave, NULL, NULL, NULL); - if (ret < 0) - return -1; - - ret = ttyname_r(*slave, slave_path, slave_path_len); - if (ret == -1) { - close(*master); - close(*slave); - *master = *slave = -1; - return -1; + int r, rc; + int slave = libxl__carefd_fd(bl->ptys[1].slave); + int master = libxl__carefd_fd(bl->ptys[1].master); + + r = ttyname_r(slave, slave_path, slave_path_len); + if (r == -1) { + LOGE(ERROR,"ttyname_r failed"); + rc = ERROR_FAIL; + goto out; } /* @@ -95,310 +109,217 @@ static int open_xenconsoled_pty(int *master, int *slave, char *slave_path, size_ * semantics on Solaris, so don''t try to set any attributes * for it. */ -#if !defined(__sun__) && !defined(__NetBSD__) - tcgetattr(*master, &termattr); + tcgetattr(master, &termattr); cfmakeraw(&termattr); - tcsetattr(*master, TCSANOW, &termattr); - - close(*slave); - *slave = -1; -#else - tcgetattr(*slave, &termattr); - cfmakeraw(&termattr); - tcsetattr(*slave, TCSANOW, &termattr); -#endif - - fcntl(*master, F_SETFL, O_NDELAY); - fcntl(*master, F_SETFD, FD_CLOEXEC); + tcsetattr(master, TCSANOW, &termattr); return 0; + + out: + return rc; } -static pid_t fork_exec_bootloader(int *master, const char *arg0, char **args) -{ - struct termios termattr; - pid_t pid = forkpty(master, NULL, NULL, NULL); - if (pid == -1) - return -1; - else if (pid == 0) { - setenv("TERM", "vt100", 1); - libxl__exec(-1, -1, -1, arg0, args); - return -1; - } +static const char *bootloader_result_command(libxl__gc *gc, const char *buf, + const char *prefix, size_t prefixlen) { + if (strncmp(buf, prefix, prefixlen)) + return 0; - /* - * On Solaris, the master pty side does not have terminal semantics, - * so don''t try to set any attributes, as it will fail. - */ -#if !defined(__sun__) - tcgetattr(*master, &termattr); - cfmakeraw(&termattr); - tcsetattr(*master, TCSANOW, &termattr); -#endif + const char *rhs = buf + prefixlen; + if (!CTYPE(isspace,*rhs)) + return 0; - fcntl(*master, F_SETFL, O_NDELAY); + while (CTYPE(isspace,*rhs)) + rhs++; - return pid; + LOG(DEBUG,"bootloader output contained %s %s", prefix, rhs); + + return rhs; } -/* - * filedescriptors: - * fifo_fd - bootstring output from the bootloader - * xenconsoled_fd - input/output from/to xenconsole - * bootloader_fd - input/output from/to pty that controls the bootloader - * The filedescriptors are NDELAY, so it''s ok to try to read - * bigger chunks than may be available, to keep e.g. curses - * screen redraws in the bootloader efficient. xenconsoled_fd is the side that - * gets xenconsole input, which will be keystrokes, so a small number - * is sufficient. bootloader_fd is pygrub output, which will be curses screen - * updates, so a larger number (1024) is appropriate there. - * - * For writeable descriptors, only include them in the set for select - * if there is actual data to write, otherwise this would loop too fast, - * eating up CPU time. - */ -static char * bootloader_interact(libxl__gc *gc, int xenconsoled_fd, int bootloader_fd, int fifo_fd) +static int parse_bootloader_result(libxl__egc *egc, + libxl__bootloader_state *bl) { - int ret; - - size_t nr_out = 0, size_out = 0; - char *output = NULL; - struct timeval wait; - - /* input from xenconsole. read on xenconsoled_fd write to bootloader_fd */ - int xenconsoled_prod = 0, xenconsoled_cons = 0; - char xenconsoled_buf[XENCONSOLED_BUF_SIZE]; - /* output from bootloader. read on bootloader_fd write to xenconsoled_fd */ - int bootloader_prod = 0, bootloader_cons = 0; - char bootloader_buf[BOOTLOADER_BUF_SIZE]; - - while(1) { - fd_set wsel, rsel; - int nfds; - - /* Set timeout to 1s before starting to discard data */ - wait.tv_sec = BOOTLOADER_TIMEOUT; - wait.tv_usec = 0; - - /* Move buffers around to drop already consumed data */ - if (xenconsoled_cons > 0) { - xenconsoled_prod -= xenconsoled_cons; - memmove(xenconsoled_buf, &xenconsoled_buf[xenconsoled_cons], - xenconsoled_prod); - xenconsoled_cons = 0; - } - if (bootloader_cons > 0) { - bootloader_prod -= bootloader_cons; - memmove(bootloader_buf, &bootloader_buf[bootloader_cons], - bootloader_prod); - bootloader_cons = 0; - } - - FD_ZERO(&rsel); - FD_SET(fifo_fd, &rsel); - nfds = fifo_fd + 1; - if (xenconsoled_prod < XENCONSOLED_BUF_SIZE) { - /* The buffer is not full, try to read more data */ - FD_SET(xenconsoled_fd, &rsel); - nfds = xenconsoled_fd + 1 > nfds ? xenconsoled_fd + 1 : nfds; - } - if (bootloader_prod < BOOTLOADER_BUF_SIZE) { - /* The buffer is not full, try to read more data */ - FD_SET(bootloader_fd, &rsel); - nfds = bootloader_fd + 1 > nfds ? bootloader_fd + 1 : nfds; - } - - FD_ZERO(&wsel); - if (bootloader_prod > 0) { - /* The buffer has data to consume */ - FD_SET(xenconsoled_fd, &wsel); - nfds = xenconsoled_fd + 1 > nfds ? xenconsoled_fd + 1 : nfds; - } - if (xenconsoled_prod > 0) { - /* The buffer has data to consume */ - FD_SET(bootloader_fd, &wsel); - nfds = bootloader_fd + 1 > nfds ? bootloader_fd + 1 : nfds; - } - - if (xenconsoled_prod == XENCONSOLED_BUF_SIZE || - bootloader_prod == BOOTLOADER_BUF_SIZE) - ret = select(nfds, &rsel, &wsel, NULL, &wait); - else - ret = select(nfds, &rsel, &wsel, NULL, NULL); - if (ret < 0) { - if (errno == EINTR) - continue; - goto out_err; - } - - /* Input from xenconsole, read xenconsoled_fd, write bootloader_fd */ - if (ret == 0 && xenconsoled_prod == XENCONSOLED_BUF_SIZE) { - /* Drop the buffer */ - xenconsoled_prod = 0; - xenconsoled_cons = 0; - } else if (FD_ISSET(xenconsoled_fd, &rsel)) { - ret = read(xenconsoled_fd, &xenconsoled_buf[xenconsoled_prod], XENCONSOLED_BUF_SIZE - xenconsoled_prod); - if (ret < 0 && errno != EIO && errno != EAGAIN) - goto out_err; - if (ret > 0) - xenconsoled_prod += ret; - } - if (FD_ISSET(bootloader_fd, &wsel)) { - ret = write(bootloader_fd, &xenconsoled_buf[xenconsoled_cons], xenconsoled_prod - xenconsoled_cons); - if (ret < 0 && errno != EIO && errno != EAGAIN) - goto out_err; - if (ret > 0) - xenconsoled_cons += ret; - } + STATE_AO_GC(bl->ao); + char buf[PATH_MAX*2]; + FILE *f = 0; + int rc = ERROR_FAIL; + libxl_domain_build_info *info = bl->info; + + f = fopen(bl->outputpath, "r"); + if (!f) { + LOGE(ERROR,"open bootloader output file %s", bl->outputpath); + goto out; + } - /* Input from bootloader, read bootloader_fd, write xenconsoled_fd */ - if (ret == 0 && bootloader_prod == BOOTLOADER_BUF_SIZE) { - /* Drop the buffer */ - bootloader_prod = 0; - bootloader_cons = 0; - } else if (FD_ISSET(bootloader_fd, &rsel)) { - ret = read(bootloader_fd, &bootloader_buf[bootloader_prod], BOOTLOADER_BUF_SIZE - bootloader_prod); - if (ret < 0 && errno != EIO && errno != EAGAIN) - goto out_err; - if (ret > 0) - bootloader_prod += ret; + for (;;) { + /* Read a nul-terminated "line" and put the result in + * buf, and its length (not including the nul) in l */ + int l = 0, c; + while ((c = getc(f)) != EOF && c != ''\0'') { + if (l < sizeof(buf)-1) + buf[l] = c; + l++; } - if (FD_ISSET(xenconsoled_fd, &wsel)) { - ret = write(xenconsoled_fd, &bootloader_buf[bootloader_cons], bootloader_prod - bootloader_cons); - if (ret < 0 && errno != EIO && errno != EAGAIN) - goto out_err; - if (ret > 0) - bootloader_cons += ret; - } - - if (FD_ISSET(fifo_fd, &rsel)) { - if (size_out - nr_out < 256) { - char *temp; - size_t new_size = size_out == 0 ? 32 : size_out * 2; - - temp = realloc(output, new_size); - if (temp == NULL) - goto out_err; - output = temp; - memset(output + size_out, 0, new_size - size_out); - size_out = new_size; + if (c == EOF) { + if (ferror(f)) { + LOGE(ERROR,"read bootloader output file %s", bl->outputpath); + goto out; } - - ret = read(fifo_fd, output + nr_out, size_out - nr_out); - if (ret > 0) - nr_out += ret; - if (ret == 0) + if (!l) break; } - } + if (l >= sizeof(buf)) { + LOG(WARN,"bootloader output contained" + " overly long item `%.150s...''", buf); + continue; + } + buf[l] = 0; - libxl__ptr_add(gc, output); - return output; + const char *rhs; +#define COMMAND(s) ((rhs = bootloader_result_command(gc, buf, s, sizeof(s)-1))) -out_err: - free(output); - return NULL; -} - -static void parse_bootloader_result(libxl__gc *gc, - libxl_domain_build_info *info, - const char *o) -{ - while (*o != ''\0'') { - if (strncmp("kernel ", o, strlen("kernel ")) == 0) { + if (COMMAND("kernel")) { free(info->u.pv.kernel.path); - info->u.pv.kernel.path = strdup(o + strlen("kernel ")); + info->u.pv.kernel.path = libxl__strdup(NULL, rhs); libxl__file_reference_map(&info->u.pv.kernel); unlink(info->u.pv.kernel.path); - } else if (strncmp("ramdisk ", o, strlen("ramdisk ")) == 0) { + } else if (COMMAND("ramdisk")) { free(info->u.pv.ramdisk.path); - info->u.pv.ramdisk.path = strdup(o + strlen("ramdisk ")); + info->u.pv.ramdisk.path = libxl__strdup(NULL, rhs); libxl__file_reference_map(&info->u.pv.ramdisk); unlink(info->u.pv.ramdisk.path); - } else if (strncmp("args ", o, strlen("args ")) == 0) { + } else if (COMMAND("args")) { free(info->u.pv.cmdline); - info->u.pv.cmdline = strdup(o + strlen("args ")); + info->u.pv.cmdline = libxl__strdup(NULL, rhs); + } else if (l) { + LOG(WARN, "unexpected output from bootloader: `%s''", buf); } - - o = o + strlen(o) + 1; } + rc = 0; + + out: + if (f) fclose(f); + return rc; } -int libxl_run_bootloader(libxl_ctx *ctx, - libxl_domain_build_info *info, - libxl_device_disk *disk, - uint32_t domid) + +/*----- init and cleanup -----*/ + +void libxl__bootloader_init(libxl__bootloader_state *bl) +{ + assert(bl->ao); + bl->diskpath = NULL; + bl->openpty.ao = bl->ao; + bl->ptys[0].master = bl->ptys[0].slave = 0; + bl->ptys[1].master = bl->ptys[1].slave = 0; + libxl__ev_child_init(&bl->child); + bl->keystrokes.ao = bl->ao; libxl__datacopier_init(&bl->keystrokes); + bl->display.ao = bl->ao; libxl__datacopier_init(&bl->display); +} + +static void bootloader_cleanup(libxl__egc *egc, libxl__bootloader_state *bl) { - GC_INIT(ctx); - int ret, rc = 0; - char *fifo = NULL; - char *diskpath = NULL; - char **args = NULL; + STATE_AO_GC(bl->ao); + int i; - char tempdir_template[] = "/var/run/libxl/bl.XXXXXX"; - char *tempdir; + if (bl->outputpath) libxl__remove_file(gc, bl->outputpath); + if (bl->outputdir) libxl__remove_directory(gc, bl->outputdir); - char *dom_console_xs_path; - char dom_console_slave_tty_path[PATH_MAX]; + if (bl->diskpath) { + libxl_device_disk_local_detach(CTX, bl->disk); + free(bl->diskpath); + bl->diskpath = 0; + } + libxl__datacopier_kill(&bl->keystrokes); + libxl__datacopier_kill(&bl->display); + for (i=0; i<2; i++) { + libxl__carefd_close(bl->ptys[i].master); + libxl__carefd_close(bl->ptys[i].slave); + } +} + +static void bootloader_setpaths(libxl__gc *gc, libxl__bootloader_state *bl) +{ + uint32_t domid = bl->domid; + bl->outputdir = GCSPRINTF(XEN_RUN_DIR "/bootloader.%"PRIu32".d", domid); + bl->outputpath = GCSPRINTF(XEN_RUN_DIR "/bootloader.%"PRIu32".out", domid); +} - int xenconsoled_fd = -1, xenconsoled_slave = -1; - int bootloader_fd = -1, fifo_fd = -1; +static void bootloader_callback(libxl__egc *egc, libxl__bootloader_state *bl, + int rc) +{ + bootloader_cleanup(egc, bl); + bl->callback(egc, bl, rc); +} - int blrc; - pid_t pid; - char *blout; +/*----- main flow of control -----*/ - struct stat st_buf; +void libxl__bootloader_run(libxl__egc *egc, libxl__bootloader_state *bl) +{ + STATE_AO_GC(bl->ao); + libxl_domain_build_info *info = bl->info; + int rc, r; - rc = libxl__domain_build_info_setdefault(gc, info); - if (rc) goto out; + libxl__bootloader_init(bl); - if (info->type != LIBXL_DOMAIN_TYPE_PV || !info->u.pv.bootloader) - goto out; + if (info->type != LIBXL_DOMAIN_TYPE_PV || !info->u.pv.bootloader) { + rc = 0; + goto out_ok; + } - rc = libxl__domain_build_info_setdefault(gc, info); - if (rc) goto out; + bootloader_setpaths(gc, bl); - rc = ERROR_INVAL; - if (!disk) + for (;;) { + r = mkdir(bl->outputdir, 0600); + if (!r) break; + if (errno == EINTR) continue; + if (errno == EEXIST) break; + LOGE(ERROR, "failed to create bootloader dir %s", bl->outputdir); + rc = ERROR_FAIL; goto out; + } - rc = ERROR_FAIL; - ret = mkdir("/var/run/libxl/", S_IRWXU); - if (ret < 0 && errno != EEXIST) + for (;;) { + r = open(bl->outputpath, O_WRONLY|O_CREAT|O_TRUNC, 0600); + if (r>=0) { close(r); break; } + if (errno == EINTR) continue; + LOGE(ERROR, "failed to precreate bootloader output %s", bl->outputpath); + rc = ERROR_FAIL; goto out; + } - ret = stat("/var/run/libxl/", &st_buf); - if (ret < 0) + bl->diskpath = libxl_device_disk_local_attach(CTX, bl->disk); + if (!bl->diskpath) { + rc = ERROR_FAIL; goto out; + } - if (!S_ISDIR(st_buf.st_mode)) - goto out; + make_bootloader_args(gc, bl); - tempdir = mkdtemp(tempdir_template); - if (tempdir == NULL) - goto out; + bl->openpty.ao = ao; + bl->openpty.callback = bootloader_gotptys; + bl->openpty.count = 2; + bl->openpty.results = bl->ptys; + rc = libxl__openptys(&bl->openpty, 0,0); + if (rc) goto out; - ret = asprintf(&fifo, "%s/fifo", tempdir); - if (ret < 0) { - fifo = NULL; - goto out_close; - } + return; - ret = mkfifo(fifo, 0600); - if (ret < 0) { - goto out_close; - } + out: + assert(rc); + out_ok: + bootloader_callback(egc, bl, rc); +} - diskpath = libxl_device_disk_local_attach(ctx, disk); - if (!diskpath) { - goto out_close; - } +static void bootloader_gotptys(libxl__egc *egc, libxl__openpty_state *op) +{ + libxl__bootloader_state *bl = CONTAINER_OF(op, *bl, openpty); + STATE_AO_GC(bl->ao); + int rc, r; - args = make_bootloader_args(gc, info, domid, fifo, diskpath); - if (args == NULL) { - rc = ERROR_NOMEM; - goto out_close; + if (bl->openpty.rc) { + rc = bl->openpty.rc; + goto out; } /* @@ -411,76 +332,188 @@ int libxl_run_bootloader(libxl_ctx *ctx, * where we copy characters between the two master fds, as well as * listening on the bootloader''s fifo for the results. */ - ret = open_xenconsoled_pty(&xenconsoled_fd, &xenconsoled_slave, + + char *dom_console_xs_path; + char dom_console_slave_tty_path[PATH_MAX]; + rc = setup_xenconsoled_pty(egc, bl, &dom_console_slave_tty_path[0], sizeof(dom_console_slave_tty_path)); - if (ret < 0) { - goto out_close; + if (rc) goto out; + + char *dompath = libxl__xs_get_dompath(gc, bl->domid); + if (!dompath) { rc = ERROR_FAIL; goto out; } + + dom_console_xs_path = GCSPRINTF("%s/console/tty", dompath); + + rc = libxl__xs_write(gc, XBT_NULL, dom_console_xs_path, "%s", + dom_console_slave_tty_path); + if (rc) { + LOGE(ERROR,"xs write console path %s := %s failed", + dom_console_xs_path, dom_console_slave_tty_path); + rc = ERROR_FAIL; + goto out; } - dom_console_xs_path = libxl__sprintf(gc, "%s/console/tty", libxl__xs_get_dompath(gc, domid)); - libxl__xs_write(gc, XBT_NULL, dom_console_xs_path, "%s", dom_console_slave_tty_path); + int bootloader_master = libxl__carefd_fd(bl->ptys[0].master); + int xenconsole_master = libxl__carefd_fd(bl->ptys[1].master); + + libxl_fd_set_nonblock(CTX, bootloader_master, 1); + libxl_fd_set_nonblock(CTX, xenconsole_master, 1); + + bl->keystrokes.writefd = bl->display.readfd = bootloader_master; + bl->keystrokes.writewhat = bl->display.readwhat = "bootloader pty"; + + bl->keystrokes.readfd = bl->display.writefd = xenconsole_master; + bl->keystrokes.readwhat = bl->display.writewhat = "xenconsole client pty"; + + bl->keystrokes.ao = ao; + bl->keystrokes.maxsz = BOOTLOADER_BUF_OUT; + bl->keystrokes.copywhat + GCSPRINTF("bootloader input for domain %"PRIu32, bl->domid); + bl->keystrokes.callback = bootloader_keystrokes_copyfail; + rc = libxl__datacopier_start(&bl->keystrokes); + if (rc) goto out; + + bl->display.ao = ao; + bl->display.maxsz = BOOTLOADER_BUF_IN; + bl->display.copywhat + GCSPRINTF("bootloader output for domain %"PRIu32, bl->domid); + bl->display.callback = bootloader_display_copyfail; + rc = libxl__datacopier_start(&bl->display); + if (rc) goto out; + + LOG(DEBUG, "executing bootloader: %s", bl->args[0]); + for (const char **blarg = bl->args; + *blarg; + blarg++) + LOG(DEBUG, " bootloader arg: %s", *blarg); + + struct termios termattr; - pid = fork_exec_bootloader(&bootloader_fd, info->u.pv.bootloader, args); - if (pid < 0) { - goto out_close; + pid_t pid = libxl__ev_child_fork(gc, &bl->child, bootloader_finished); + if (pid == -1) { + rc = ERROR_FAIL; + goto out; } - while (1) { - if (waitpid(pid, &blrc, WNOHANG) == pid) - goto out_close; + if (!pid) { + /* child */ + r = login_tty(libxl__carefd_fd(bl->ptys[0].slave)); + if (r) { LOGE(ERROR, "login_tty failed"); exit(-1); } + setenv("TERM", "vt100", 1); + libxl__exec(-1, -1, -1, bl->args[0], (char**)bl->args); + exit(-1); + } - fifo_fd = open(fifo, O_RDONLY); - if (fifo_fd > -1) - break; + /* parent */ - if (errno == EINTR) - continue; + /* + * On Solaris, the master pty side does not have terminal semantics, + * so don''t try to set any attributes, as it will fail. + */ +#if !defined(__sun__) + tcgetattr(bootloader_master, &termattr); + cfmakeraw(&termattr); + tcsetattr(bootloader_master, TCSANOW, &termattr); +#endif + + return; + + out: + bootloader_callback(egc, bl, rc); +} - goto out_close; +/* perhaps one of these will be called, but perhaps not */ +static void bootloader_copyfail(libxl__egc *egc, const char *which, + libxl__bootloader_state *bl, int onwrite, int errnoval) +{ + STATE_AO_GC(bl->ao); + int r; + + if (!onwrite && !errnoval) + LOG(ERROR, "unexpected eof copying %s", which); + libxl__datacopier_kill(&bl->keystrokes); + libxl__datacopier_kill(&bl->display); + if (libxl__ev_child_inuse(&bl->child)) { + r = kill(bl->child.pid, SIGTERM); + if (r) LOGE(WARN, "after failure, failed to kill bootloader [%lu]", + (unsigned long)bl->child.pid); } + bl->rc = ERROR_FAIL; +} +static void bootloader_keystrokes_copyfail(libxl__egc *egc, + libxl__datacopier_state *dc, int onwrite, int errnoval) +{ + libxl__bootloader_state *bl = CONTAINER_OF(dc, *bl, keystrokes); + bootloader_copyfail(egc, "bootloader input", bl, onwrite, errnoval); +} +static void bootloader_display_copyfail(libxl__egc *egc, + libxl__datacopier_state *dc, int onwrite, int errnoval) +{ + libxl__bootloader_state *bl = CONTAINER_OF(dc, *bl, display); + bootloader_copyfail(egc, "bootloader output", bl, onwrite, errnoval); +} - fcntl(fifo_fd, F_SETFL, O_NDELAY); +static void bootloader_finished(libxl__egc *egc, libxl__ev_child *child, + pid_t pid, int status) +{ + libxl__bootloader_state *bl = CONTAINER_OF(child, *bl, child); + STATE_AO_GC(bl->ao); + int rc; - blout = bootloader_interact(gc, xenconsoled_fd, bootloader_fd, fifo_fd); - if (blout == NULL) { - goto out_close; + libxl__datacopier_kill(&bl->keystrokes); + libxl__datacopier_kill(&bl->display); + + if (status) { + libxl_report_child_exitstatus(CTX, XTL_ERROR, "bootloader", + pid, status); + rc = ERROR_FAIL; + goto out; + } else { + LOG(DEBUG, "bootloader completed"); } - pid = waitpid(pid, &blrc, 0); - if (pid == -1 || (pid > 0 && WIFEXITED(blrc) && WEXITSTATUS(blrc) != 0)) { - goto out_close; + if (bl->rc) { + /* datacopier went wrong */ + rc = bl->rc; + goto out; } - parse_bootloader_result(gc, info, blout); + rc = parse_bootloader_result(egc, bl); + if (rc) goto out; rc = 0; -out_close: - if (diskpath) { - libxl_device_disk_local_detach(ctx, disk); - free(diskpath); - } - if (fifo_fd > -1) - close(fifo_fd); - if (bootloader_fd > -1) - close(bootloader_fd); - if (xenconsoled_fd > -1) - close(xenconsoled_fd); - if (xenconsoled_slave > -1) - close(xenconsoled_slave); - - if (fifo) { - unlink(fifo); - free(fifo); - } + LOG(DEBUG, "bootloader execution successful"); - rmdir(tempdir); + out: + bootloader_callback(egc, bl, rc); +} - free(args); +/*----- entrypoint for external callers -----*/ -out: - GC_FREE; - return rc; +static void run_bootloader_done(libxl__egc *egc, + libxl__bootloader_state *st, int rc) +{ + libxl__ao_complete(egc, st->ao, rc); +} + +int libxl_run_bootloader(libxl_ctx *ctx, + libxl_domain_build_info *info, + libxl_device_disk *disk, + uint32_t domid, + libxl_asyncop_how *ao_how) +{ + AO_CREATE(ctx,domid,ao_how); + libxl__bootloader_state *bl; + + GCNEW(bl); + bl->ao = ao; + bl->callback = run_bootloader_done; + bl->info = info; + bl->disk = disk; + bl->domid = domid; + libxl__bootloader_run(egc, bl); + return AO_INPROGRESS; } /* diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index d501102..f7732aa 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -593,8 +593,12 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config, if (ret) goto error_out; } - if ( restore_fd < 0 ) { - ret = libxl_run_bootloader(ctx, &d_config->b_info, d_config->num_disks > 0 ? &d_config->disks[0] : NULL, domid); + libxl_device_disk *bootdisk + d_config->num_disks > 0 ? &d_config->disks[0] : NULL; + + if (restore_fd < 0 && bootdisk) { + ret = libxl_run_bootloader(ctx, &d_config->b_info, bootdisk, domid, + 0 /* fixme-ao */); if (ret) { LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "failed to run bootloader: %d", ret); diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 3744a28..e8502c6 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -42,6 +42,7 @@ #include <sys/time.h> #include <sys/types.h> #include <sys/wait.h> +#include <sys/socket.h> #include <xs.h> #include <xenctrl.h> @@ -440,6 +441,7 @@ _hidden int libxl__remove_file(libxl__gc *gc, const char *path); _hidden int libxl__remove_directory(libxl__gc *gc, const char *path); _hidden int libxl__remove_file_or_directory(libxl__gc *gc, const char *path); + _hidden char **libxl__xs_kvs_of_flexarray(libxl__gc *gc, flexarray_t *array, int length); _hidden int libxl__xs_writev(libxl__gc *gc, xs_transaction_t t, @@ -1549,6 +1551,38 @@ int libxl__openptys(libxl__openpty_state *op, const struct winsize *winp); +/*----- bootloader -----*/ + +typedef struct libxl__bootloader_state libxl__bootloader_state; +typedef void libxl__run_bootloader_callback(libxl__egc*, + libxl__bootloader_state*, int rc); + +struct libxl__bootloader_state { + /* caller must fill these in, and they must all remain valid */ + libxl__ao *ao; + libxl__run_bootloader_callback *callback; + libxl_domain_build_info *info; /* u.pv.{kernel,ramdisk,cmdline} updated */ + libxl_device_disk *disk; + uint32_t domid; + /* private to libxl__run_bootloader */ + char *outputpath, *outputdir; + char *diskpath; /* not from gc, represents actually attached disk */ + libxl__openpty_state openpty; + libxl__openpty_result ptys[2]; /* [0] is for bootloader */ + libxl__ev_child child; + int nargs, argsspace; + const char **args; + libxl__datacopier_state keystrokes, display; + int rc; +}; + +_hidden void libxl__bootloader_init(libxl__bootloader_state *bl); + +/* Will definitely call st->callback, perhaps reentrantly. + * If callback is passed rc==0, will have updated st->info appropriately */ +_hidden void libxl__bootloader_run(libxl__egc*, libxl__bootloader_state *st); + + /* * Convenience macros. */ -- 1.7.2.5
Ian Jackson
2012-May-11 17:57 UTC
[PATCH 12/27] libxl: make libxl_create_logfile const-correct
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> --- tools/libxl/libxl_utils.c | 2 +- tools/libxl/libxl_utils.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c index 19b4615..f0d94c6 100644 --- a/tools/libxl/libxl_utils.c +++ b/tools/libxl/libxl_utils.c @@ -193,7 +193,7 @@ static int logrename(libxl__gc *gc, const char *old, const char *new) return 0; } -int libxl_create_logfile(libxl_ctx *ctx, char *name, char **full_name) +int libxl_create_logfile(libxl_ctx *ctx, const char *name, char **full_name) { GC_INIT(ctx); struct stat stat_buf; diff --git a/tools/libxl/libxl_utils.h b/tools/libxl/libxl_utils.h index ca53a8a..2b47622 100644 --- a/tools/libxl/libxl_utils.h +++ b/tools/libxl/libxl_utils.h @@ -26,7 +26,7 @@ int libxl_name_to_cpupoolid(libxl_ctx *ctx, const char *name, uint32_t *poolid); char *libxl_cpupoolid_to_name(libxl_ctx *ctx, uint32_t poolid); int libxl_get_stubdom_id(libxl_ctx *ctx, int guest_domid); int libxl_is_stubdom(libxl_ctx *ctx, uint32_t domid, uint32_t *target_domid); -int libxl_create_logfile(libxl_ctx *ctx, char *name, char **full_name); +int libxl_create_logfile(libxl_ctx *ctx, const char *name, char **full_name); int libxl_string_to_backend(libxl_ctx *ctx, char *s, libxl_disk_backend *backend); int libxl_read_file_contents(libxl_ctx *ctx, const char *filename, -- 1.7.2.5
This involves adding a new log feature to libxl__datacopier, and then using it. If the bootloader exits nonzero we print the log filename in a log message from libxl. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> --- tools/libxl/libxl_aoutils.c | 10 ++++++++++ tools/libxl/libxl_bootloader.c | 24 ++++++++++++++++++++++++ tools/libxl/libxl_internal.h | 3 ++- 3 files changed, 36 insertions(+), 1 deletions(-) diff --git a/tools/libxl/libxl_aoutils.c b/tools/libxl/libxl_aoutils.c index 734a5dc..91e34de 100644 --- a/tools/libxl/libxl_aoutils.c +++ b/tools/libxl/libxl_aoutils.c @@ -118,6 +118,16 @@ static void datacopier_readable(libxl__egc *egc, libxl__ev_fd *ev, libxl__ev_fd_deregister(gc, &dc->toread); break; } + if (dc->log) { + int wrote = fwrite(buf->buf + buf->used, 1, r, dc->log); + if (wrote != r) { + assert(ferror(dc->log)); + assert(errno); + LOGE(ERROR, "error logging %s", dc->copywhat); + datacopier_callback(egc, dc, 0, errno); + return; + } + } buf->used += r; dc->used += r; assert(buf->used <= sizeof(buf->buf)); diff --git a/tools/libxl/libxl_bootloader.c b/tools/libxl/libxl_bootloader.c index bdc4cb4..1534bae 100644 --- a/tools/libxl/libxl_bootloader.c +++ b/tools/libxl/libxl_bootloader.c @@ -236,6 +236,10 @@ static void bootloader_cleanup(libxl__egc *egc, libxl__bootloader_state *bl) libxl__carefd_close(bl->ptys[i].master); libxl__carefd_close(bl->ptys[i].slave); } + if (bl->display.log) { + fclose(bl->display.log); + bl->display.log = NULL; + } } static void bootloader_setpaths(libxl__gc *gc, libxl__bootloader_state *bl) @@ -258,6 +262,8 @@ void libxl__bootloader_run(libxl__egc *egc, libxl__bootloader_state *bl) { STATE_AO_GC(bl->ao); libxl_domain_build_info *info = bl->info; + uint32_t domid = bl->domid; + char *logfile_tmp = NULL; int rc, r; libxl__bootloader_init(bl); @@ -269,6 +275,22 @@ void libxl__bootloader_run(libxl__egc *egc, libxl__bootloader_state *bl) bootloader_setpaths(gc, bl); + const char *logfile_leaf = GCSPRINTF("bootloader.%"PRIu32, domid); + rc = libxl_create_logfile(CTX, logfile_leaf, &logfile_tmp); + if (rc) goto out; + + /* Transfer ownership of log filename to bl and the gc */ + bl->logfile = logfile_tmp; + libxl__ptr_add(gc, logfile_tmp); + logfile_tmp = NULL; + + bl->display.log = fopen(bl->logfile, "a"); + if (!bl->display.log) { + LOGE(ERROR, "failed to create bootloader logfile %s", bl->logfile); + rc = ERROR_FAIL; + goto out; + } + for (;;) { r = mkdir(bl->outputdir, 0600); if (!r) break; @@ -308,6 +330,7 @@ void libxl__bootloader_run(libxl__egc *egc, libxl__bootloader_state *bl) out: assert(rc); out_ok: + free(logfile_tmp); bootloader_callback(egc, bl, rc); } @@ -465,6 +488,7 @@ static void bootloader_finished(libxl__egc *egc, libxl__ev_child *child, libxl__datacopier_kill(&bl->display); if (status) { + LOG(ERROR, "bootloader failed - consult logfile %s", bl->logfile); libxl_report_child_exitstatus(CTX, XTL_ERROR, "bootloader", pid, status); rc = ERROR_FAIL; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index e8502c6..c5ec586 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1503,6 +1503,7 @@ struct libxl__datacopier_state { int readfd, writefd; ssize_t maxsz; const char *copywhat, *readwhat, *writewhat; /* for error msgs */ + FILE *log; /* gets a copy of everything */ libxl__datacopier_callback *callback; /* remaining fields are private to datacopier */ libxl__ev_fd toread, towrite; @@ -1565,7 +1566,7 @@ struct libxl__bootloader_state { libxl_device_disk *disk; uint32_t domid; /* private to libxl__run_bootloader */ - char *outputpath, *outputdir; + char *outputpath, *outputdir, *logfile; char *diskpath; /* not from gc, represents actually attached disk */ libxl__openpty_state openpty; libxl__openpty_result ptys[2]; /* [0] is for bootloader */ -- 1.7.2.5
Ian Jackson
2012-May-11 17:57 UTC
[PATCH 14/27] libxl: Allow AO_GC and EGC_GC even if not used
Mark the gc produced by AO_GC and EGC_GC with the gcc feature __attribute__((unused)). This allows the use of EGC_INIT and STATE_AO_GC by functions which do actually use the gc. This is convenient because those functions might want to use the ao or egc, rather than the gc; and also because it means that functions which morally ought to be fishing any gc they use out of an egc or state structure can be written do so regardless of whether the gc is actually used right then. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> --- tools/libxl/libxl_internal.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index c5ec586..21fe99c 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1287,7 +1287,7 @@ libxl__device_model_version_running(libxl__gc *gc, uint32_t domid); /* useful for all functions which take an egc: */ #define EGC_GC \ - libxl__gc *const gc = &egc->gc + libxl__gc *const gc __attribute__((unused)) = &egc->gc /* egc initialisation and destruction: */ @@ -1390,7 +1390,7 @@ _hidden void libxl__egc_cleanup(libxl__egc *egc); }) #define AO_GC \ - libxl__gc *const gc = &ao->gc + libxl__gc *const gc __attribute__((unused)) = &ao->gc #define STATE_AO_GC(op_ao) \ libxl__ao *const ao = (op_ao); \ -- 1.7.2.5
Ian Jackson
2012-May-11 17:58 UTC
[PATCH 15/27] libxl: add a dummy ao_how to libxl_domain_core_dump
From: Ian Campbell <ian.campbell@citrix.com> Although this function is not currently slow it may become so in the future (this also depends somewhat on the size of the guest). Therefore arrange for it to take an ao_how which it completes immediately. This will allow us to make it asynchronous in the future without breaking API compatibility. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> --- tools/libxl/libxl.c | 18 ++++++++++++++---- tools/libxl/libxl.h | 4 +++- tools/libxl/xl_cmdimpl.c | 4 ++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index d5fb186..482adaa 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -642,16 +642,26 @@ int libxl_domain_pause(libxl_ctx *ctx, uint32_t domid) } int libxl_domain_core_dump(libxl_ctx *ctx, uint32_t domid, - const char *filename) + const char *filename, + const libxl_asyncop_how *ao_how) { - int ret; + AO_CREATE(ctx, domid, ao_how); + int ret, rc; + ret = xc_domain_dumpcore(ctx->xch, domid, filename); if (ret<0) { LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "core dumping domain %d to %s", domid, filename); - return ERROR_FAIL; + rc = ERROR_FAIL; + goto out; } - return 0; + + rc = 0; +out: + + libxl__ao_complete(egc, ao, rc); + + return AO_INPROGRESS; } int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 3087146..d8dbb1e 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -511,7 +511,9 @@ int libxl_domain_rename(libxl_ctx *ctx, uint32_t domid, int libxl_domain_pause(libxl_ctx *ctx, uint32_t domid); int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid); -int libxl_domain_core_dump(libxl_ctx *ctx, uint32_t domid, const char *filename); +int libxl_domain_core_dump(libxl_ctx *ctx, uint32_t domid, + const char *filename, + const libxl_asyncop_how *ao_how); int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, uint32_t target_memkb); int libxl_set_memory_target(libxl_ctx *ctx, uint32_t domid, int32_t target_memkb, int relative, int enforce); diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index c1cab9e..45e2c30 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -1306,7 +1306,7 @@ static int handle_domain_death(libxl_ctx *ctx, uint32_t domid, LOG("failed to construct core dump path"); } else { LOG("dumping core to %s", corefile); - rc=libxl_domain_core_dump(ctx, domid, corefile); + rc=libxl_domain_core_dump(ctx, domid, corefile, NULL); if (rc) LOG("core dump failed (rc=%d).", rc); } /* No point crying over spilled milk, continue on failure. */ @@ -2927,7 +2927,7 @@ static void core_dump_domain(const char *domain_spec, const char *filename) { int rc; find_domain(domain_spec); - rc=libxl_domain_core_dump(ctx, domid, filename); + rc=libxl_domain_core_dump(ctx, domid, filename, NULL); if (rc) { fprintf(stderr,"core dump failed (rc=%d)\n",rc);exit(-1); } } -- 1.7.2.5
Remove this obsolete hook. Callers inside libxl which create and reap children should use the mechanisms provided by the event system. (This has no functional difference since there is no way for ctx->waitpid_instead ever to become set.) Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> --- tools/libxl/libxl_exec.c | 12 +++--------- tools/libxl/libxl_internal.h | 3 --- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/tools/libxl/libxl_exec.c b/tools/libxl/libxl_exec.c index b10e79f..2ee2154 100644 --- a/tools/libxl/libxl_exec.c +++ b/tools/libxl/libxl_exec.c @@ -19,11 +19,6 @@ #include "libxl_internal.h" -static int call_waitpid(pid_t (*waitpid_cb)(pid_t, int *, int), pid_t pid, int *status, int options) -{ - return (waitpid_cb) ? waitpid_cb(pid, status, options) : waitpid(pid, status, options); -} - static void check_open_fds(const char *what) { const char *env_debug; @@ -344,7 +339,7 @@ int libxl__spawn_spawn(libxl__gc *gc, if (!for_spawn) _exit(0); /* just detach then */ - got = call_waitpid(ctx->waitpid_instead, child, &status, 0); + got = waitpid(child, &status, 0); assert(got == child); rc = (WIFEXITED(status) ? WEXITSTATUS(status) : @@ -404,7 +399,7 @@ int libxl__spawn_detach(libxl__gc *gc, (unsigned long)for_spawn->intermediate); abort(); /* things are very wrong */ } - got = call_waitpid(ctx->waitpid_instead, for_spawn->intermediate, &status, 0); + got = waitpid(for_spawn->intermediate, &status, 0); assert(got == for_spawn->intermediate); if (!(WIFSIGNALED(status) && WTERMSIG(status) == SIGKILL)) { report_spawn_intermediate_status(gc, for_spawn, status); @@ -421,14 +416,13 @@ int libxl__spawn_detach(libxl__gc *gc, int libxl__spawn_check(libxl__gc *gc, libxl__spawn_starting *for_spawn) { - libxl_ctx *ctx = libxl__gc_owner(gc); pid_t got; int status; if (!for_spawn) return 0; assert(for_spawn->intermediate); - got = call_waitpid(ctx->waitpid_instead, for_spawn->intermediate, &status, WNOHANG); + got = waitpid(for_spawn->intermediate, &status, WNOHANG); if (!got) return 0; assert(got == for_spawn->intermediate); diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 21fe99c..6fb99f6 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -325,9 +325,6 @@ struct libxl__ctx { int sigchld_selfpipe[2]; /* [0]==-1 means handler not installed */ LIBXL_LIST_HEAD(, libxl__ev_child) children; - /* This is obsolete and must be removed: */ - int (*waitpid_instead)(pid_t pid, int *status, int flags); - libxl_version_info version_info; }; -- 1.7.2.5
Ian Jackson
2012-May-11 17:58 UTC
[PATCH 17/27] libxl: change some structures to unit arrays
In the next patch these variables will turn into actual pointers. To clarify that patch, prepare the ground by changing these variables from "struct foo var" to "struct foo var[1]". This enables accesses to them and their members to be made as if they were pointers. No functional change. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> --- tools/libxl/libxl_create.c | 18 +++++----- tools/libxl/libxl_dm.c | 84 ++++++++++++++++++++++---------------------- 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index f7732aa..b137288 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -564,7 +564,7 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config, { libxl_ctx *ctx = libxl__gc_owner(gc); libxl__spawner_starting *dm_starting = 0; - libxl__domain_build_state state; + libxl__domain_build_state state[1]; uint32_t domid; int i, ret; @@ -606,12 +606,12 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config, } } - memset(&state, 0, sizeof(state)); + memset(state, 0, sizeof(*state)); if ( restore_fd >= 0 ) { - ret = domain_restore(gc, &d_config->b_info, domid, restore_fd, &state); + ret = domain_restore(gc, &d_config->b_info, domid, restore_fd, state); } else { - ret = libxl__domain_build(gc, &d_config->b_info, domid, &state); + ret = libxl__domain_build(gc, &d_config->b_info, domid, state); } if (ret) { @@ -649,7 +649,7 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config, ret = init_console_info(&console, 0); if ( ret ) goto error_out; - libxl__device_console_add(gc, domid, &console, &state); + libxl__device_console_add(gc, domid, &console, state); libxl__device_console_dispose(&console); libxl_device_vkb_init(&vkb); @@ -657,7 +657,7 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config, libxl_device_vkb_dispose(&vkb); ret = libxl__create_device_model(gc, domid, d_config, - &state, &dm_starting); + state, &dm_starting); if (ret < 0) { LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "failed to create device model: %d", ret); @@ -683,11 +683,11 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config, d_config->num_vfbs, d_config->vfbs, d_config->num_disks, &d_config->disks[0]); - libxl__device_console_add(gc, domid, &console, &state); + libxl__device_console_add(gc, domid, &console, state); libxl__device_console_dispose(&console); if (need_qemu) { - libxl__create_xenpv_qemu(gc, domid, d_config, &state, &dm_starting); + libxl__create_xenpv_qemu(gc, domid, d_config, state, &dm_starting); } break; } @@ -701,7 +701,7 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config, == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) { libxl__qmp_initializations(gc, domid, d_config); } - ret = libxl__confirm_device_model_startup(gc, &state, dm_starting); + ret = libxl__confirm_device_model_startup(gc, state, dm_starting); if (ret < 0) { LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "device model did not start: %d", ret); diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 36b0730..725c3c0 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -678,10 +678,10 @@ static int libxl__create_stubdom(libxl__gc *gc, libxl_ctx *ctx = libxl__gc_owner(gc); int i, num_console = STUBDOM_SPECIAL_CONSOLES, ret; libxl__device_console *console; - libxl_domain_config dm_config; + libxl_domain_config dm_config[1]; libxl_device_vfb vfb; libxl_device_vkb vkb; - libxl__domain_build_state stubdom_state; + libxl__domain_build_state stubdom_state[1]; uint32_t dm_domid; char **args; struct xs_permissions perm[2]; @@ -694,58 +694,58 @@ static int libxl__create_stubdom(libxl__gc *gc, goto out; } - libxl_domain_create_info_init(&dm_config.c_info); - dm_config.c_info.type = LIBXL_DOMAIN_TYPE_PV; - dm_config.c_info.name = libxl__sprintf(gc, "%s-dm", + libxl_domain_create_info_init(&dm_config->c_info); + dm_config->c_info.type = LIBXL_DOMAIN_TYPE_PV; + dm_config->c_info.name = libxl__sprintf(gc, "%s-dm", libxl__domid_to_name(gc, guest_domid)); - dm_config.c_info.ssidref = guest_config->b_info.device_model_ssidref; + dm_config->c_info.ssidref = guest_config->b_info.device_model_ssidref; - libxl_uuid_generate(&dm_config.c_info.uuid); + libxl_uuid_generate(&dm_config->c_info.uuid); - libxl_domain_build_info_init(&dm_config.b_info); - libxl_domain_build_info_init_type(&dm_config.b_info, LIBXL_DOMAIN_TYPE_PV); + libxl_domain_build_info_init(&dm_config->b_info); + libxl_domain_build_info_init_type(&dm_config->b_info, LIBXL_DOMAIN_TYPE_PV); - dm_config.b_info.max_vcpus = 1; - dm_config.b_info.max_memkb = 32 * 1024; - dm_config.b_info.target_memkb = dm_config.b_info.max_memkb; + dm_config->b_info.max_vcpus = 1; + dm_config->b_info.max_memkb = 32 * 1024; + dm_config->b_info.target_memkb = dm_config->b_info.max_memkb; - dm_config.b_info.u.pv.kernel.path = libxl__abs_path(gc, "ioemu-stubdom.gz", + dm_config->b_info.u.pv.kernel.path = libxl__abs_path(gc, "ioemu-stubdom.gz", libxl__xenfirmwaredir_path()); - dm_config.b_info.u.pv.cmdline = libxl__sprintf(gc, " -d %d", guest_domid); - dm_config.b_info.u.pv.ramdisk.path = ""; - dm_config.b_info.u.pv.features = ""; + dm_config->b_info.u.pv.cmdline = libxl__sprintf(gc, " -d %d", guest_domid); + dm_config->b_info.u.pv.ramdisk.path = ""; + dm_config->b_info.u.pv.features = ""; - dm_config.b_info.device_model_version + dm_config->b_info.device_model_version guest_config->b_info.device_model_version; - dm_config.b_info.device_model + dm_config->b_info.device_model guest_config->b_info.device_model; - dm_config.b_info.extra = guest_config->b_info.extra; - dm_config.b_info.extra_pv = guest_config->b_info.extra_pv; - dm_config.b_info.extra_hvm = guest_config->b_info.extra_hvm; + dm_config->b_info.extra = guest_config->b_info.extra; + dm_config->b_info.extra_pv = guest_config->b_info.extra_pv; + dm_config->b_info.extra_hvm = guest_config->b_info.extra_hvm; - dm_config.disks = guest_config->disks; - dm_config.num_disks = guest_config->num_disks; + dm_config->disks = guest_config->disks; + dm_config->num_disks = guest_config->num_disks; - dm_config.vifs = guest_config->vifs; - dm_config.num_vifs = guest_config->num_vifs; + dm_config->vifs = guest_config->vifs; + dm_config->num_vifs = guest_config->num_vifs; - ret = libxl__domain_create_info_setdefault(gc, &dm_config.c_info); + ret = libxl__domain_create_info_setdefault(gc, &dm_config->c_info); if (ret) goto out; - ret = libxl__domain_build_info_setdefault(gc, &dm_config.b_info); + ret = libxl__domain_build_info_setdefault(gc, &dm_config->b_info); if (ret) goto out; libxl__vfb_and_vkb_from_hvm_guest_config(gc, guest_config, &vfb, &vkb); - dm_config.vfbs = &vfb; - dm_config.num_vfbs = 1; - dm_config.vkbs = &vkb; - dm_config.num_vkbs = 1; + dm_config->vfbs = &vfb; + dm_config->num_vfbs = 1; + dm_config->vkbs = &vkb; + dm_config->num_vkbs = 1; /* fixme: this function can leak the stubdom if it fails */ dm_domid = 0; - ret = libxl__domain_make(gc, &dm_config.c_info, &dm_domid); + ret = libxl__domain_make(gc, &dm_config->c_info, &dm_domid); if (ret) goto out; - ret = libxl__domain_build(gc, &dm_config.b_info, dm_domid, &stubdom_state); + ret = libxl__domain_build(gc, &dm_config->b_info, dm_domid, stubdom_state); if (ret) goto out; @@ -790,20 +790,20 @@ retry_transaction: if (errno == EAGAIN) goto retry_transaction; - for (i = 0; i < dm_config.num_disks; i++) { - ret = libxl_device_disk_add(ctx, dm_domid, &dm_config.disks[i]); + for (i = 0; i < dm_config->num_disks; i++) { + ret = libxl_device_disk_add(ctx, dm_domid, &dm_config->disks[i]); if (ret) goto out_free; } - for (i = 0; i < dm_config.num_vifs; i++) { - ret = libxl_device_nic_add(ctx, dm_domid, &dm_config.vifs[i]); + for (i = 0; i < dm_config->num_vifs; i++) { + ret = libxl_device_nic_add(ctx, dm_domid, &dm_config->vifs[i]); if (ret) goto out_free; } - ret = libxl_device_vfb_add(ctx, dm_domid, &dm_config.vfbs[0]); + ret = libxl_device_vfb_add(ctx, dm_domid, &dm_config->vfbs[0]); if (ret) goto out_free; - ret = libxl_device_vkb_add(ctx, dm_domid, &dm_config.vkbs[0]); + ret = libxl_device_vkb_add(ctx, dm_domid, &dm_config->vkbs[0]); if (ret) goto out_free; @@ -847,14 +847,14 @@ retry_transaction: break; } ret = libxl__device_console_add(gc, dm_domid, &console[i], - i == STUBDOM_CONSOLE_LOGGING ? &stubdom_state : NULL); + i == STUBDOM_CONSOLE_LOGGING ? stubdom_state : NULL); if (ret) goto out_free; } if (libxl__create_xenpv_qemu(gc, dm_domid, - &dm_config, - &stubdom_state, + dm_config, + stubdom_state, &dm_starting) < 0) { ret = ERROR_FAIL; goto out_free; -- 1.7.2.5
libxl__spawn_spawn becomes a callback-style asynchronous function. The implementation is now in terms of libxl__ev_* including libxl_ev_child. All the callers need to be updated. This includes the device model spawning functions libxl__create_device_model and libxl__create_stubdom; these are replaced with libxl__spawn_local_dm and libxl__spawn_stubdom. libxl__confirm_device_model_startup is abolished; instead the dm spawner calls back. (The choice of which kind of device model to create is lifted out of what used to be libxl__create_device_model, because that function was indirectly recursive. Recursive callback-style operations are clumsy because they require a pointer indirection for the nested states.) Waiting for proper device model startup it is no longer notionally optional. Previously the code appeared to tolerate this by passing NULL for various libxl__spawner_starting* parameters to device model spawners. However, this was not used anywhere. Conversely, the "for_spawn" parameter to libxl__wait_for_offspring is no longer supported. It remains as an unused formal parameter to avoid updating, in this patch, all the call sites which pass NULL. libxl__wait_for_offspring is in any case itself an obsolete function, so this wrinkle will go away when its callers are updated to use the event system. Consequently libxl__spawn_check is also abolished. The "console ready" callback also remains unchanged in this patch. The API for this needs to be reviewed in the context of the event series and its reentrancy restrictions documented. Thus their callers need to be updated. These are the domain creation functions libxl_domain_create_new and _restore. These functions now take ao_hows, and have a private state structure. However domain creation remains not completely converted to the event mechanism; in particular it runs the outward-facing function libxl_run_bootloader with a NULL ao_how, which is quite wrong. As it happens in the current code this is not a bug because none of the rest of the functionality surrounding the bootloader call will mind if the event loop is reentered in the middle of its execution. The file-scope function libxl__set_fd_flag which was used by the previous spawn arrangements becomes unused and is removed; other places in libxl can use libxl_fd_set_nonblock and libxl_fd_set_cloexec, which of course remain. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Changes since v8: * Make midproc_cb callback with correct pid (that of the grandchild, not "middle" which is zero). Reported by Roger Pau Monne. Changes since v7: * Rename libxl__spawn_stubdom to libxl__spawn_stub_dm (and ..._state); rename the state''s stubdom_* members to dm_*. * Eliminate the union between the two dm creation states in libxl__domain_create_state. Instead, the domain creation code simply uses libxl__stub_dm_spawn_state.dm directly, if we''re taking the local dm path. * Remove a spurious "break". * In domain creation, move the PV non-qemu case into the switch. * Code style fixes. * Constify some convenience aliases. * Improve comments (including typo fixes). --- tools/libxl/libxl.h | 14 ++- tools/libxl/libxl_create.c | 206 +++++++++++++++++++----- tools/libxl/libxl_dm.c | 219 +++++++++++++++----------- tools/libxl/libxl_exec.c | 354 +++++++++++++++++++++--------------------- tools/libxl/libxl_internal.h | 286 +++++++++++++++++++++++----------- tools/libxl/xl_cmdimpl.c | 6 +- 6 files changed, 683 insertions(+), 402 deletions(-) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index d8dbb1e..e19d947 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -465,8 +465,18 @@ int libxl_ctx_free(libxl_ctx *ctx /* 0 is OK */); /* domain related functions */ typedef int (*libxl_console_ready)(libxl_ctx *ctx, uint32_t domid, void *priv); -int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config, libxl_console_ready cb, void *priv, uint32_t *domid); -int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config, libxl_console_ready cb, void *priv, uint32_t *domid, int restore_fd); + /* fixme-ao Need to review this API. If we keep it, the reentrancy + * properties need to be documented but they may turn out to be too + * awkward */ + +int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config, + libxl_console_ready cb, void *priv, uint32_t *domid, + const libxl_asyncop_how *ao_how); +int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config, + libxl_console_ready cb, void *priv, + uint32_t *domid, int restore_fd, + const libxl_asyncop_how *ao_how); + void libxl_domain_config_init(libxl_domain_config *d_config); void libxl_domain_config_dispose(libxl_domain_config *d_config); int libxl_domain_suspend(libxl_ctx *ctx, libxl_domain_suspend_info *info, diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index b137288..9ce107a 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -558,16 +558,40 @@ static int store_libxl_entry(libxl__gc *gc, uint32_t domid, libxl_device_model_version_to_string(b_info->device_model_version)); } -static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config, - libxl_console_ready cb, void *priv, - uint32_t *domid_out, int restore_fd) +/*----- main domain creation -----*/ + +/* We have a linear control flow; only one event callback is + * outstanding at any time. Each initiation and callback function + * arranges for the next to be called, as the very last thing it + * does. (If that particular sub-operation is not needed, a + * function will call the next event callback directly.) + */ + +/* Event callbacks, in this order: */ +static void domcreate_devmodel_started(libxl__egc *egc, + libxl__dm_spawn_state *dmss, + int rc); + +/* Our own function to clean up and call the user''s callback. + * The final call in the sequence. */ +static void domcreate_complete(libxl__egc *egc, + libxl__domain_create_state *dcs, + int rc); + +static void initiate_domain_create(libxl__egc *egc, + libxl__domain_create_state *dcs) { + STATE_AO_GC(dcs->ao); libxl_ctx *ctx = libxl__gc_owner(gc); - libxl__spawner_starting *dm_starting = 0; - libxl__domain_build_state state[1]; uint32_t domid; int i, ret; + /* convenience aliases */ + libxl_domain_config *const d_config = dcs->guest_config; + const int restore_fd = dcs->restore_fd; + const libxl_console_ready cb = dcs->console_cb; + void *const priv = dcs->console_cb_priv; + domid = 0; ret = libxl__domain_create_info_setdefault(gc, &d_config->c_info); @@ -580,9 +604,12 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config, goto error_out; } + dcs->guest_domid = domid; + dcs->dmss.dm.guest_domid = 0; /* means we haven''t spawned */ + if ( d_config->c_info.type == LIBXL_DOMAIN_TYPE_PV && cb ) { - if ( (*cb)(ctx, domid, priv) ) - goto error_out; + ret = (*cb)(ctx, domid, priv); + if (ret) goto error_out; } ret = libxl__domain_build_info_setdefault(gc, &d_config->b_info); @@ -606,7 +633,17 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config, } } - memset(state, 0, sizeof(*state)); + memset(&dcs->build_state, 0, sizeof(dcs->build_state)); + libxl__domain_build_state *state = &dcs->build_state; + + /* We might be going to call libxl__spawn_local_dm, or _spawn_stub_dm. + * Fill in any field required by either, including both relevant + * callbacks (_spawn_stub_dm will overwrite our trespass if needed). */ + dcs->dmss.dm.spawn.ao = ao; + dcs->dmss.dm.guest_config = dcs->guest_config; + dcs->dmss.dm.build_state = &dcs->build_state; + dcs->dmss.dm.callback = domcreate_devmodel_started; + dcs->dmss.callback = domcreate_devmodel_started; if ( restore_fd >= 0 ) { ret = domain_restore(gc, &d_config->b_info, domid, restore_fd, state); @@ -656,14 +693,12 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config, libxl_device_vkb_add(ctx, domid, &vkb); libxl_device_vkb_dispose(&vkb); - ret = libxl__create_device_model(gc, domid, d_config, - state, &dm_starting); - if (ret < 0) { - LIBXL__LOG(ctx, LIBXL__LOG_ERROR, - "failed to create device model: %d", ret); - goto error_out; - } - break; + dcs->dmss.dm.guest_domid = domid; + if (libxl_defbool_val(d_config->b_info.device_model_stubdomain)) + libxl__spawn_stub_dm(egc, &dcs->dmss); + else + libxl__spawn_local_dm(egc, &dcs->dmss.dm); + return; } case LIBXL_DOMAIN_TYPE_PV: { @@ -687,26 +722,52 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config, libxl__device_console_dispose(&console); if (need_qemu) { - libxl__create_xenpv_qemu(gc, domid, d_config, state, &dm_starting); + dcs->dmss.dm.guest_domid = domid; + libxl__spawn_local_dm(egc, &dcs->dmss.dm); + return; + } else { + assert(!dcs->dmss.dm.guest_domid); + domcreate_devmodel_started(egc, &dcs->dmss.dm, 0); + return; } - break; } default: ret = ERROR_INVAL; goto error_out; } + abort(); /* not reached */ + + error_out: + assert(ret); + domcreate_complete(egc, dcs, ret); +} + +static void domcreate_devmodel_started(libxl__egc *egc, + libxl__dm_spawn_state *dmss, + int ret) +{ + libxl__domain_create_state *dcs = CONTAINER_OF(dmss, *dcs, dmss.dm); + STATE_AO_GC(dmss->spawn.ao); + int i; + libxl_ctx *ctx = CTX; + int domid = dcs->guest_domid; + + /* convenience aliases */ + libxl_domain_config *const d_config = dcs->guest_config; + const libxl_console_ready cb = dcs->console_cb; + void *const priv = dcs->console_cb_priv; + + if (ret) { + LIBXL__LOG(ctx, LIBXL__LOG_ERROR, + "device model did not start: %d", ret); + goto error_out; + } - if (dm_starting) { + if (dcs->dmss.dm.guest_domid) { if (d_config->b_info.device_model_version == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) { libxl__qmp_initializations(gc, domid, d_config); } - ret = libxl__confirm_device_model_startup(gc, state, dm_starting); - if (ret < 0) { - LIBXL__LOG(ctx, LIBXL__LOG_ERROR, - "device model did not start: %d", ret); - goto error_out; - } } for (i = 0; i < d_config->num_pcidevs; i++) @@ -734,38 +795,95 @@ static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config, if ( cb && (d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM || (d_config->c_info.type == LIBXL_DOMAIN_TYPE_PV && d_config->b_info.u.pv.bootloader ))) { - if ( (*cb)(ctx, domid, priv) ) - goto error_out; + ret = (*cb)(ctx, domid, priv); + if (ret) goto error_out; } - *domid_out = domid; - return 0; + domcreate_complete(egc, dcs, 0); + return; error_out: - if (domid) - libxl_domain_destroy(ctx, domid); + assert(ret); + domcreate_complete(egc, dcs, ret); +} - return ret; +static void domcreate_complete(libxl__egc *egc, + libxl__domain_create_state *dcs, + int rc) +{ + STATE_AO_GC(dcs->ao); + + if (rc) { + if (dcs->guest_domid) { + int rc2 = libxl_domain_destroy(CTX, dcs->guest_domid); + if (rc2) + LOG(ERROR, "unable to destroy domain %d following" + " failed creation", dcs->guest_domid); + } + dcs->guest_domid = -1; + } + dcs->callback(egc, dcs, rc, dcs->guest_domid); } +/*----- application-facing domain creation interface -----*/ + +typedef struct { + libxl__domain_create_state dcs; + uint32_t *domid_out; +} libxl__app_domain_create_state; + +static void domain_create_cb(libxl__egc *egc, + libxl__domain_create_state *dcs, + int rc, uint32_t domid); + +static int do_domain_create(libxl_ctx *ctx, libxl_domain_config *d_config, + libxl_console_ready cb, void *priv, uint32_t *domid, + int restore_fd, const libxl_asyncop_how *ao_how) +{ + AO_CREATE(ctx, 0, ao_how); + libxl__app_domain_create_state *cdcs; + + GCNEW(cdcs); + cdcs->dcs.ao = ao; + cdcs->dcs.guest_config = d_config; + cdcs->dcs.restore_fd = restore_fd; + cdcs->dcs.console_cb = cb; + cdcs->dcs.console_cb_priv = priv; + cdcs->dcs.callback = domain_create_cb; + cdcs->domid_out = domid; + + initiate_domain_create(egc, &cdcs->dcs); + + return AO_INPROGRESS; +} + +static void domain_create_cb(libxl__egc *egc, + libxl__domain_create_state *dcs, + int rc, uint32_t domid) +{ + libxl__app_domain_create_state *cdcs = CONTAINER_OF(dcs, *cdcs, dcs); + STATE_AO_GC(cdcs->dcs.ao); + + if (!rc) + *cdcs->domid_out = domid; + + libxl__ao_complete(egc, ao, rc); +} + int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config, - libxl_console_ready cb, void *priv, uint32_t *domid) + libxl_console_ready cb, void *priv, + uint32_t *domid, + const libxl_asyncop_how *ao_how) { - GC_INIT(ctx); - int rc; - rc = do_domain_create(gc, d_config, cb, priv, domid, -1); - GC_FREE; - return rc; + return do_domain_create(ctx, d_config, cb, priv, domid, -1, ao_how); } int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config, - libxl_console_ready cb, void *priv, uint32_t *domid, int restore_fd) + libxl_console_ready cb, void *priv, + uint32_t *domid, int restore_fd, + const libxl_asyncop_how *ao_how) { - GC_INIT(ctx); - int rc; - rc = do_domain_create(gc, d_config, cb, priv, domid, restore_fd); - GC_FREE; - return rc; + return do_domain_create(ctx, d_config, cb, priv, domid, restore_fd, ao_how); } /* diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 725c3c0..4ad7d02 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -669,24 +669,28 @@ retry_transaction: return 0; } -static int libxl__create_stubdom(libxl__gc *gc, - int guest_domid, - libxl_domain_config *guest_config, - libxl__domain_build_state *d_state, - libxl__spawner_starting **starting_r) +static void spawn_stubdom_pvqemu_cb(libxl__egc *egc, + libxl__dm_spawn_state *stubdom_dmss, + int rc); + +void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss) { + STATE_AO_GC(sdss->dm.spawn.ao); libxl_ctx *ctx = libxl__gc_owner(gc); int i, num_console = STUBDOM_SPECIAL_CONSOLES, ret; libxl__device_console *console; - libxl_domain_config dm_config[1]; libxl_device_vfb vfb; libxl_device_vkb vkb; - libxl__domain_build_state stubdom_state[1]; - uint32_t dm_domid; char **args; struct xs_permissions perm[2]; xs_transaction_t t; - libxl__spawner_starting *dm_starting = 0; + + /* convenience aliases */ + libxl_domain_config *const dm_config = &sdss->dm_config; + libxl_domain_config *const guest_config = sdss->dm.guest_config; + const int guest_domid = sdss->dm.guest_domid; + libxl__domain_build_state *const d_state = sdss->dm.build_state; + libxl__domain_build_state *const stubdom_state = &sdss->dm_state; if (guest_config->b_info.device_model_version ! LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL) { @@ -694,6 +698,8 @@ static int libxl__create_stubdom(libxl__gc *gc, goto out; } + sdss->pvqemu.guest_domid = 0; + libxl_domain_create_info_init(&dm_config->c_info); dm_config->c_info.type = LIBXL_DOMAIN_TYPE_PV; dm_config->c_info.name = libxl__sprintf(gc, "%s-dm", @@ -741,10 +747,10 @@ static int libxl__create_stubdom(libxl__gc *gc, dm_config->num_vkbs = 1; /* fixme: this function can leak the stubdom if it fails */ - dm_domid = 0; - ret = libxl__domain_make(gc, &dm_config->c_info, &dm_domid); + ret = libxl__domain_make(gc, &dm_config->c_info, &sdss->pvqemu.guest_domid); if (ret) goto out; + uint32_t dm_domid = sdss->pvqemu.guest_domid; ret = libxl__domain_build(gc, &dm_config->b_info, dm_domid, stubdom_state); if (ret) goto out; @@ -852,42 +858,67 @@ retry_transaction: goto out_free; } - if (libxl__create_xenpv_qemu(gc, dm_domid, - dm_config, - stubdom_state, - &dm_starting) < 0) { - ret = ERROR_FAIL; - goto out_free; - } - if (libxl__confirm_device_model_startup(gc, d_state, dm_starting) < 0) { - ret = ERROR_FAIL; - goto out_free; - } - - libxl_domain_unpause(ctx, dm_domid); + sdss->pvqemu.guest_domid = dm_domid; + sdss->pvqemu.guest_config = &sdss->dm_config; + sdss->pvqemu.build_state = &sdss->dm_state; + sdss->pvqemu.callback = spawn_stubdom_pvqemu_cb; - if (starting_r) { - *starting_r = calloc(1, sizeof(libxl__spawner_starting)); - (*starting_r)->domid = guest_domid; - (*starting_r)->dom_path = libxl__xs_get_dompath(gc, guest_domid); - (*starting_r)->for_spawn = NULL; - } + libxl__spawn_local_dm(egc, &sdss->pvqemu); - ret = 0; + free(args); + return; out_free: free(args); out: - return ret; + assert(ret); + spawn_stubdom_pvqemu_cb(egc, &sdss->pvqemu, ret); } -int libxl__create_device_model(libxl__gc *gc, - int domid, - libxl_domain_config *guest_config, - libxl__domain_build_state *state, - libxl__spawner_starting **starting_r) +static void spawn_stubdom_pvqemu_cb(libxl__egc *egc, + libxl__dm_spawn_state *stubdom_dmss, + int rc) { - libxl_ctx *ctx = libxl__gc_owner(gc); + libxl__stub_dm_spawn_state *sdss + CONTAINER_OF(stubdom_dmss, *sdss, pvqemu); + STATE_AO_GC(sdss->dm.spawn.ao); + uint32_t dm_domid = sdss->pvqemu.guest_domid; + + if (rc) goto out; + + rc = libxl_domain_unpause(CTX, dm_domid); + if (rc) goto out; + + out: + if (rc) { + if (dm_domid) + libxl_domain_destroy(CTX, dm_domid); + } + sdss->callback(egc, &sdss->dm, rc); +} + +/* callbacks passed to libxl__spawn_spawn */ +static void device_model_confirm(libxl__egc *egc, libxl__spawn_state *spawn, + const char *xsdata); +static void device_model_startup_failed(libxl__egc *egc, + libxl__spawn_state *spawn); + +/* our "next step" function, called from those callbacks and elsewhere */ +static void device_model_spawn_outcome(libxl__egc *egc, + libxl__dm_spawn_state *dmss, + int rc); + +void libxl__spawn_local_dm(libxl__egc *egc, libxl__dm_spawn_state *dmss) +{ + /* convenience aliases */ + const int domid = dmss->guest_domid; + libxl__domain_build_state *const state = dmss->build_state; + libxl__spawn_state *const spawn = &dmss->spawn; + + STATE_AO_GC(dmss->spawn.ao); + + libxl_ctx *ctx = CTX; + libxl_domain_config *guest_config = dmss->guest_config; const libxl_domain_create_info *c_info = &guest_config->c_info; const libxl_domain_build_info *b_info = &guest_config->b_info; const libxl_vnc_info *vnc = libxl__dm_vnc(guest_config); @@ -895,15 +926,13 @@ int libxl__create_device_model(libxl__gc *gc, int logfile_w, null; int rc; char **args, **arg; - libxl__spawner_starting buf_starting, *p; xs_transaction_t t; char *vm_path; char **pass_stuff; const char *dm; if (libxl_defbool_val(b_info->device_model_stubdomain)) { - rc = libxl__create_stubdom(gc, domid, guest_config, state, starting_r); - goto out; + abort(); } dm = libxl__domain_device_model(gc, b_info); @@ -947,25 +976,8 @@ int libxl__create_device_model(libxl__gc *gc, free(logfile); null = open("/dev/null", O_RDONLY); - if (starting_r) { - rc = ERROR_NOMEM; - *starting_r = calloc(1, sizeof(libxl__spawner_starting)); - if (!*starting_r) - goto out_close; - p = *starting_r; - p->for_spawn = calloc(1, sizeof(libxl__spawn_starting)); - } else { - p = &buf_starting; - p->for_spawn = NULL; - } - - p->domid = domid; - p->dom_path = libxl__xs_get_dompath(gc, domid); - p->pid_path = "image/device-model-pid"; - if (!p->dom_path) { - rc = ERROR_FAIL; - goto out_close; - } + const char *dom_path = libxl__xs_get_dompath(gc, domid); + spawn->pidpath = GCSPRINTF("%s/%s", dom_path, "image/device-model-pid"); if (vnc && vnc->passwd) { /* This xenstore key will only be used by qemu-xen-traditionnal. @@ -973,7 +985,7 @@ int libxl__create_device_model(libxl__gc *gc, retry_transaction: /* Find uuid and the write the vnc password to xenstore for qemu. */ t = xs_transaction_start(ctx->xsh); - vm_path = libxl__xs_read(gc,t,libxl__sprintf(gc, "%s/vm", p->dom_path)); + vm_path = libxl__xs_read(gc,t,libxl__sprintf(gc, "%s/vm", dom_path)); if (vm_path) { /* Now write the vncpassword into it. */ pass_stuff = libxl__calloc(gc, 3, sizeof(char *)); @@ -990,8 +1002,15 @@ retry_transaction: for (arg = args; *arg; arg++) LIBXL__LOG(CTX, XTL_DEBUG, " %s", *arg); - rc = libxl__spawn_spawn(gc, p->for_spawn, "device model", - libxl_spawner_record_pid, p); + spawn->what = GCSPRINTF("domain %d device model", domid); + spawn->xspath = GCSPRINTF("/local/domain/0/device-model/%d/state", domid); + spawn->timeout_ms = LIBXL_DEVICE_MODEL_START_TIMEOUT * 1000; + spawn->pidpath = GCSPRINTF("%s/image/device-model-pid", dom_path); + spawn->midproc_cb = libxl__spawn_record_pid; + spawn->confirm_cb = device_model_confirm; + spawn->failure_cb = device_model_startup_failed; + + rc = libxl__spawn_spawn(egc, spawn); if (rc < 0) goto out_close; if (!rc) { /* inner child */ @@ -1006,30 +1025,61 @@ out_close: close(logfile_w); free(args); out: - return rc; + if (rc) + device_model_spawn_outcome(egc, dmss, rc); +} + + +static void device_model_confirm(libxl__egc *egc, libxl__spawn_state *spawn, + const char *xsdata) +{ + libxl__dm_spawn_state *dmss = CONTAINER_OF(spawn, *dmss, spawn); + STATE_AO_GC(spawn->ao); + + if (!xsdata) + return; + + if (strcmp(xsdata, "running")) + return; + + libxl__spawn_detach(gc, spawn); + + device_model_spawn_outcome(egc, dmss, 0); } +static void device_model_startup_failed(libxl__egc *egc, + libxl__spawn_state *spawn) +{ + libxl__dm_spawn_state *dmss = CONTAINER_OF(spawn, *dmss, spawn); + device_model_spawn_outcome(egc, dmss, ERROR_FAIL); +} -int libxl__confirm_device_model_startup(libxl__gc *gc, - libxl__domain_build_state *state, - libxl__spawner_starting *starting) +static void device_model_spawn_outcome(libxl__egc *egc, + libxl__dm_spawn_state *dmss, + int rc) { - char *path; - int domid = starting->domid; - int ret, ret2; - path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/state", domid); - ret = libxl__spawn_confirm_offspring_startup(gc, - LIBXL_DEVICE_MODEL_START_TIMEOUT, - "Device Model", path, "running", starting); + STATE_AO_GC(dmss->spawn.ao); + int ret2; + + if (rc) + LOG(ERROR, "%s: spawn failed (rc=%d)", dmss->spawn.what, rc); + + libxl__domain_build_state *state = dmss->build_state; + if (state->saved_state) { ret2 = unlink(state->saved_state); - if (ret2) LIBXL__LOG_ERRNO(CTX, XTL_ERROR, - "failed to remove device-model state %s\n", - state->saved_state); - /* Do not clobber spawn_confirm error code with unlink error code. */ - if (!ret) ret = ret2; + if (ret2) { + LOGE(ERROR, "%s: failed to remove device-model state %s", + dmss->spawn.what, state->saved_state); + rc = ERROR_FAIL; + goto out; + } } - return ret; + + rc = 0; + + out: + dmss->callback(egc, dmss, rc); } int libxl__destroy_device_model(libxl__gc *gc, uint32_t domid) @@ -1131,15 +1181,6 @@ out: return ret; } -int libxl__create_xenpv_qemu(libxl__gc *gc, uint32_t domid, - libxl_domain_config *guest_config, - libxl__domain_build_state *state, - libxl__spawner_starting **starting_r) -{ - libxl__create_device_model(gc, domid, guest_config, state, starting_r); - return 0; -} - /* * Local variables: * mode: C diff --git a/tools/libxl/libxl_exec.c b/tools/libxl/libxl_exec.c index 2ee2154..882c048 100644 --- a/tools/libxl/libxl_exec.c +++ b/tools/libxl/libxl_exec.c @@ -127,29 +127,35 @@ void libxl_report_child_exitstatus(libxl_ctx *ctx, } } -void libxl_spawner_record_pid(void *for_spawn, pid_t innerchild) +int libxl__spawn_record_pid(libxl__gc *gc, libxl__spawn_state *spawn, + pid_t innerchild) { - libxl__spawner_starting *starting = for_spawn; - struct xs_handle *xsh; - char *path = NULL, *pid = NULL; - int len; - - if (asprintf(&path, "%s/%s", starting->dom_path, starting->pid_path) < 0) - goto out; + struct xs_handle *xsh = NULL; + const char *pid = NULL; + int rc, xsok; - len = asprintf(&pid, "%d", innerchild); - if (len < 0) - goto out; + pid = GCSPRINTF("%d", innerchild); /* we mustn''t use the parent''s handle in the child */ xsh = xs_daemon_open(); + if (!xsh) { + LOGE(ERROR, "write %s = %s: xenstore reopen failed", + spawn->pidpath, pid); + rc = ERROR_FAIL; goto out; + } - xs_write(xsh, XBT_NULL, path, pid, len); + xsok = xs_write(xsh, XBT_NULL, spawn->pidpath, pid, strlen(pid)); + if (!xsok) { + LOGE(ERROR, + "write %s = %s: xenstore write failed", spawn->pidpath, pid); + rc = ERROR_FAIL; goto out; + } + + rc = 0; - xs_daemon_close(xsh); out: - free(path); - free(pid); + if (xsh) xs_daemon_close(xsh); + return rc ? SIGTERM : 0; } int libxl__wait_for_offspring(libxl__gc *gc, @@ -184,19 +190,9 @@ int libxl__wait_for_offspring(libxl__gc *gc, tv.tv_sec = timeout; tv.tv_usec = 0; nfds = xs_fileno(xsh) + 1; - if (spawning && spawning->fd > xs_fileno(xsh)) - nfds = spawning->fd + 1; + assert(!spawning); while (rc > 0 || (!rc && tv.tv_sec > 0)) { - if ( spawning ) { - rc = libxl__spawn_check(gc, spawning); - if ( rc ) { - LIBXL__LOG(ctx, LIBXL__LOG_ERROR, - "%s died during startup", what); - rc = -1; - goto err_died; - } - } p = xs_read(xsh, XBT_NULL, path, &len); if ( NULL == p ) goto again; @@ -218,8 +214,6 @@ again: free(p); FD_ZERO(&rfds); FD_SET(xs_fileno(xsh), &rfds); - if (spawning) - FD_SET(spawning->fd, &rfds); rc = select(nfds, &rfds, NULL, NULL, &tv); if (rc > 0) { if (FD_ISSET(xs_fileno(xsh), &rfds)) { @@ -229,207 +223,215 @@ again: else goto again; } - if (spawning && FD_ISSET(spawning->fd, &rfds)) { - unsigned char dummy; - if (read(spawning->fd, &dummy, sizeof(dummy)) != 1) - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_DEBUG, - "failed to read spawn status pipe"); - } } } LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "%s not ready", what); -err_died: + xs_unwatch(xsh, path, path); xs_daemon_close(xsh); err: return -1; } -static int detach_offspring(libxl__gc *gc, - libxl__spawner_starting *starting) -{ - int rc; - rc = libxl__spawn_detach(gc, starting->for_spawn); - if (starting->for_spawn) - free(starting->for_spawn); - free(starting); - return rc; -} -int libxl__spawn_confirm_offspring_startup(libxl__gc *gc, - uint32_t timeout, char *what, - char *path, char *state, - libxl__spawner_starting *starting) -{ - int detach; - int problem = libxl__wait_for_offspring(gc, starting->domid, timeout, what, - path, state, - starting->for_spawn, NULL, NULL); - detach = detach_offspring(gc, starting); - return problem ? problem : detach; -} +/*----- spawn implementation -----*/ -static int libxl__set_fd_flag(libxl__gc *gc, int fd, int flag) -{ - int flags; +/* + * Full set of possible states of a libxl__spawn_state and its _detachable: + * + * ss-> ss-> ss-> | ssd-> ssd-> + * timeout xswatch ssd | mid ss + * - Undefined undef undef no | - - + * - Idle Idle Idle no | - - + * - Active Active Active yes | Active yes + * - Partial Active/Idle Active/Idle maybe | Active/Idle yes (if exists) + * - Detached - - - | Active no + * + * When in state Detached, the middle process has been sent a SIGKILL. + */ - flags = fcntl(fd, F_GETFL); - if (flags == -1) - return ERROR_FAIL; +/* Event callbacks. */ +static void spawn_watch_event(libxl__egc *egc, libxl__ev_xswatch *xsw, + const char *watch_path, const char *event_path); +static void spawn_timeout(libxl__egc *egc, libxl__ev_time *ev, + const struct timeval *requested_abs); +static void spawn_middle_death(libxl__egc *egc, libxl__ev_child *childw, + pid_t pid, int status); - flags |= flag; +/* Precondition: Partial. Results: Detached. */ +static void spawn_cleanup(libxl__gc *gc, libxl__spawn_state *ss); - if (fcntl(fd, F_SETFL, flags) == -1) - return ERROR_FAIL; +/* Precondition: Partial; caller has logged failure reason. + * Results: Caller notified of failure; + * after return, ss may be completely invalid as caller may reuse it */ +static void spawn_failed(libxl__egc *egc, libxl__spawn_state *ss); - return 0; +void libxl__spawn_init(libxl__spawn_state *ss) +{ + libxl__ev_time_init(&ss->timeout); + libxl__ev_xswatch_init(&ss->xswatch); + ss->ssd = 0; } -int libxl__spawn_spawn(libxl__gc *gc, - libxl__spawn_starting *for_spawn, - const char *what, - void (*intermediate_hook)(void *for_spawn, - pid_t innerchild), - void *hook_data) +int libxl__spawn_spawn(libxl__egc *egc, libxl__spawn_state *ss) { - libxl_ctx *ctx = libxl__gc_owner(gc); - pid_t child, got; + STATE_AO_GC(ss->ao); + int r; + pid_t child; int status, rc; - pid_t intermediate; - int pipes[2]; - unsigned char dummy = 0; - - if (for_spawn) { - for_spawn->what = strdup(what); - if (!for_spawn->what) return ERROR_NOMEM; - - if (libxl_pipe(ctx, pipes) < 0) - goto err_parent; - if (libxl__set_fd_flag(gc, pipes[0], O_NONBLOCK) < 0 || - libxl__set_fd_flag(gc, pipes[1], O_NONBLOCK) < 0) - goto err_parent_pipes; - } - intermediate = libxl_fork(ctx); - if (intermediate ==-1) - goto err_parent_pipes; + libxl__spawn_init(ss); + ss->ssd = libxl__zalloc(0, sizeof(*ss->ssd)); + libxl__ev_child_init(&ss->ssd->mid); + + rc = libxl__ev_time_register_rel(gc, &ss->timeout, + spawn_timeout, ss->timeout_ms); + if (rc) goto out_err; - if (intermediate) { + rc = libxl__ev_xswatch_register(gc, &ss->xswatch, + spawn_watch_event, ss->xspath); + if (rc) goto out_err; + + pid_t middle = libxl__ev_child_fork(gc, &ss->ssd->mid, spawn_middle_death); + if (middle ==-1) { rc = ERROR_FAIL; goto out_err; } + + if (middle) { /* parent */ - if (for_spawn) { - for_spawn->intermediate = intermediate; - for_spawn->fd = pipes[0]; - close(pipes[1]); - } return 1; } - /* we are now the intermediate process */ - if (for_spawn) close(pipes[0]); + /* we are now the middle process */ child = fork(); if (child == -1) exit(255); if (!child) { - if (for_spawn) close(pipes[1]); return 0; /* caller runs child code */ } - intermediate_hook(hook_data, child); - - if (!for_spawn) _exit(0); /* just detach then */ - - got = waitpid(child, &status, 0); - assert(got == child); - - rc = (WIFEXITED(status) ? WEXITSTATUS(status) : - WIFSIGNALED(status) && WTERMSIG(status) < 127 - ? WTERMSIG(status)+128 : -1); - if (for_spawn) { - if (write(pipes[1], &dummy, sizeof(dummy)) != 1) - perror("libxl__spawn_spawn: unable to signal child exit to parent"); + int failsig = ss->midproc_cb(gc, ss, child); + if (failsig) { + kill(child, failsig); + _exit(127); } - _exit(rc); - err_parent_pipes: - if (for_spawn) { - close(pipes[0]); - close(pipes[1]); + for (;;) { + pid_t got = waitpid(child, &status, 0); + if (got == -1) { + assert(errno == EINTR); + continue; + } + assert(got == child); + break; } - err_parent: - if (for_spawn) free(for_spawn->what); + r = (WIFEXITED(status) && WEXITSTATUS(status) <= 127 ? WEXITSTATUS(status) : + WIFSIGNALED(status) && WTERMSIG(status) < 127 ? WTERMSIG(status)+128 : + -1); + _exit(r); - return ERROR_FAIL; + out_err: + spawn_cleanup(gc, ss); + return rc; } -static void report_spawn_intermediate_status(libxl__gc *gc, - libxl__spawn_starting *for_spawn, - int status) +static void spawn_cleanup(libxl__gc *gc, libxl__spawn_state *ss) { - if (!WIFEXITED(status)) { - libxl_ctx *ctx = libxl__gc_owner(gc); - char *intermediate_what; - /* intermediate process did the logging itself if it exited */ - if ( asprintf(&intermediate_what, - "%s intermediate process (startup monitor)", - for_spawn->what) < 0 ) - intermediate_what = "intermediate process (startup monitor)"; - libxl_report_child_exitstatus(ctx, LIBXL__LOG_ERROR, intermediate_what, - for_spawn->intermediate, status); + int r; + + libxl__ev_time_deregister(gc, &ss->timeout); + libxl__ev_xswatch_deregister(gc, &ss->xswatch); + + libxl__spawn_state_detachable *ssd = ss->ssd; + if (ssd) { + if (libxl__ev_child_inuse(&ssd->mid)) { + pid_t child = ssd->mid.pid; + r = kill(child, SIGKILL); + if (r && errno != ESRCH) + LOGE(WARN, "%s: failed to kill intermediate child (pid=%lu)", + ss->what, (unsigned long)child); + } + + /* disconnect the ss and ssd from each other */ + ssd->ss = 0; + ss->ssd = 0; } } -int libxl__spawn_detach(libxl__gc *gc, - libxl__spawn_starting *for_spawn) +static void spawn_failed(libxl__egc *egc, libxl__spawn_state *ss) { - libxl_ctx *ctx = libxl__gc_owner(gc); - int r, status; - pid_t got; - int rc = 0; + EGC_GC; + spawn_cleanup(gc, ss); + ss->failure_cb(egc, ss); /* must be last; callback may do anything to ss */ +} - if (!for_spawn) return 0; +static void spawn_timeout(libxl__egc *egc, libxl__ev_time *ev, + const struct timeval *requested_abs) +{ + /* Before event, was Active; is now Partial. */ + EGC_GC; + libxl__spawn_state *ss = CONTAINER_OF(ev, *ss, timeout); + LOG(ERROR, "%s: startup timed out", ss->what); + spawn_failed(egc, ss); /* must be last */ +} - if (for_spawn->intermediate) { - r = kill(for_spawn->intermediate, SIGKILL); - if (r) { - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, - "could not kill %s intermediate process [%ld]", - for_spawn->what, - (unsigned long)for_spawn->intermediate); - abort(); /* things are very wrong */ - } - got = waitpid(for_spawn->intermediate, &status, 0); - assert(got == for_spawn->intermediate); - if (!(WIFSIGNALED(status) && WTERMSIG(status) == SIGKILL)) { - report_spawn_intermediate_status(gc, for_spawn, status); - rc = ERROR_FAIL; - } - for_spawn->intermediate = 0; +static void spawn_watch_event(libxl__egc *egc, libxl__ev_xswatch *xsw, + const char *watch_path, const char *event_path) +{ + /* On entry, is Active. */ + EGC_GC; + libxl__spawn_state *ss = CONTAINER_OF(xsw, *ss, xswatch); + char *p = libxl__xs_read(gc, 0, ss->xspath); + if (!p && errno != ENOENT) { + LOG(ERROR, "%s: xenstore read of %s failed", ss->what, ss->xspath); + spawn_failed(egc, ss); /* must be last */ + return; } - - free(for_spawn->what); - for_spawn->what = 0; - - return rc; + ss->confirm_cb(egc, ss, p); /* must be last */ } -int libxl__spawn_check(libxl__gc *gc, libxl__spawn_starting *for_spawn) +static void spawn_middle_death(libxl__egc *egc, libxl__ev_child *childw, + pid_t pid, int status) + /* Before event, was Active or Detached; + * is now Active or Detached except that ssd->mid is Idle */ { - pid_t got; - int status; - - if (!for_spawn) return 0; + EGC_GC; + libxl__spawn_state_detachable *ssd = CONTAINER_OF(childw, *ssd, mid); + libxl__spawn_state *ss = ssd->ss; - assert(for_spawn->intermediate); - got = waitpid(for_spawn->intermediate, &status, WNOHANG); - if (!got) return 0; - - assert(got == for_spawn->intermediate); - report_spawn_intermediate_status(gc, for_spawn, status); + if (!WIFEXITED(status)) { + const char *what + GCSPRINTF("%s intermediate process (startup monitor)", + ss ? ss->what : "(detached)"); + int loglevel = ss ? XTL_ERROR : XTL_WARN; + libxl_report_child_exitstatus(CTX, loglevel, what, pid, status); + } else if (ss) { /* otherwise it was supposed to be a daemon by now */ + if (!status) + LOG(ERROR, "%s [%ld]: unexpectedly exited with exit status 0," + " when we were waiting for it to confirm startup", + ss->what, (unsigned long)pid); + else if (status <= 127) + LOG(ERROR, "%s [%ld]: failed startup with non-zero exit status %d", + ss->what, (unsigned long)pid, status); + else if (status < 255) { + int sig = status - 128; + const char *str = strsignal(sig); + if (str) + LOG(ERROR, "%s [%ld]: died during startup due to fatal" + " signal %s", ss->what, (unsigned long)pid, str); + else + LOG(ERROR, "%s [%ld]: died during startup due to unknown fatal" + " signal number %d", ss->what, (unsigned long)pid, sig); + } + ss->ssd = 0; /* detatch the ssd to make the ss be in state Partial */ + spawn_failed(egc, ss); /* must be last use of ss */ + } + free(ssd); +} - for_spawn->intermediate = 0; - return ERROR_FAIL; +void libxl__spawn_detach(libxl__gc *gc, libxl__spawn_state *ss) +{ + spawn_cleanup(gc, ss); } /* diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 6fb99f6..dc84881 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -847,75 +847,198 @@ _hidden int libxl__create_pci_backend(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev, int num); _hidden int libxl__device_pci_destroy_all(libxl__gc *gc, uint32_t domid); -/* xl_exec */ +/* + *----- spawn ----- + * + * Higher-level double-fork and separate detach eg as for device models + * + * Each libxl__spawn_state is in one of the conventional states + * Undefined, Idle, Active + */ - /* higher-level double-fork and separate detach eg as for device models */ +typedef struct libxl__obsolete_spawn_starting libxl__spawn_starting; +/* this type is never defined, so no objects of this type exist + * fixme-ao This should go away completely. */ -typedef struct { - /* put this in your own status structure as returned to application */ - /* all fields are private to libxl_spawn_... */ - pid_t intermediate; - int fd; - char *what; /* malloc''d in spawn_spawn */ -} libxl__spawn_starting; +typedef struct libxl__spawn_state libxl__spawn_state; -typedef struct { - char *dom_path; /* from libxl_malloc, only for libxl_spawner_record_pid */ - const char *pid_path; /* only for libxl_spawner_record_pid */ - int domid; - libxl__spawn_starting *for_spawn; -} libxl__spawner_starting; +/* Clears out a spawn state; idempotent. */ +_hidden void libxl__spawn_init(libxl__spawn_state*); /* - * libxl__spawn_spawn - Create a new process - * gc: allocation pool - * for_spawn: malloc''d pointer to libxl__spawn_starting (optional) - * what: string describing the spawned process - * intermediate_hook: helper to record pid, such as libxl_spawner_record_pid - * hook_data: data to pass to the hook function + * libxl__spawn_spawn - Create a new process which will become daemonic + * Forks twice, to allow the child to detach entirely from the parent. + * + * We call the two generated processes the "middle child" (result of + * the first fork) and the "inner child" (result of the second fork + * which takes place in the middle child). + * + * The inner child must soon exit or exec. It must also soon exit or + * notify the parent of its successful startup by writing to the + * xenstore path xspath. + * + * The user (in the parent) will be called back (confirm_cb) every + * time that xenstore path is modified. + * + * In both children, the ctx is not fully usable: gc and logging + * operations are OK, but operations on Xen and xenstore are not. + * (The restrictions are the same as those which apply to children + * made with libxl__ev_child_fork.) + * + * midproc_cb will be called in the middle child, with the pid of the + * inner child; this could for example record the pid. midproc_cb + * should be fast, and should return. It will be called (reentrantly) + * within libxl__spawn_init. + * + * failure_cb will be called in the parent on failure of the + * intermediate or final child; an error message will have been + * logged. + * + * confirm_cb and failure_cb will not be called reentrantly from + * within libxl__spawn_spawn. + * + * what: string describing the spawned process, used for logging * * Logs errors. A copy of "what" is taken. * Return values: - * < 0 error, for_spawn need not be detached - * +1 caller is the parent, must call detach on *for_spawn eventually + * < 0 error, *spawn is now Idle and need not be detached + * +1 caller is the parent, *spawn is Active and must eventually be detached * 0 caller is now the inner child, should probably call libxl__exec - * Caller, may pass 0 for for_spawn, in which case no need to detach. + * + * The spawn state must be Undefined or Idle on entry. */ -_hidden int libxl__spawn_spawn(libxl__gc *gc, - libxl__spawn_starting *for_spawn, - const char *what, - void (*intermediate_hook)(void *for_spawn, pid_t innerchild), - void *hook_data); +_hidden int libxl__spawn_spawn(libxl__egc *egc, libxl__spawn_state *spawn); /* - * libxl_spawner_record_pid - Record given pid in xenstore - * for_spawn: malloc''d pointer to libxl__spawn_starting (optional) - * innerchild: pid of the child + * libxl__spawn_detach - Detaches the daemonic child. + * + * Works by killing the intermediate process from spawn_spawn. + * After this function returns, failures of either child are no + * longer reported via failure_cb. + * + * If called before the inner child has been created, this may prevent + * it from running at all. Thus this should be called only when the + * inner child has notified that it is ready. Normally it will be + * called from within confirm_cb. * - * This function is passed as intermediate_hook to libxl__spawn_spawn. + * Logs errors. + * + * The spawn state must be Active or Idle on entry and will be Idle + * on return. */ -_hidden void libxl_spawner_record_pid(void *for_spawn, pid_t innerchild); +_hidden void libxl__spawn_detach(libxl__gc *gc, libxl__spawn_state*); /* - * libxl__spawn_confirm_offspring_startup - Wait for child state - * gc: allocation pool - * timeout: how many seconds to wait for the child - * what: string describing the spawned process - * path: path to the state file in xenstore - * state: expected string to wait for in path (optional) - * starting: malloc''d pointer to libxl__spawner_starting + * If successful, this should return 0. * - * Returns 0 on success, and < 0 on error. + * Otherwise it should return a signal number, which will be + * sent to the inner child; the overall spawn will then fail. + */ +typedef int /* signal number */ +libxl__spawn_midproc_cb(libxl__gc*, libxl__spawn_state*, pid_t inner); + +/* + * Called if the spawn failed. The reason will have been logged. + * The spawn state will be Idle on entry to the callback (and + * it may be reused immediately if desired). + */ +typedef void libxl__spawn_failure_cb(libxl__egc*, libxl__spawn_state*); + +/* + * Called when the xspath watch triggers. xspath will have been read + * and the result placed in xsdata; if that failed because the key + * didn''t exist, xspath==0. (If it failed for some other reason, + * the spawn machinery calls failure_cb instead.) * - * This function waits the given timeout for the given path to appear - * in xenstore, and optionally for state in path. - * The intermediate process created in libxl__spawn_spawn is killed. - * The memory referenced by starting->for_spawn and starting is free''d. + * If the child has indicated its successful startup, or a failure + * has occurred, this should call libxl__spawn_detach. + * + * If the child is still starting up, should simply return, doing + * nothing. + * + * The spawn state will be Active on entry to the callback; there + * are no restrictions on the state on return; it may even have + * been detached and reused. */ -_hidden int libxl__spawn_confirm_offspring_startup(libxl__gc *gc, - uint32_t timeout, char *what, - char *path, char *state, - libxl__spawner_starting *starting); +typedef void libxl__spawn_confirm_cb(libxl__egc*, libxl__spawn_state*, + const char *xsdata); + +typedef struct { + /* Private to the spawn implementation. + */ + /* This separate struct, from malloc, allows us to "detach" + * the child and reap it later, when our user has gone + * away and freed its libxl__spawn_state */ + struct libxl__spawn_state *ss; + libxl__ev_child mid; +} libxl__spawn_state_detachable; + +struct libxl__spawn_state { + /* must be filled in by user and remain valid */ + libxl__ao *ao; + const char *what; + const char *xspath; + const char *pidpath; /* only used by libxl__spawn_midproc_record_pid */ + int timeout_ms; /* -1 means forever */ + libxl__spawn_midproc_cb *midproc_cb; + libxl__spawn_failure_cb *failure_cb; + libxl__spawn_confirm_cb *confirm_cb; + + /* remaining fields are private to libxl_spawn_... */ + libxl__ev_time timeout; + libxl__ev_xswatch xswatch; + libxl__spawn_state_detachable *ssd; +}; + +static inline int libxl__spawn_inuse(libxl__spawn_state *ss) + { return !!ss->ssd; } + +/* + * libxl_spawner_record_pid - Record given pid in xenstore + * + * This function can be passed directly as an intermediate_hook to + * libxl__spawn_spawn. On failure, returns the value SIGTERM. + */ +_hidden int libxl__spawn_record_pid(libxl__gc*, libxl__spawn_state*, + pid_t innerchild); + +/*----- device model creation -----*/ + +/* First layer; wraps libxl__spawn_spawn. */ + +typedef struct libxl__dm_spawn_state libxl__dm_spawn_state; + +typedef void libxl__dm_spawn_cb(libxl__egc *egc, libxl__dm_spawn_state*, + int rc /* if !0, error was logged */); + +struct libxl__dm_spawn_state { + /* mixed - spawn.ao must be initialised by user; rest is private: */ + libxl__spawn_state spawn; + /* filled in by user, must remain valid: */ + uint32_t guest_domid; /* domain being served */ + libxl_domain_config *guest_config; + libxl__domain_build_state *build_state; /* relates to guest_domid */ + libxl__dm_spawn_cb *callback; +}; + +_hidden void libxl__spawn_local_dm(libxl__egc *egc, libxl__dm_spawn_state*); + +/* Stubdom device models. */ + +typedef struct { + /* Mixed - user must fill in public parts EXCEPT callback, + * which may be undefined on entry. (See above for details) */ + libxl__dm_spawn_state dm; /* the stub domain device model */ + /* filled in by user, must remain valid: */ + libxl__dm_spawn_cb *callback; /* called as callback(,&sdss->dm,) */ + /* private to libxl__spawn_stub_dm: */ + libxl_domain_config dm_config; + libxl__domain_build_state dm_state; + libxl__dm_spawn_state pvqemu; +} libxl__stub_dm_spawn_state; + +_hidden void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state*); + /* * libxl__wait_for_offspring - Wait for child state @@ -948,31 +1071,6 @@ _hidden int libxl__wait_for_offspring(libxl__gc *gc, void *userdata), void *check_callback_userdata); -/* - * libxl__spawn_detach - Kill intermediate process from spawn_spawn - * gc: allocation pool - * for_spawn: malloc''d pointer to libxl__spawn_starting (optional) - * - * Returns 0 on success, and < 0 on error. - * - * Logs errors. Idempotent, but only permitted after successful - * call to libxl__spawn_spawn, and no point calling it again if it fails. - */ -_hidden int libxl__spawn_detach(libxl__gc *gc, - libxl__spawn_starting *for_spawn); - -/* - * libxl__spawn_check - Check intermediate child process - * gc: allocation pool - * for_spawn: malloc''d pointer to libxl__spawn_starting (optional) - * - * Returns 0 on success, and < 0 on error. - * - * Logs errors but also returns them. - * Caller must still call detach. - */ -_hidden int libxl__spawn_check(libxl__gc *gc, - libxl__spawn_starting *for_spawn); /* low-level stuff, for synchronous subprocesses etc. */ @@ -991,15 +1089,6 @@ _hidden int libxl__domain_build(libxl__gc *gc, /* for device model creation */ _hidden const char *libxl__domain_device_model(libxl__gc *gc, const libxl_domain_build_info *info); -_hidden int libxl__create_device_model(libxl__gc *gc, - int domid, - libxl_domain_config *guest_config, - libxl__domain_build_state *state, - libxl__spawner_starting **starting_r); -_hidden int libxl__create_xenpv_qemu(libxl__gc *gc, uint32_t domid, - libxl_domain_config *guest_config, - libxl__domain_build_state *state, - libxl__spawner_starting **starting_r); _hidden int libxl__need_xenpv_qemu(libxl__gc *gc, int nr_consoles, libxl__device_console *consoles, int nr_vfbs, libxl_device_vfb *vfbs, @@ -1007,10 +1096,6 @@ _hidden int libxl__need_xenpv_qemu(libxl__gc *gc, /* Caller must either: pass starting_r==0, or on successful * return pass *starting_r (which will be non-0) to * libxl__confirm_device_model_startup or libxl__detach_device_model. */ -_hidden int libxl__confirm_device_model_startup(libxl__gc *gc, - libxl__domain_build_state *state, - libxl__spawner_starting *starting); -_hidden int libxl__detach_device_model(libxl__gc *gc, libxl__spawner_starting *starting); _hidden int libxl__wait_for_device_model(libxl__gc *gc, uint32_t domid, char *state, libxl__spawn_starting *spawning, @@ -1581,6 +1666,31 @@ _hidden void libxl__bootloader_init(libxl__bootloader_state *bl); _hidden void libxl__bootloader_run(libxl__egc*, libxl__bootloader_state *st); +/*----- Domain creation -----*/ + +typedef struct libxl__domain_create_state libxl__domain_create_state; + +typedef void libxl__domain_create_cb(libxl__egc *egc, + libxl__domain_create_state*, + int rc, uint32_t domid); + +struct libxl__domain_create_state { + /* filled in by user */ + libxl__ao *ao; + libxl_domain_config *guest_config; + int restore_fd; + libxl_console_ready console_cb; + void *console_cb_priv; + libxl__domain_create_cb *callback; + /* private to domain_create */ + int guest_domid; + libxl__domain_build_state build_state; + libxl__stub_dm_spawn_state dmss; + /* If we''re not doing stubdom, we use only dmss.dm, + * for the non-stubdom device model. */ +}; + + /* * Convenience macros. */ diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 45e2c30..621aeaf 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -1695,8 +1695,8 @@ start: if ( restore_file ) { ret = libxl_domain_create_restore(ctx, &d_config, - cb, &child_console_pid, - &domid, restore_fd); + cb, &child_console_pid, + &domid, restore_fd, 0); /* * On subsequent reboot etc we should create the domain, not * restore/migrate-receive it again. @@ -1704,7 +1704,7 @@ start: restore_file = NULL; }else{ ret = libxl_domain_create_new(ctx, &d_config, - cb, &child_console_pid, &domid); + cb, &child_console_pid, &domid, 0); } if ( ret ) goto error_out; -- 1.7.2.5
Ian Jackson
2012-May-11 17:58 UTC
[PATCH 19/27] libxl: set guest_domid even if libxl__domain_make fails
From: Roger Pau Monne <roger.pau@citrix.com> This is needed in order to perform the domain destruction if libxl__domain_make fails. Also move doc comment about error behaviour of libxl__domain_make from implementation to declaration. Signed-off-by: Roger Pau Monne <roger.pau@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> --- tools/libxl/libxl_create.c | 3 +-- tools/libxl/libxl_internal.h | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 9ce107a..5075537 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -396,8 +396,6 @@ out: int libxl__domain_make(libxl__gc *gc, libxl_domain_create_info *info, uint32_t *domid) - /* on entry, libxl_domid_valid_guest(domid) must be false; - * on exit (even error exit), domid may be valid and refer to a domain */ { libxl_ctx *ctx = libxl__gc_owner(gc); int flags, ret, rc; @@ -600,6 +598,7 @@ static void initiate_domain_create(libxl__egc *egc, ret = libxl__domain_make(gc, &d_config->c_info, &domid); if (ret) { LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot make domain: %d", ret); + dcs->guest_domid = domid; ret = ERROR_FAIL; goto error_out; } diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index dc84881..b1ce4d6 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1078,9 +1078,13 @@ _hidden void libxl__exec(int stdinfd, int stdoutfd, int stderrfd, const char *arg0, char **args); // logs errors, never returns /* from xl_create */ + + /* on entry, libxl_domid_valid_guest(domid) must be false; + * on exit (even error exit), domid may be valid and refer to a domain */ _hidden int libxl__domain_make(libxl__gc *gc, libxl_domain_create_info *info, uint32_t *domid); + _hidden int libxl__domain_build(libxl__gc *gc, libxl_domain_build_info *info, uint32_t domid, -- 1.7.2.5
Ian Jackson
2012-May-11 17:58 UTC
[PATCH 20/27] libxl: make libxl_create run bootloader via callback
Change initiate_domain_create to properly use libxl__bootloader_run rather than improperly calling libxl_run_bootloader with NULL ao_how. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Changes since v7: * constify convenience aliases. Changes since v6: * Bugfixes from testing. --- tools/libxl/libxl_create.c | 53 +++++++++++++++++++++++++++++++---------- tools/libxl/libxl_internal.h | 1 + 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 5075537..63cb430 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -569,6 +569,9 @@ static int store_libxl_entry(libxl__gc *gc, uint32_t domid, static void domcreate_devmodel_started(libxl__egc *egc, libxl__dm_spawn_state *dmss, int rc); +static void domcreate_bootloader_done(libxl__egc *egc, + libxl__bootloader_state *bl, + int rc); /* Our own function to clean up and call the user''s callback. * The final call in the sequence. */ @@ -589,6 +592,7 @@ static void initiate_domain_create(libxl__egc *egc, const int restore_fd = dcs->restore_fd; const libxl_console_ready cb = dcs->console_cb; void *const priv = dcs->console_cb_priv; + memset(&dcs->build_state, 0, sizeof(dcs->build_state)); domid = 0; @@ -619,21 +623,43 @@ static void initiate_domain_create(libxl__egc *egc, if (ret) goto error_out; } + dcs->bl.ao = ao; libxl_device_disk *bootdisk d_config->num_disks > 0 ? &d_config->disks[0] : NULL; if (restore_fd < 0 && bootdisk) { - ret = libxl_run_bootloader(ctx, &d_config->b_info, bootdisk, domid, - 0 /* fixme-ao */); - if (ret) { - LIBXL__LOG(ctx, LIBXL__LOG_ERROR, - "failed to run bootloader: %d", ret); - goto error_out; - } + dcs->bl.callback = domcreate_bootloader_done; + dcs->bl.info = &d_config->b_info, + dcs->bl.disk = bootdisk; + dcs->bl.domid = dcs->guest_domid; + + libxl__bootloader_run(egc, &dcs->bl); + } else { + domcreate_bootloader_done(egc, &dcs->bl, 0); } + return; - memset(&dcs->build_state, 0, sizeof(dcs->build_state)); - libxl__domain_build_state *state = &dcs->build_state; +error_out: + assert(ret); + domcreate_complete(egc, dcs, ret); +} + +static void domcreate_bootloader_done(libxl__egc *egc, + libxl__bootloader_state *bl, + int ret) +{ + libxl__domain_create_state *dcs = CONTAINER_OF(bl, *dcs, bl); + STATE_AO_GC(bl->ao); + int i; + + /* convenience aliases */ + const uint32_t domid = dcs->guest_domid; + libxl_domain_config *const d_config = dcs->guest_config; + const int restore_fd = dcs->restore_fd; + libxl__domain_build_state *const state = &dcs->build_state; + libxl_ctx *const ctx = CTX; + + if (ret) goto error_out; /* We might be going to call libxl__spawn_local_dm, or _spawn_stub_dm. * Fill in any field required by either, including both relevant @@ -784,12 +810,13 @@ static void domcreate_devmodel_started(libxl__egc *egc, if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_PV && libxl_defbool_val(d_config->b_info.u.pv.e820_host)) { - int rc; - rc = libxl__e820_alloc(gc, domid, d_config); - if (rc) + ret = libxl__e820_alloc(gc, domid, d_config); + if (ret) { LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Failed while collecting E820 with: %d (errno:%d)\n", - rc, errno); + ret, errno); + goto error_out; + } } if ( cb && (d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM || (d_config->c_info.type == LIBXL_DOMAIN_TYPE_PV && diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index b1ce4d6..9b4c273 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1689,6 +1689,7 @@ struct libxl__domain_create_state { /* private to domain_create */ int guest_domid; libxl__domain_build_state build_state; + libxl__bootloader_state bl; libxl__stub_dm_spawn_state dmss; /* If we''re not doing stubdom, we use only dmss.dm, * for the non-stubdom device model. */ -- 1.7.2.5
Ian Jackson
2012-May-11 17:58 UTC
[PATCH 21/27] libxl: Fix an ao completion bug; document locking policy
Document the concurrent access policies for libxl__ao and libxl__egc, and their corresponding gcs. Fix a violation of the policy: If an ao was submitted and a callback requested, and while the initiating function was still running on the original thread, the ao is completed on another thread, the completing thread would improperly concurrently access the ao with the initiating thread. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> --- tools/libxl/libxl_event.c | 7 +++++++ tools/libxl/libxl_internal.h | 23 ++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletions(-) diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index 3e784f0..b546471 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -901,6 +901,11 @@ void libxl__event_disaster(libxl__egc *egc, const char *msg, int errnoval, static void egc_run_callbacks(libxl__egc *egc) { + /* + * The callbacks must happen with the ctx unlocked. + * See the comment near #define EGC_GC in libxl_internal.h and + * those in the definitions of libxl__egc and libxl__ao. + */ EGC_GC; libxl_event *ev, *ev_tmp; @@ -914,9 +919,11 @@ static void egc_run_callbacks(libxl__egc *egc) entry_for_callback, ao_tmp) { LIBXL_TAILQ_REMOVE(&egc->aos_for_callback, ao, entry_for_callback); ao->how.callback(CTX, ao->rc, ao->how.u.for_callback); + CTX_LOCK; ao->notified = 1; if (!ao->in_initiator) libxl__ao__destroy(CTX, ao); + CTX_UNLOCK; } } diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 9b4c273..f48cfdc 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -359,7 +359,8 @@ struct libxl__gc { }; struct libxl__egc { - /* for event-generating functions only */ + /* For event-generating functions only. + * The egc and its gc may be accessed only on the creating thread. */ struct libxl__gc gc; struct libxl__event_list occurred_for_callback; LIBXL_TAILQ_HEAD(, libxl__ao) aos_for_callback; @@ -369,6 +370,20 @@ struct libxl__egc { #define LIBXL__AO_MAGIC_DESTROYED 0xA0DEAD00ul struct libxl__ao { + /* + * An ao and its gc may be accessed only with the ctx lock held. + * + * Special exception: If an ao has been added to + * egc->aos_for_callback, the thread owning the egc may remove the + * ao from that list and make the callback without holding the + * lock. + * + * Corresponding restriction: An ao may be added only to one + * egc->aos_for_callback, once; rc and how must already have been + * set and may not be subsequently modified. (This restriction is + * easily and obviously met since the ao is queued for callback + * only in libxl__ao_complete.) + */ uint32_t magic; unsigned constructing:1, in_initiator:1, complete:1, notified:1; int rc; @@ -1365,6 +1380,12 @@ libxl__device_model_version_running(libxl__gc *gc, uint32_t domid); * should in any case not find it necessary to call egc-creators from * within libxl. * + * The callbacks must all take place with the ctx unlocked because + * the application is entitled to reenter libxl from them. This + * would be bad not because the lock is not recursive (it is) but + * because the application might make blocking libxl calls which + * would hold the lock unreasonably long. + * * For the same reason libxl__egc_cleanup (or EGC_FREE) must be called * with the ctx *unlocked*. So the right pattern has the EGC_... * macro calls on the outside of the CTX_... ones. -- 1.7.2.5
Ian Jackson
2012-May-11 17:58 UTC
[PATCH 22/27] libxl: provide progress reporting for long-running operations
This will be used for reporting, during domain creation, that the console is ready. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Changes since v7: * If aop->how.callback, actually add the aop to the for_callback list (!) * Document the threadsafety of aop''s, and make appropriate cross-references. * Allocate the actual aop from its thread''s egc; do not free it. * Remove pointless code motion of libxl__ao_create. * Minor formatting fixes. --- tools/libxl/libxl.h | 45 ++++++++++++++++++++++++++ tools/libxl/libxl_event.c | 72 ++++++++++++++++++++++++++++++++++++++++-- tools/libxl/libxl_internal.h | 35 ++++++++++++++++++++ 3 files changed, 149 insertions(+), 3 deletions(-) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index e19d947..ba0f4de 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -435,6 +435,51 @@ typedef struct { } u; } libxl_asyncop_how; +/* + * Some more complex asynchronous operations can report intermediate + * progress. How this is to be reported is controlled, for each + * function, by a parameter + * libxl_asyncprogress_how *aop_FOO_how; + * for each kind of progress FOO supported by that function. Each + * such kind of progress is associated with an event type. + * + * The function description will document whether, when, and how + * many times, the intermediate progress will be reported, and + * what the corresponding event type(s) are. + * + * If aop_FOO_how==NULL, intermediate progress reports are discarded. + * + * If aop_FOO_how->callback==NULL, intermediate progress reports + * generate libxl events which can be obtained from libxl_event_wait + * or libxl_event_check. + * + * If aop_FOO_how->callback!=NULL, libxl will report intermediate + * progress by calling callback(ctx, &event, for_callback). + * + * The rules for these events are otherwise the same as those for + * ordinary events. The reentrancy and threading rules for the + * callback are the same as those for ao completion callbacks. + * + * Note that the callback, if provided, is responsible for freeing + * the event. + * + * If callbacks are requested, they will be made, and returned, before + * the long-running libxl operation is considered finished (so if the + * long-running libxl operation was invoked with ao_how==NULL then any + * callbacks will occur strictly before the long-running operation + * returns). However, the callbacks may occur on any thread. + * + * In general, otherwise, no promises are made about the relative + * order of callbacks in a multithreaded program. In particular + * different callbacks relating to the same long-running operation may + * be delivered out of order. + */ + +typedef struct { + void (*callback)(libxl_ctx *ctx, libxl_event*, void *for_callback); + libxl_ev_user for_event; /* always used */ + void *for_callback; /* passed to callback */ +} libxl_asyncprogress_how; #define LIBXL_VERSION 0 diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index b546471..460ef66 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -902,18 +902,29 @@ void libxl__event_disaster(libxl__egc *egc, const char *msg, int errnoval, static void egc_run_callbacks(libxl__egc *egc) { /* - * The callbacks must happen with the ctx unlocked. - * See the comment near #define EGC_GC in libxl_internal.h and - * those in the definitions of libxl__egc and libxl__ao. + * The callbacks must happen with the ctx unlocked. See the + * comment near #define EGC_GC in libxl_internal.h and those in + * the definitions of libxl__egc, libxl__ao and libxl__aop. */ EGC_GC; libxl_event *ev, *ev_tmp; + libxl__aop_occurred *aop, *aop_tmp; LIBXL_TAILQ_FOREACH_SAFE(ev, &egc->occurred_for_callback, link, ev_tmp) { LIBXL_TAILQ_REMOVE(&egc->occurred_for_callback, ev, link); CTX->event_hooks->event_occurs(CTX->event_hooks_user, ev); } + LIBXL_TAILQ_FOREACH_SAFE(aop, &egc->aops_for_callback, entry, aop_tmp) { + LIBXL_TAILQ_REMOVE(&egc->aops_for_callback, aop, entry); + aop->how->callback(CTX, aop->ev, aop->how->for_callback); + + CTX_LOCK; + aop->ao->progress_reports_outstanding--; + libxl__ao_complete_check_progress_reports(egc, aop->ao); + CTX_UNLOCK; + } + libxl__ao *ao, *ao_tmp; LIBXL_TAILQ_FOREACH_SAFE(ao, &egc->aos_for_callback, entry_for_callback, ao_tmp) { @@ -1296,6 +1307,7 @@ void libxl__ao_abort(libxl__ao *ao) assert(ao->magic == LIBXL__AO_MAGIC); assert(ao->in_initiator); assert(!ao->complete); + assert(!ao->progress_reports_outstanding); libxl__ao__destroy(CTX, ao); } @@ -1306,6 +1318,24 @@ void libxl__ao_complete(libxl__egc *egc, libxl__ao *ao, int rc) ao->complete = 1; ao->rc = rc; + libxl__ao_complete_check_progress_reports(egc, ao); +} + +void libxl__ao_complete_check_progress_reports(libxl__egc *egc, libxl__ao *ao) +{ + /* + * We don''t consider an ao complete if it has any outstanding + * callbacks. These callbacks might be outstanding on other + * threads, queued up in the other threads'' egc''s. Those threads + * will, after making the callback, take out the lock again, + * decrement progress_reports_outstanding, and call us again. + */ + + assert(ao->progress_reports_outstanding >= 0); + + if (!ao->complete || ao->progress_reports_outstanding) + return; + if (ao->poller) { assert(ao->in_initiator); if (!ao->constructing) @@ -1355,6 +1385,7 @@ libxl__ao *libxl__ao_create(libxl_ctx *ctx, uint32_t domid, return NULL; } + int libxl__ao_inprogress(libxl__ao *ao) { AO_GC; @@ -1412,6 +1443,41 @@ int libxl__ao_inprogress(libxl__ao *ao) } +/* progress reporting */ + +/* The application indicates a desire to ignore events by passing NULL + * for how. But we want to copy *how. So we have this dummy function + * whose address is stored in callback if the app passed how==NULL. */ +static void dummy_asyncprogress_callback_ignore + (libxl_ctx *ctx, libxl_event *ev, void *for_callback) { } + +void libxl__ao_progress_gethow(libxl_asyncprogress_how *in_state, + const libxl_asyncprogress_how *from_app) { + if (from_app) + *in_state = *from_app; + else + in_state->callback = dummy_asyncprogress_callback_ignore; +} + +void libxl__ao_progress_report(libxl__egc *egc, libxl__ao *ao, + const libxl_asyncprogress_how *how, libxl_event *ev) +{ + ev->for_user = how->for_event; + if (how->callback == dummy_asyncprogress_callback_ignore) { + /* ignore */ + } else if (how->callback) { + libxl__aop_occurred *aop = libxl__zalloc(&egc->gc, sizeof(*aop)); + ao->progress_reports_outstanding++; + aop->ao = ao; + aop->ev = ev; + aop->how = how; + LIBXL_TAILQ_INSERT_TAIL(&egc->aops_for_callback, aop, entry); + } else { + libxl__event_occurred(egc, ev); + } +} + + /* * Local variables: * mode: C diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index f48cfdc..d5cf69a 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -119,6 +119,7 @@ _hidden void libxl__log(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval, typedef struct libxl__gc libxl__gc; typedef struct libxl__egc libxl__egc; typedef struct libxl__ao libxl__ao; +typedef struct libxl__aop_occurred libxl__aop_occurred; _hidden void libxl__alloc_failed(libxl_ctx *, const char *func, size_t nmemb, size_t size) __attribute__((noreturn)); @@ -364,6 +365,21 @@ struct libxl__egc { struct libxl__gc gc; struct libxl__event_list occurred_for_callback; LIBXL_TAILQ_HEAD(, libxl__ao) aos_for_callback; + LIBXL_TAILQ_HEAD(, libxl__aop_occurred) aops_for_callback; +}; + +struct libxl__aop_occurred { + /* + * An aop belongs to, and may be accessed only on, the thread + * which created it. It normally lives in that thread''s egc. + * + * While an aop exists, it corresponds to one refcount in + * ao->progress_reports_outstanding, preventing ao destruction. + */ + LIBXL_TAILQ_ENTRY(libxl__aop_occurred) entry; + libxl__ao *ao; + libxl_event *ev; + const libxl_asyncprogress_how *how; }; #define LIBXL__AO_MAGIC 0xA0FACE00ul @@ -386,6 +402,7 @@ struct libxl__ao { */ uint32_t magic; unsigned constructing:1, in_initiator:1, complete:1, notified:1; + int progress_reports_outstanding; int rc; libxl__gc gc; libxl_asyncop_how how; @@ -1402,6 +1419,7 @@ libxl__device_model_version_running(libxl__gc *gc, uint32_t domid); LIBXL_INIT_GC((egc).gc,ctx); \ LIBXL_TAILQ_INIT(&(egc).occurred_for_callback); \ LIBXL_TAILQ_INIT(&(egc).aos_for_callback); \ + LIBXL_TAILQ_INIT(&(egc).aops_for_callback); \ } while(0) _hidden void libxl__egc_cleanup(libxl__egc *egc); @@ -1448,6 +1466,9 @@ _hidden void libxl__egc_cleanup(libxl__egc *egc); * pointer to the internal event generation request routines * libxl__evgen_FOO, so that at some point a CALLBACK will be * made when the operation is complete. + * - if the operation provides progress reports, the aop_how(s) + * must be copied into the per-operation structure using + * libxl__ao_progress_gethow. * * - If initiation is successful, the initiating function needs * to run libxl__ao_inprogress right before unlocking and @@ -1457,6 +1478,10 @@ _hidden void libxl__egc_cleanup(libxl__egc *egc); * call libxl__ao_abort before unlocking and returning whatever * error code is appropriate (AO_ABORT macro). * + * - If the operation supports progress reports, it may generate + * suitable events with NEW_EVENT and report them with + * libxl__ao_progress_report (with the ctx locked). + * * - Later, some callback function, whose callback has been requested * directly or indirectly, should call libxl__ao_complete (with the * ctx locked, as it will generally already be in any event callback @@ -1512,8 +1537,18 @@ _hidden int libxl__ao_inprogress(libxl__ao *ao); /* temporarily unlocks */ _hidden void libxl__ao_abort(libxl__ao *ao); _hidden void libxl__ao_complete(libxl__egc *egc, libxl__ao *ao, int rc); +/* Can be called at any time. Use is essential for any aop user. */ +_hidden void libxl__ao_progress_gethow(libxl_asyncprogress_how *in_state, + const libxl_asyncprogress_how *from_app); + +/* Must be called with the ctx locked. Will fill in ev->for_user, + * so caller need not do that. */ +_hidden void libxl__ao_progress_report(libxl__egc *egc, libxl__ao *ao, + const libxl_asyncprogress_how *how, libxl_event *ev /* consumed */); + /* For use by ao machinery ONLY */ _hidden void libxl__ao__destroy(libxl_ctx*, libxl__ao *ao); +_hidden void libxl__ao_complete_check_progress_reports(libxl__egc*, libxl__ao*); /* -- 1.7.2.5
Ian Jackson
2012-May-11 17:58 UTC
[PATCH 23/27] libxl: remove malloc failure handling from NEW_EVENT
Change to use libxl__zalloc, where allocation failure is fatal. Also remove a spurious semicolon from the helper macro. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> --- tools/libxl/libxl.c | 2 -- tools/libxl/libxl_event.c | 8 +------- tools/libxl/libxl_internal.h | 4 ++-- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 482adaa..4d01cf8 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -789,7 +789,6 @@ static void domain_death_occurred(libxl__egc *egc, *evg_upd = evg_next; libxl_event *ev = NEW_EVENT(egc, DOMAIN_DEATH, evg->domid); - if (!ev) return; libxl__event_occurred(egc, ev); @@ -876,7 +875,6 @@ static void domain_death_xswatch_callback(libxl__egc *egc, libxl__ev_xswatch *w, if (!evg->shutdown_reported && (got->flags & XEN_DOMINF_shutdown)) { libxl_event *ev = NEW_EVENT(egc, DOMAIN_SHUTDOWN, got->domain); - if (!ev) goto out; LIBXL__LOG(CTX, LIBXL__LOG_DEBUG, " shutdown reporting"); diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index 460ef66..63719b2 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -989,13 +989,7 @@ libxl_event *libxl__event_new(libxl__egc *egc, { libxl_event *ev; - ev = malloc(sizeof(*ev)); - if (!ev) { - LIBXL__EVENT_DISASTER(egc, "allocate new event", errno, type); - return NULL; - } - - memset(ev, 0, sizeof(*ev)); + ev = libxl__zalloc(0,sizeof(*ev)); ev->type = type; ev->domid = domid; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index d5cf69a..a407317 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -654,10 +654,10 @@ _hidden libxl_event *libxl__event_new(libxl__egc*, libxl_event_type, uint32_t domid); /* Convenience function. * Allocates a new libxl_event, fills in domid and type. - * If allocation fails, calls _disaster, and returns NULL. */ + * Cannot fail. */ #define NEW_EVENT(egc, type, domid) \ - libxl__event_new((egc), LIBXL_EVENT_TYPE_##type, (domid)); + libxl__event_new((egc), LIBXL_EVENT_TYPE_##type, (domid)) /* Convenience macro. */ /* -- 1.7.2.5
Ian Jackson
2012-May-11 17:58 UTC
[PATCH 24/27] libxl: convert console callback to libxl_asyncprogress_how
Remove the old console callback. (Its reentrancy properties were troublesome: in principle, the event loop might be reentered during the callback, and the libxl__domain_create_state swept out from under the feet of the domain creation.) As a side effect of the new code arrangements, the console callback for non-bootloader-using PV guests now occurs near the end of domain creation, in the same place as for HVM guests, rather than near the start. The new arrangements should in principle mean that by the time the console is described as ready by the callback, the xenstore key is indeed ready. So in the future the timeout might be removed from the console client. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> --- tools/libxl/libxl.h | 17 ++++++----- tools/libxl/libxl_bootloader.c | 3 ++ tools/libxl/libxl_create.c | 59 +++++++++++++++++++++++----------------- tools/libxl/libxl_internal.h | 6 +++- tools/libxl/libxl_types.idl | 2 + tools/libxl/xl_cmdimpl.c | 25 ++++++++++------- 6 files changed, 67 insertions(+), 45 deletions(-) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index ba0f4de..979940a 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -509,18 +509,19 @@ int libxl_ctx_alloc(libxl_ctx **pctx, int version, int libxl_ctx_free(libxl_ctx *ctx /* 0 is OK */); /* domain related functions */ -typedef int (*libxl_console_ready)(libxl_ctx *ctx, uint32_t domid, void *priv); - /* fixme-ao Need to review this API. If we keep it, the reentrancy - * properties need to be documented but they may turn out to be too - * awkward */ int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config, - libxl_console_ready cb, void *priv, uint32_t *domid, - const libxl_asyncop_how *ao_how); + uint32_t *domid, + const libxl_asyncop_how *ao_how, + const libxl_asyncprogress_how *aop_console_how); int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config, - libxl_console_ready cb, void *priv, uint32_t *domid, int restore_fd, - const libxl_asyncop_how *ao_how); + const libxl_asyncop_how *ao_how, + const libxl_asyncprogress_how *aop_console_how); + /* A progress report will be made via ao_console_how, of type + * domain_create_console_available, when the domain''s primary + * console is available and can be connected to. + */ void libxl_domain_config_init(libxl_domain_config *d_config); void libxl_domain_config_dispose(libxl_domain_config *d_config); diff --git a/tools/libxl/libxl_bootloader.c b/tools/libxl/libxl_bootloader.c index 1534bae..8436c07 100644 --- a/tools/libxl/libxl_bootloader.c +++ b/tools/libxl/libxl_bootloader.c @@ -377,6 +377,9 @@ static void bootloader_gotptys(libxl__egc *egc, libxl__openpty_state *op) goto out; } + if (bl->console_available) + bl->console_available(egc, bl); + int bootloader_master = libxl__carefd_fd(bl->ptys[0].master); int xenconsole_master = libxl__carefd_fd(bl->ptys[1].master); diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 63cb430..14721eb 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -569,10 +569,15 @@ static int store_libxl_entry(libxl__gc *gc, uint32_t domid, static void domcreate_devmodel_started(libxl__egc *egc, libxl__dm_spawn_state *dmss, int rc); +static void domcreate_bootloader_console_available(libxl__egc *egc, + libxl__bootloader_state *bl); static void domcreate_bootloader_done(libxl__egc *egc, libxl__bootloader_state *bl, int rc); +static void domcreate_console_available(libxl__egc *egc, + libxl__domain_create_state *dcs); + /* Our own function to clean up and call the user''s callback. * The final call in the sequence. */ static void domcreate_complete(libxl__egc *egc, @@ -590,8 +595,6 @@ static void initiate_domain_create(libxl__egc *egc, /* convenience aliases */ libxl_domain_config *const d_config = dcs->guest_config; const int restore_fd = dcs->restore_fd; - const libxl_console_ready cb = dcs->console_cb; - void *const priv = dcs->console_cb_priv; memset(&dcs->build_state, 0, sizeof(dcs->build_state)); domid = 0; @@ -610,11 +613,6 @@ static void initiate_domain_create(libxl__egc *egc, dcs->guest_domid = domid; dcs->dmss.dm.guest_domid = 0; /* means we haven''t spawned */ - if ( d_config->c_info.type == LIBXL_DOMAIN_TYPE_PV && cb ) { - ret = (*cb)(ctx, domid, priv); - if (ret) goto error_out; - } - ret = libxl__domain_build_info_setdefault(gc, &d_config->b_info); if (ret) goto error_out; @@ -629,6 +627,7 @@ static void initiate_domain_create(libxl__egc *egc, if (restore_fd < 0 && bootdisk) { dcs->bl.callback = domcreate_bootloader_done; + dcs->bl.console_available = domcreate_bootloader_console_available; dcs->bl.info = &d_config->b_info, dcs->bl.disk = bootdisk; dcs->bl.domid = dcs->guest_domid; @@ -644,6 +643,21 @@ error_out: domcreate_complete(egc, dcs, ret); } +static void domcreate_bootloader_console_available(libxl__egc *egc, + libxl__bootloader_state *bl) +{ + libxl__domain_create_state *dcs = CONTAINER_OF(bl, *dcs, bl); + STATE_AO_GC(bl->ao); + domcreate_console_available(egc, dcs); +} + +static void domcreate_console_available(libxl__egc *egc, + libxl__domain_create_state *dcs) { + libxl__ao_progress_report(egc, dcs->ao, &dcs->aop_console_how, + NEW_EVENT(egc, DOMAIN_CREATE_CONSOLE_AVAILABLE, + dcs->guest_domid)); +} + static void domcreate_bootloader_done(libxl__egc *egc, libxl__bootloader_state *bl, int ret) @@ -779,8 +793,6 @@ static void domcreate_devmodel_started(libxl__egc *egc, /* convenience aliases */ libxl_domain_config *const d_config = dcs->guest_config; - const libxl_console_ready cb = dcs->console_cb; - void *const priv = dcs->console_cb_priv; if (ret) { LIBXL__LOG(ctx, LIBXL__LOG_ERROR, @@ -818,12 +830,7 @@ static void domcreate_devmodel_started(libxl__egc *egc, goto error_out; } } - if ( cb && (d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM || - (d_config->c_info.type == LIBXL_DOMAIN_TYPE_PV && - d_config->b_info.u.pv.bootloader ))) { - ret = (*cb)(ctx, domid, priv); - if (ret) goto error_out; - } + domcreate_console_available(egc, dcs); domcreate_complete(egc, dcs, 0); return; @@ -863,8 +870,9 @@ static void domain_create_cb(libxl__egc *egc, int rc, uint32_t domid); static int do_domain_create(libxl_ctx *ctx, libxl_domain_config *d_config, - libxl_console_ready cb, void *priv, uint32_t *domid, - int restore_fd, const libxl_asyncop_how *ao_how) + uint32_t *domid, + int restore_fd, const libxl_asyncop_how *ao_how, + const libxl_asyncprogress_how *aop_console_how) { AO_CREATE(ctx, 0, ao_how); libxl__app_domain_create_state *cdcs; @@ -873,9 +881,8 @@ static int do_domain_create(libxl_ctx *ctx, libxl_domain_config *d_config, cdcs->dcs.ao = ao; cdcs->dcs.guest_config = d_config; cdcs->dcs.restore_fd = restore_fd; - cdcs->dcs.console_cb = cb; - cdcs->dcs.console_cb_priv = priv; cdcs->dcs.callback = domain_create_cb; + libxl__ao_progress_gethow(&cdcs->dcs.aop_console_how, aop_console_how); cdcs->domid_out = domid; initiate_domain_create(egc, &cdcs->dcs); @@ -897,19 +904,21 @@ static void domain_create_cb(libxl__egc *egc, } int libxl_domain_create_new(libxl_ctx *ctx, libxl_domain_config *d_config, - libxl_console_ready cb, void *priv, uint32_t *domid, - const libxl_asyncop_how *ao_how) + const libxl_asyncop_how *ao_how, + const libxl_asyncprogress_how *aop_console_how) { - return do_domain_create(ctx, d_config, cb, priv, domid, -1, ao_how); + return do_domain_create(ctx, d_config, domid, -1, + ao_how, aop_console_how); } int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config, - libxl_console_ready cb, void *priv, uint32_t *domid, int restore_fd, - const libxl_asyncop_how *ao_how) + const libxl_asyncop_how *ao_how, + const libxl_asyncprogress_how *aop_console_how) { - return do_domain_create(ctx, d_config, cb, priv, domid, restore_fd, ao_how); + return do_domain_create(ctx, d_config, domid, restore_fd, + ao_how, aop_console_how); } /* diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index a407317..3aa0ed7 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1699,11 +1699,14 @@ int libxl__openptys(libxl__openpty_state *op, typedef struct libxl__bootloader_state libxl__bootloader_state; typedef void libxl__run_bootloader_callback(libxl__egc*, libxl__bootloader_state*, int rc); +typedef void libxl__bootloader_console_callback(libxl__egc*, + libxl__bootloader_state*); struct libxl__bootloader_state { /* caller must fill these in, and they must all remain valid */ libxl__ao *ao; libxl__run_bootloader_callback *callback; + libxl__bootloader_console_callback *console_available; libxl_domain_build_info *info; /* u.pv.{kernel,ramdisk,cmdline} updated */ libxl_device_disk *disk; uint32_t domid; @@ -1739,9 +1742,8 @@ struct libxl__domain_create_state { libxl__ao *ao; libxl_domain_config *guest_config; int restore_fd; - libxl_console_ready console_cb; - void *console_cb_priv; libxl__domain_create_cb *callback; + libxl_asyncprogress_how aop_console_how; /* private to domain_create */ int guest_domid; libxl__domain_build_state build_state; diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index 68599cb..551e367 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -459,6 +459,7 @@ libxl_event_type = Enumeration("event_type", [ (2, "DOMAIN_DEATH"), (3, "DISK_EJECT"), (4, "OPERATION_COMPLETE"), + (5, "DOMAIN_CREATE_CONSOLE_AVAILABLE"), ]) libxl_ev_user = UInt(64) @@ -484,4 +485,5 @@ libxl_event = Struct("event",[ ("operation_complete", Struct(None, [ ("rc", integer), ])), + ("domain_create_console_available", Struct(None, [])), ]))]) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 621aeaf..b91a2d5 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -1457,16 +1457,18 @@ static int freemem(libxl_domain_build_info *b_info) return ERROR_NOMEM; } -static int autoconnect_console(libxl_ctx *ctx, uint32_t domid, void *priv) +static void autoconnect_console(libxl_ctx *ctx, libxl_event *ev, void *priv) { pid_t *pid = priv; + libxl_event_free(ctx, ev); + *pid = fork(); if (*pid < 0) { perror("unable to fork xenconsole"); - return ERROR_FAIL; + return; } else if (*pid > 0) - return 0; + return; postfork(); @@ -1533,7 +1535,7 @@ static int create_domain(struct domain_create *dom_info) int config_len = 0; int restore_fd = -1; int status = 0; - libxl_console_ready cb; + const libxl_asyncprogress_how *autoconnect_console_how; pid_t child_console_pid = -1; struct save_file_header hdr; @@ -1687,24 +1689,27 @@ start: goto error_out; } + libxl_asyncprogress_how autoconnect_console_how_buf; if ( dom_info->console_autoconnect ) { - cb = autoconnect_console; + autoconnect_console_how_buf.callback = autoconnect_console; + autoconnect_console_how_buf.for_callback = &child_console_pid; + autoconnect_console_how = &autoconnect_console_how_buf; }else{ - cb = NULL; + autoconnect_console_how = 0; } if ( restore_file ) { ret = libxl_domain_create_restore(ctx, &d_config, - cb, &child_console_pid, - &domid, restore_fd, 0); + &domid, restore_fd, + 0, autoconnect_console_how); /* * On subsequent reboot etc we should create the domain, not * restore/migrate-receive it again. */ restore_file = NULL; }else{ - ret = libxl_domain_create_new(ctx, &d_config, - cb, &child_console_pid, &domid, 0); + ret = libxl_domain_create_new(ctx, &d_config, &domid, + 0, autoconnect_console_how); } if ( ret ) goto error_out; -- 1.7.2.5
Ian Jackson
2012-May-11 17:58 UTC
[PATCH 25/27] libxl: clarify definition of "slow" operation
Update the comment in libxl_internal.h to be clearer about which application-facing libxl operations need to take an ao_how. Reported-by: Dan Magenheimer <dan.magenheimer@oracle.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> --- tools/libxl/libxl_internal.h | 29 +++++++++++++++++++++++------ 1 files changed, 23 insertions(+), 6 deletions(-) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 3aa0ed7..9f3f759 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1439,17 +1439,34 @@ _hidden void libxl__egc_cleanup(libxl__egc *egc); /* * Machinery for asynchronous operations ("ao") * - * All "slow" functions (includes anything that might block on a - * guest or an external script) need to use the asynchronous - * operation ("ao") machinery. The function should take a parameter - * const libxl_asyncop_how *ao_how and must start with a call to - * AO_INITIATOR_ENTRY. These functions MAY NOT be called from - * inside libxl, because they can cause reentrancy callbacks. + * All "slow" functions (see below for the exact definition) need to + * use the asynchronous operation ("ao") machinery. The function + * should take a parameter const libxl_asyncop_how *ao_how and must + * start with a call to AO_INITIATOR_ENTRY. These functions MAY NOT + * be called from inside libxl, because they can cause reentrancy + * callbacks. * * For the same reason functions taking an ao_how may make themselves * an egc with EGC_INIT (and they will generally want to, to be able * to immediately complete an ao during its setup). * + * + * "Slow" functions includes any that might block on a guest or an + * external script. More broadly, it includes any operations which + * are sufficiently slow that an application might reasonably want to + * initiate them, and then carry on doing something else, while the + * operation completes. That is, a "fast" function must be fast + * enough that we do not mind blocking all other management operations + * on the same host while it completes. + * + * There are certain primitive functions which make a libxl operation + * necessarily "slow" for API reasons. These are: + * - awaiting xenstore watches (although read-modify-write xenstore + * transactions are OK for fast functions) + * - spawning subprocesses + * - anything with a timeout + * + * * Lifecycle of an ao: * * - Created by libxl__ao_create (or the AO_CREATE convenience macro). -- 1.7.2.5
Abolish libxl_fork. Its only callers were in xl. Its functionality is now moved elsewhere, as follows: * The "logging version of fork", which is what it was billed as, is now xl_fork, which also dies on failure. * Closing the xenstore handle in the child is now done in libxl__ev_child_fork, which is the only remaining place where fork is called in libxl. * We provide a new function libxl__ev_child_xenstore_reopen for in-libxl children to make the ctx useable for xenstore again. * Consequently libxl__spawn_record_pid now no longer needs to mess about with its own xenstore handle. As a bonus it can now just use libxl__xs_write. Also, since we have now converted all the forkers in libxl, we can always honour the fork_replacement childproc hook - so do so. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> --- tools/libxl/libxl_exec.c | 35 ++++++++++++++++------------------- tools/libxl/libxl_fork.c | 25 ++++++++++++++++++++++++- tools/libxl/libxl_internal.h | 5 +++++ tools/libxl/libxl_utils.c | 21 --------------------- tools/libxl/libxl_utils.h | 3 +-- tools/libxl/xl.c | 12 ++++++++++++ tools/libxl/xl.h | 1 + tools/libxl/xl_cmdimpl.c | 5 ++--- 8 files changed, 61 insertions(+), 46 deletions(-) diff --git a/tools/libxl/libxl_exec.c b/tools/libxl/libxl_exec.c index 882c048..b46b893 100644 --- a/tools/libxl/libxl_exec.c +++ b/tools/libxl/libxl_exec.c @@ -127,34 +127,23 @@ void libxl_report_child_exitstatus(libxl_ctx *ctx, } } -int libxl__spawn_record_pid(libxl__gc *gc, libxl__spawn_state *spawn, - pid_t innerchild) +int libxl__spawn_record_pid(libxl__gc *gc, libxl__spawn_state *spawn, pid_t pid) { - struct xs_handle *xsh = NULL; - const char *pid = NULL; - int rc, xsok; + int r, rc; - pid = GCSPRINTF("%d", innerchild); + rc = libxl__ev_child_xenstore_reopen(gc, spawn->what); + if (rc) goto out; - /* we mustn''t use the parent''s handle in the child */ - xsh = xs_daemon_open(); - if (!xsh) { - LOGE(ERROR, "write %s = %s: xenstore reopen failed", - spawn->pidpath, pid); - rc = ERROR_FAIL; goto out; - } - - xsok = xs_write(xsh, XBT_NULL, spawn->pidpath, pid, strlen(pid)); - if (!xsok) { + r = libxl__xs_write(gc, XBT_NULL, spawn->pidpath, "%d", pid); + if (r) { LOGE(ERROR, - "write %s = %s: xenstore write failed", spawn->pidpath, pid); + "write %s = %d: xenstore write failed", spawn->pidpath, pid); rc = ERROR_FAIL; goto out; } rc = 0; out: - if (xsh) xs_daemon_close(xsh); return rc ? SIGTERM : 0; } @@ -302,7 +291,15 @@ int libxl__spawn_spawn(libxl__egc *egc, libxl__spawn_state *ss) /* we are now the middle process */ - child = fork(); + pid_t (*fork_replacement)(void*) + CTX->childproc_hooks + ? CTX->childproc_hooks->fork_replacement + : 0; + child + fork_replacement + ? fork_replacement(CTX->childproc_user) + : fork(); + if (child == -1) exit(255); if (!child) { diff --git a/tools/libxl/libxl_fork.c b/tools/libxl/libxl_fork.c index 35c8bdd..9ff99e0 100644 --- a/tools/libxl/libxl_fork.c +++ b/tools/libxl/libxl_fork.c @@ -347,7 +347,12 @@ pid_t libxl__ev_child_fork(libxl__gc *gc, libxl__ev_child *ch, if (!pid) { /* woohoo! */ - return 0; /* Yes, CTX is left locked in the child. */ + if (CTX->xsh) { + xs_daemon_destroy_postfork(CTX->xsh); + CTX->xsh = NULL; /* turns mistakes into crashes */ + } + /* Yes, CTX is left locked in the child. */ + return 0; } ch->pid = pid; @@ -395,6 +400,24 @@ const libxl_childproc_hooks libxl__childproc_default_hooks = { libxl_sigchld_owner_libxl, 0, 0 }; +int libxl__ev_child_xenstore_reopen(libxl__gc *gc, const char *what) { + int rc; + + assert(!CTX->xsh); + CTX->xsh = xs_daemon_open(); + if (!CTX->xsh) { + LOGE(ERROR, "%s: xenstore reopen failed", what); + rc = ERROR_FAIL; goto out; + } + + libxl_fd_set_cloexec(CTX, xs_fileno(CTX->xsh), 1); + + return 0; + + out: + return rc; +} + /* * Local variables: * mode: C diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 9f3f759..83fabea 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -640,6 +640,11 @@ static inline void libxl__ev_child_init(libxl__ev_child *childw_out) static inline int libxl__ev_child_inuse(libxl__ev_child *childw_out) { return childw_out->pid >= 0; } +/* Useable (only) in the child to once more make the ctx useable for + * xenstore operations. logs failure in the form "what: <error + * message>". */ +_hidden int libxl__ev_child_xenstore_reopen(libxl__gc *gc, const char *what); + /* * Other event-handling support provided by the libxl event core to diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c index f0d94c6..858410e 100644 --- a/tools/libxl/libxl_utils.c +++ b/tools/libxl/libxl_utils.c @@ -444,27 +444,6 @@ int libxl__remove_directory(libxl__gc *gc, const char *dirpath) return rc; } -pid_t libxl_fork(libxl_ctx *ctx) -{ - pid_t pid; - - pid = fork(); - if (pid == -1) { - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "fork failed"); - return -1; - } - - if (!pid) { - if (ctx->xsh) xs_daemon_destroy_postfork(ctx->xsh); - ctx->xsh = 0; - /* This ensures that anyone who forks but doesn''t exec, - * and doesn''t reinitialise the libxl_ctx, is OK. - * It also means they can safely call libxl_ctx_free. */ - } - - return pid; -} - int libxl_pipe(libxl_ctx *ctx, int pipes[2]) { if (pipe(pipes) < 0) { diff --git a/tools/libxl/libxl_utils.h b/tools/libxl/libxl_utils.h index 2b47622..74beb52 100644 --- a/tools/libxl/libxl_utils.h +++ b/tools/libxl/libxl_utils.h @@ -47,9 +47,8 @@ int libxl_write_exactly(libxl_ctx *ctx, int fd, const void *data, * logged using filename (which is only used for logging) and what * (which may be 0). */ -pid_t libxl_fork(libxl_ctx *ctx); int libxl_pipe(libxl_ctx *ctx, int pipes[2]); - /* Just like fork(2), pipe(2), but log errors. */ + /* Just like pipe(2), but log errors. */ void libxl_report_child_exitstatus(libxl_ctx *ctx, xentoollog_level, const char *what, pid_t pid, int status); diff --git a/tools/libxl/xl.c b/tools/libxl/xl.c index a6ffd25..d4db1f8 100644 --- a/tools/libxl/xl.c +++ b/tools/libxl/xl.c @@ -105,6 +105,18 @@ void postfork(void) } } +pid_t xl_fork(libxl_ctx *ctx) { + pid_t pid; + + pid = fork(); + if (pid == -1) { + perror("fork failed"); + exit(-1); + } + + return pid; +} + int main(int argc, char **argv) { int opt = 0; diff --git a/tools/libxl/xl.h b/tools/libxl/xl.h index f0d0ec8..2b6714a 100644 --- a/tools/libxl/xl.h +++ b/tools/libxl/xl.h @@ -104,6 +104,7 @@ struct cmd_spec *cmdtable_lookup(const char *s); extern libxl_ctx *ctx; extern xentoollog_logger_stdiostream *logger; +pid_t xl_fork(libxl_ctx *ctx); /* like fork, but prints and dies if it fails */ void postfork(void); /* global options */ diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index b91a2d5..efaf3de 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -1736,7 +1736,7 @@ start: pid_t child1, got_child; int nullfd; - child1 = libxl_fork(ctx); + child1 = xl_fork(ctx); if (child1) { printf("Daemon running with PID %d\n", child1); @@ -2779,8 +2779,7 @@ static void migrate_domain(const char *domain_spec, const char *rune, MUST( libxl_pipe(ctx, sendpipe) ); MUST( libxl_pipe(ctx, recvpipe) ); - child = libxl_fork(ctx); - if (child==-1) exit(1); + child = xl_fork(ctx); if (!child) { dup2(sendpipe[0], 0); -- 1.7.2.5
Ian Jackson
2012-May-11 17:58 UTC
[PATCH 27/27] libxl: abort bootloader invocation when domain dies
Cancel the bootloader (specifically, by sending it a signal) if the domain is seen to disappear from xenstore. We use a new utility event source libxl__domaindeathcheck which provides a convenient wrapper for the xenstore watch. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Changes since v8: * Fixed the commit message summary line. Changes since v7: * Add a comment explaining why we use a watch on the domain''s xenstore path rather than @releaseDomain. * Fix typo in error message. --- tools/libxl/libxl_bootloader.c | 43 ++++++++++++++++++++++++++++-------- tools/libxl/libxl_event.c | 47 ++++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_internal.h | 29 +++++++++++++++++++++++- 3 files changed, 108 insertions(+), 11 deletions(-) diff --git a/tools/libxl/libxl_bootloader.c b/tools/libxl/libxl_bootloader.c index 8436c07..fb1302b 100644 --- a/tools/libxl/libxl_bootloader.c +++ b/tools/libxl/libxl_bootloader.c @@ -31,6 +31,7 @@ static void bootloader_keystrokes_copyfail(libxl__egc *egc, libxl__datacopier_state *dc, int onwrite, int errnoval); static void bootloader_display_copyfail(libxl__egc *egc, libxl__datacopier_state *dc, int onwrite, int errnoval); +static void bootloader_domaindeath(libxl__egc*, libxl__domaindeathcheck *dc); static void bootloader_finished(libxl__egc *egc, libxl__ev_child *child, pid_t pid, int status); @@ -213,6 +214,7 @@ void libxl__bootloader_init(libxl__bootloader_state *bl) bl->ptys[0].master = bl->ptys[0].slave = 0; bl->ptys[1].master = bl->ptys[1].slave = 0; libxl__ev_child_init(&bl->child); + libxl__domaindeathcheck_init(&bl->deathcheck); bl->keystrokes.ao = bl->ao; libxl__datacopier_init(&bl->keystrokes); bl->display.ao = bl->ao; libxl__datacopier_init(&bl->display); } @@ -230,6 +232,7 @@ static void bootloader_cleanup(libxl__egc *egc, libxl__bootloader_state *bl) free(bl->diskpath); bl->diskpath = 0; } + libxl__domaindeathcheck_stop(gc,&bl->deathcheck); libxl__datacopier_kill(&bl->keystrokes); libxl__datacopier_kill(&bl->display); for (i=0; i<2; i++) { @@ -256,6 +259,23 @@ static void bootloader_callback(libxl__egc *egc, libxl__bootloader_state *bl, bl->callback(egc, bl, rc); } +/* might be called at any time, provided it''s init''d */ +static void bootloader_abort(libxl__egc *egc, + libxl__bootloader_state *bl, int rc) +{ + STATE_AO_GC(bl->ao); + int r; + + libxl__datacopier_kill(&bl->keystrokes); + libxl__datacopier_kill(&bl->display); + if (libxl__ev_child_inuse(&bl->child)) { + r = kill(bl->child.pid, SIGTERM); + if (r) LOGE(WARN, "after failure, failed to kill bootloader [%lu]", + (unsigned long)bl->child.pid); + } + bl->rc = rc; +} + /*----- main flow of control -----*/ void libxl__bootloader_run(libxl__egc *egc, libxl__bootloader_state *bl) @@ -377,6 +397,12 @@ static void bootloader_gotptys(libxl__egc *egc, libxl__openpty_state *op) goto out; } + bl->deathcheck.what = "stopping bootloader"; + bl->deathcheck.domid = bl->domid; + bl->deathcheck.callback = bootloader_domaindeath; + rc = libxl__domaindeathcheck_start(gc, &bl->deathcheck); + if (rc) goto out; + if (bl->console_available) bl->console_available(egc, bl); @@ -454,18 +480,9 @@ static void bootloader_copyfail(libxl__egc *egc, const char *which, libxl__bootloader_state *bl, int onwrite, int errnoval) { STATE_AO_GC(bl->ao); - int r; - if (!onwrite && !errnoval) LOG(ERROR, "unexpected eof copying %s", which); - libxl__datacopier_kill(&bl->keystrokes); - libxl__datacopier_kill(&bl->display); - if (libxl__ev_child_inuse(&bl->child)) { - r = kill(bl->child.pid, SIGTERM); - if (r) LOGE(WARN, "after failure, failed to kill bootloader [%lu]", - (unsigned long)bl->child.pid); - } - bl->rc = ERROR_FAIL; + bootloader_abort(egc, bl, ERROR_FAIL); } static void bootloader_keystrokes_copyfail(libxl__egc *egc, libxl__datacopier_state *dc, int onwrite, int errnoval) @@ -480,6 +497,12 @@ static void bootloader_display_copyfail(libxl__egc *egc, bootloader_copyfail(egc, "bootloader output", bl, onwrite, errnoval); } +static void bootloader_domaindeath(libxl__egc *egc, libxl__domaindeathcheck *dc) +{ + libxl__bootloader_state *bl = CONTAINER_OF(dc, *bl, deathcheck); + bootloader_abort(egc, bl, ERROR_FAIL); +} + static void bootloader_finished(libxl__egc *egc, libxl__ev_child *child, pid_t pid, int status) { diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c index 63719b2..03d0498 100644 --- a/tools/libxl/libxl_event.c +++ b/tools/libxl/libxl_event.c @@ -589,6 +589,53 @@ int libxl__ev_devstate_wait(libxl__gc *gc, libxl__ev_devstate *ds, } /* + * domain death/destruction + */ + +/* + * We use a xenstore watch on the domain''s path, rather than using an + * @releaseDomain watch and asking the hypervisor. This is simpler + * because turning @releaseDomain into domain-specific information is + * complicated. + * + * It is also sufficient for our callers, which are generally trying + * to do cleanup of their own execution state on domain death, for the + * following reason: if the domain is destroyed then either (a) the + * entries in xenstore have already been deleted, in which case the + * test here works or (b) they have not in which case something has + * gone very badly wrong and we are going to leak those xenstore + * entries, in which case trying to avoid leaking other stuff is + * futile. + */ + +static void domaindeathcheck_callback(libxl__egc *egc, libxl__ev_xswatch *w, + const char *watch_path, const char *event_path) +{ + libxl__domaindeathcheck *dc = CONTAINER_OF(w, *dc, watch); + EGC_GC; + const char *p = libxl__xs_read(gc, XBT_NULL, watch_path); + if (p) return; + + if (errno!=ENOENT) { + LIBXL__EVENT_DISASTER(egc,"failed to read xenstore" + " for domain detach check", errno, 0); + return; + } + + LOG(ERROR,"%s: domain %"PRIu32" removed (%s no longer in xenstore)", + dc->what, dc->domid, watch_path); + dc->callback(egc, dc); +} + +int libxl__domaindeathcheck_start(libxl__gc *gc, + libxl__domaindeathcheck *dc) +{ + const char *path = GCSPRINTF("/local/domain/%"PRIu32, dc->domid); + return libxl__ev_xswatch_register(gc, &dc->watch, + domaindeathcheck_callback, path); +} + +/* * osevent poll */ diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 83fabea..f71e76a 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -866,6 +866,33 @@ _hidden int libxl__ev_devstate_wait(libxl__gc *gc, libxl__ev_devstate *ds, const char *state_path, int state, int milliseconds); +/* + * libxl__ev_domaindeathcheck_register - arranges to call back (once) + * if the domain is destroyed. If the domain dies, we log a message + * of the form "<what>: <explanation of the situation, including the domid>". + */ + +typedef struct libxl__domaindeathcheck libxl__domaindeathcheck; +typedef void libxl___domaindeathcheck_callback(libxl__egc *egc, + libxl__domaindeathcheck*); + +struct libxl__domaindeathcheck { + /* must be filled in by caller, and remain valid: */ + const char *what; + uint32_t domid; + libxl___domaindeathcheck_callback *callback; + /* private */ + libxl__ev_xswatch watch; +}; + +_hidden int libxl__domaindeathcheck_start(libxl__gc *gc, + libxl__domaindeathcheck *dc); + +static inline void libxl__domaindeathcheck_init + (libxl__domaindeathcheck *dc) { libxl__ev_xswatch_init(&dc->watch); } +static inline void libxl__domaindeathcheck_stop(libxl__gc *gc, + libxl__domaindeathcheck *dc) { libxl__ev_xswatch_deregister(gc,&dc->watch); } + /* * libxl__try_phy_backend - Check if there''s support for the passed @@ -1738,6 +1765,7 @@ struct libxl__bootloader_state { libxl__openpty_state openpty; libxl__openpty_result ptys[2]; /* [0] is for bootloader */ libxl__ev_child child; + libxl__domaindeathcheck deathcheck; int nargs, argsspace; const char **args; libxl__datacopier_state keystrokes, display; @@ -1750,7 +1778,6 @@ _hidden void libxl__bootloader_init(libxl__bootloader_state *bl); * If callback is passed rc==0, will have updated st->info appropriately */ _hidden void libxl__bootloader_run(libxl__egc*, libxl__bootloader_state *st); - /*----- Domain creation -----*/ typedef struct libxl__domain_create_state libxl__domain_create_state; -- 1.7.2.5