[m-rev.] diff: improve build of mkinit

Peter Ross pro at missioncriticalit.com
Thu Jun 24 21:31:24 AEST 2004


Hi,


===================================================================


Only include the source to getopt when building mkinit, if a getopt
library doesn't appear to be available.

This avoids a problem where mkinit segfaults under windows with cygwin
due to header files defining different versions of optarg.

configure.in:
	Check for getopt.h and then save the status into
	GETOPT_H_AVAILABLE.

Mmake.common.in:
	Save GETOPT_H_AVAILABLE for use by mmake.

util/Mmakefile:
	Only include the getopt source if GETOPT_H_AVAILABLE is no.

Index: Mmake.common.in
===================================================================
RCS file: /home/mercury1/repository/mercury/Mmake.common.in,v
retrieving revision 1.77
diff -u -r1.77 Mmake.common.in
--- Mmake.common.in	30 Dec 2003 10:11:25 -0000	1.77
+++ Mmake.common.in	24 Jun 2004 11:15:55 -0000
@@ -222,6 +222,9 @@
 # Are we compiling using the MS C compiler?
 USING_MICROSOFT_CL_COMPILER=@USING_MICROSOFT_CL_COMPILER@
 
+# Is the getopt.h header file available?
+GETOPT_H_AVAILABLE=@GETOPT_H_AVAILABLE@
+
 #-----------------------------------------------------------------------------#
 
 # Module-specific options should go in Mercury.options so they
Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.392
diff -u -r1.392 configure.in
--- configure.in	14 Jun 2004 03:51:55 -0000	1.392
+++ configure.in	24 Jun 2004 11:15:56 -0000
@@ -743,7 +743,14 @@
 		unistd.h sys/wait.h sys/siginfo.h sys/signal.h ucontext.h \
 		asm/sigcontext.h sys/param.h sys/time.h sys/times.h \
 		sys/types.h sys/stat.h fcntl.h termios.h sys/ioctl.h \
-		sys/stropts.h windows.h dirent.h)
+		sys/stropts.h windows.h dirent.h getopt.h)
+
+if test "$MR_HAVE_GETOPT_H" = 1; then
+	GETOPT_H_AVAILABLE=yes
+else
+	GETOPT_H_AVAILABLE=no
+fi
+AC_SUBST(GETOPT_H_AVAILABLE)
 
 if test "$MR_HAVE_UCONTEXT_H" != 1; then
 	MERCURY_CHECK_FOR_HEADERS(sys/ucontext.h)
Index: util/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/util/Mmakefile,v
retrieving revision 1.15
diff -u -r1.15 Mmakefile
--- util/Mmakefile	25 Jul 2002 08:51:07 -0000	1.15
+++ util/Mmakefile	24 Jun 2004 11:15:56 -0000
@@ -23,7 +23,13 @@
 PROGFILENAMES=$(PROGS:%=%$(EXT_FOR_EXE))
 SRC=$(PROGS:%=%.c)
 
-GETOPT_SRC=$(RUNTIME_DIR)/GETOPT/getopt.c $(RUNTIME_DIR)/GETOPT/getopt1.c
+
+# Only if getopt.h doesn't exist do we link in a version of getopt.
+ifeq ("$(GETOPT_H_AVAILABLE)","no")
+	GETOPT_SRC=$(RUNTIME_DIR)/GETOPT/getopt.c $(RUNTIME_DIR)/GETOPT/getopt1.c
+else
+	GETOPT_SRC=
+endif
 
 # mkinit.c needs `struct stat'
 MGNUCFLAGS-mkinit = --no-ansi


-- 
Software Engineer                                (Work)   +32 2 757 10 15
Mission Critical                                 (Mobile) +32 485 482 559
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list