[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Axiom-developer] better pty patch
From: |
Waldek Hebisch |
Subject: |
[Axiom-developer] better pty patch |
Date: |
Mon, 6 Nov 2006 00:10:57 +0100 (CET) |
Many systems (Linux, BSD and supposedly also Mac OS X) provide 'openpty'
function as a preferred method to open a pty (for example on Linux
'openpty' will use Unix 98 ptys, but if those are not available it
will fall back to legacy ptys). 'openpty' seem to be available
in 'libutil', so in order to use it we must link to 'libutil'.
The patch below tries to 'openpty': add configure check and auguments
compiler and linker argument. There are some things which probably
should be done in different way (please comment):
1) configure defines 'HAVE_OPENPTY' preprocessor symbol, this symbol
is then propagated via 'DEFS' make variable and compile command
line. Alternatively we could have a common header file generated
by configure
2) I only modified clef and sman Makefiles, but it is probably better
to use the same set of libraries and the same compiler command line
for all compilations.
diff -ru build-improvements.bb/config/var-def.mk
build-improvements/config/var-def.mk
--- build-improvements.bb/config/var-def.mk 2006-11-03 18:07:14.000000000
+0100
+++ build-improvements/config/var-def.mk 2006-11-04 23:02:43.000000000
+0100
@@ -112,6 +112,8 @@
AXIOM_X11_CFLAGS = @X_CFLAGS@
AXIOM_X11_LDFLAGS = @X_LIBS@ @X_PRE_LIBS@ -lX11 @X_EXTRA_LIBS@
+EXTRA_LIBS = @EXTRA_LIBS@
+DEFS = @DEFS@
## Where the staging build directory is found
AXIOM = @AXIOM@
diff -ru build-improvements.bb/configure build-improvements/configure
diff -ru build-improvements.bb/configure.ac.pamphlet
build-improvements/configure.ac.pamphlet
--- build-improvements.bb/configure.ac.pamphlet 2006-11-03 18:07:14.000000000
+0100
+++ build-improvements/configure.ac.pamphlet 2006-11-04 22:50:25.000000000
+0100
@@ -580,6 +580,17 @@
AC_SUBST(X_PRE_LIBS)
@
+\section{Extra libraries}
+
+Axiom supporting programs [[sman]] and [[clef]] use pseudo terminals.
+To open pseudo terminals we use [[openpty]] if available, otherwise
+we fall back to platform specific code.
+
+<<extra libraries>>=
+AC_CHECK_FUNCS(openpty,, AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY)]
+ [EXTRA_LIBS="-lutil"]))
+AC_SUBST(EXTRA_LIBS)
+@
\section{configure.ac}
@@ -602,6 +613,8 @@
<<locate X11>>
+<<extra libraries>>
+
<<define AXIOM>>
<<platform specific bits>>
diff -ru build-improvements.bb/src/clef/Makefile.pamphlet
build-improvements/src/clef/Makefile.pamphlet
--- build-improvements.bb/src/clef/Makefile.pamphlet 2006-11-03
18:07:14.000000000 +0100
+++ build-improvements/src/clef/Makefile.pamphlet 2006-11-04
22:57:58.000000000 +0100
@@ -25,7 +25,7 @@
clef_objects = $(clef_sources:.c=.o)
CFLAGS= ${CCF}
-LDFLAGS= -L${LIB} -lspad ${LDF}
+LDFLAGS= -L${LIB} -lspad ${EXTRA_LIBS} ${LDF}
@
\section{The clef sources, edible}
diff -ru build-improvements.bb/src/lib/Makefile.pamphlet
build-improvements/src/lib/Makefile.pamphlet
--- build-improvements.bb/src/lib/Makefile.pamphlet 2006-11-03
18:07:14.000000000 +0100
+++ build-improvements/src/lib/Makefile.pamphlet 2006-11-04
23:04:53.000000000 +0100
@@ -49,7 +49,7 @@
.PRECIOUS: %.o
%.o: %.c
- $(CC) $(CCF) -c -I$(INC) $< -o $@
+ $(CC) $(DEFS) $(CCF) -c -I$(INC) $< -o $@
@
diff -ru build-improvements.bb/src/lib/openpty.c.pamphlet
build-improvements/src/lib/openpty.c.pamphlet
--- build-improvements.bb/src/lib/openpty.c.pamphlet 2006-11-03
18:07:14.000000000 +0100
+++ build-improvements/src/lib/openpty.c.pamphlet 2006-11-05
22:45:03.000000000 +0100
@@ -10,17 +10,9 @@
\tableofcontents
\eject
\section{MAC OSX and BSD platform changes}
-Since we have no other information we are adding the [[MACOSXplatform]]
variable
-to the list everywhere we find [[LINUXplatform]]. This may not be correct but
-we have no way to know yet. We have also added the [[BSDplatform]] variable.
-MAC OSX is some variant of BSD. These should probably be merged but we
-cannot yet prove that.
-<<mac osx platform change 1>>=
-#if defined(SUN4OS5platform) ||defined(ALPHAplatform) || defined(HP10platform)
|| defined(LINUXplatform) || defined(MACOSXplatform) || defined(BSDplatform)
-@
-<<mac osx platform change 2>>=
-#if defined(SUNplatform) || defined(HP9platform) || defined(LINUXplatform) ||
defined(MACOSXplatform) || defined(BSDplatform)
-@
+We should really use autotools to check for Unix 98 pty support.
+Before this is done below we hardcode information about each platform.
+
\section{License}
<<license>>=
/*
@@ -70,6 +62,9 @@
#include <stropts.h>
#endif
+#ifdef HAVE_OPENPTY
+#include <pty.h>
+#endif
#include "openpty.H1"
@@ -104,7 +99,10 @@
#endif
{
-#if defined(SUNplatform) || defined (HP9platform) || defined(RTplatform)
||defined(AIX370platform) || defined(BSDplatform)
+#ifdef HAVE_OPENPTY
+ return openpty(controller, server, serverPath, 0, 0);
+#else
+#if defined(SUNplatform) || defined (HP9platform) || defined(RTplatform)
||defined(AIX370platform) || defined(BSDplatform) || defined(MACOSXplatform)
int looking = 1, i;
int oflag = O_RDWR; /* flag for opening the pty */
@@ -147,7 +145,8 @@
return(fdm);
#endif
-<<mac osx platform change 1>>
+/* MAC OS X 10.3 does not support Unix 98 pty's */
+#if defined(SUN4OS5platform) ||defined(ALPHAplatform) || defined(HP10platform)
|| defined(LINUXplatform) || defined(BSDplatform)
extern int grantpt(int);
extern int unlockpt(int);
extern char* ptsname(int);
@@ -199,6 +198,7 @@
return (*controller);
#endif
+#endif
}
@@ -216,7 +216,7 @@
sprintf(serv, "/dev/ttyp%02x", channelNo);
channelNo++;
#endif
-<<mac osx platform change 2>>
+#if defined(SUNplatform) || defined(HP9platform) || defined(LINUXplatform) ||
defined(MACOSXplatform) || defined(BSDplatform)
static int channelNo = 0;
static char group[] = "pqrstuvwxyzPQRST";
static int groupNo = 0;
diff -ru build-improvements.bb/src/sman/Makefile.pamphlet
build-improvements/src/sman/Makefile.pamphlet
--- build-improvements.bb/src/sman/Makefile.pamphlet 2006-11-03
18:07:09.000000000 +0100
+++ build-improvements/src/sman/Makefile.pamphlet 2006-11-04
22:58:41.000000000 +0100
@@ -25,7 +25,7 @@
# this is where the documentation ends up
DOC= $(axiom_target_docdir)/src/sman
CFLAGS= ${CCF} -I$(INC) -I$(builddir)
-LDFLAGS= -L${LIB} -lspad ${LDF}
+LDFLAGS= -L${LIB} -lspad ${EXTRA_LIBS} ${LDF}
SMANOBJS= ${LIB}/libspad.a
--
Waldek Hebisch
address@hidden
- [Axiom-developer] better pty patch,
Waldek Hebisch <=