Dialog howto

From Open Watcom

Revision as of 14:17, 15 February 2011; view current revision
←Older revision | Newer revision→
Jump to: navigation, search

This was tried with Open Watcom 1.9 and pdcurses 3.4. It uses GNU configure and make tools, so you'll probably need msys installed and set up specifically for Watcom to run those tools. To build dialog libraries and example programs with Open Watcom, you can try these steps.

Download latest version of pdcurses from: http://archive.ubuntu.com/ubuntu/pool/universe/d/dialog/dialog_1.1-20080819.orig.tar.gz

Decompress and unarchive the dialog file. I use 7za (command line version of 7zip) for convenience. Here's an example:

7za x dialog_1.1-20080819.orig.tar.gz
7za x dialog_1.1-20080819.orig.tar

Be sure to change any necessary names for version numbers and tools you're using.

Go to source code directory. For example:

cd dialog_1.1-20080819

Apply the following patches before running configure:

perl -i.bk1 -pe 's/MINGW\*:\*/MINGW*:* | *:WATCOM*:*/' config.guess
perl -i.bk2 -pe 's/test \$cf_curs_lib = unknown/test \$cf_curs_lib = notunknown/' configure
perl -i.bk3 -pe 's/test \$cf_result = no && { { echo "\$as_me:9272/test \$cf_result = notno && { { echo "\$as_me:9272/' configure
patch -p2 < patch.diff

patch.diff contains:

diff -Naurp src/dialog-1.1-2008081/fselect.c tmp/dialog-1.1-20080819/fselect.c
--- src/dialog-1.1-20080819/fselect.c	2008-03-16 09:04:57 -0400
+++ tmp/dialog-1.1-20080819/fselect.c	2008-03-16 09:04:57 -0400
@@ -31,8 +31,13 @@
 # include <dirent.h>
 # define NAMLEN(dirent) strlen((dirent)->d_name)
 #else
+#if HAVE_DIRECT_H
+# include <direct.h>
+# define NAMLEN(dirent) strlen((dirent)->d_name)
+#else
 # define dirent direct
 # define NAMLEN(dirent) (dirent)->d_namlen
+#endif
 # if HAVE_SYS_NDIR_H
 #  include <sys/ndir.h>
 # endif
diff -Naurp src/dialog-1.1-2008081/ui_getc.c tmp/dialog-1.1-20080819/ui_getc.c
--- src/dialog-1.1-20080819/ui_getc.c	2008-03-16 16:02:20 -0400
+++ tmp/dialog-1.1-20080819/ui_getc.c	2008-03-16 16:02:20 -0400
@@ -24,6 +24,13 @@
 #include <dialog.h>
 #include <dlg_keys.h>
 
+#ifdef NEED_FCNTL_H
+#define F_GETFL 3
+#define SIGHUP 1
+#define SIGQUIT 3
+#include <fcntl.h>
+#endif
+
 #ifdef NEED_WCHAR_H
 #include <wchar.h>
 #endif
@@ -102,6 +109,7 @@ dlg_remove_callback(DIALOG_CALLBACK * p)
 static int
 dlg_getc_ready(DIALOG_CALLBACK * p)
 {
+#ifndef HAVE_NO_FD
     fd_set read_fds;
     int fd = fileno(p->input);
     struct timeval test;
@@ -113,6 +121,9 @@ dlg_getc_ready(DIALOG_CALLBACK * p)
     test.tv_usec = WTIMEOUT_VAL * 1000;		/* Microseconds.  */
     return (select(fd + 1, &read_fds, (fd_set *) 0, (fd_set *) 0, &test) == 1)
 	&& (FD_ISSET(fd, &read_fds));
+#else
+   return 0;
+#endif   
 }
 
 int
@@ -187,9 +198,11 @@ valid_file(FILE *fp)
 
     if (fd >= 0) {
 	long result = 0;
+#ifndef HAVE_NO_COMPAT_FCNTL
 	if ((result = fcntl(fd, F_GETFL, 0)) >= 0) {
 	    code = TRUE;
 	}
+#endif   
     }
     return code;
 }
@@ -395,7 +408,7 @@ dlg_killall_bg(int *retval)
 	    }
 	}
 	if (dialog_state.getc_callbacks != 0) {
-
+#ifndef HAVE_NO_FORK
 	    refresh();
 	    fflush(stdout);
 	    fflush(stderr);
@@ -445,6 +458,7 @@ dlg_killall_bg(int *retval)
 		    }
 		}
 	    }
+#endif   
 	}
     }
 }
diff -Naurp src/dialog-1.1-2008081/util.c tmp/dialog-1.1-20080819/util.c
--- src/dialog-1.1-20080819/util.c	2008-08-19 20:26:37 -0400
+++ tmp/dialog-1.1-20080819/util.c	2008-08-19 20:26:37 -0400
@@ -179,6 +179,7 @@ static int
 open_terminal(char **result, int mode)
 {
     const char *device = TTY_DEVICE;
+#ifndef HAVE_NO_ISATTY
     if (!isatty(fileno(stderr))
 	|| (device = ttyname(fileno(stderr))) == 0) {
 	if (!isatty(fileno(stdout))
@@ -189,6 +190,7 @@ open_terminal(char **result, int mode)
 	    }
 	}
     }
+#endif    
     *result = dlg_strclone(device);
     return open(device, mode);
 }

Type and enter:

./configure

Apply the following patches before running make:

cat patch_dlg_config.txt >>dlg_config.h
perl -i.bk1 -pe 's/LIBS		= -lunknown  -lx #/#/' makefile
perl -i.bk2 -pe 's/\$(RANLIB) \$@//' makefile
perl -i.bk3 -pe 's/\${AR} -cr/\${AR}/' makefile
perl -i.bk4 -pe 's/-L. -ldialog /-L. pdcurses.lib libdialog.a /' makefile
perl -i.bk5 -pe 's/VERSION//' makefile

patch_dlg_config.txt contains:

#define HAVE_COLOR 1
#define HAVE_FLUSHINP 1
#define HAVE_GETBEGX 1
#define HAVE_GETBEGY 1
#define HAVE_GETCURX 1
#define HAVE_GETCURY 1
#define HAVE_GETMAXX 1
#define HAVE_GETMAXY 1
#define HAVE_GETPARX 1
#define HAVE_GETPARY 1
#define HAVE_USE_DEFAULT_COLORS 1
#define HAVE_NO_ISATTY 1
#define NEED_FCNTL_H 1
#define HAVE_NO_FD 1
#define HAVE_NO_COMPAT_FCNTL 1
#define HAVE_NO_FORK 1
#define HAVE_DIRECT_H 1

At the command line, type and enter:

make

Use make to install the files. You can optionally add DESTDIR=path to the make install command in order to set the path where you want the files to be installed.

make install

This creates dialog.exe and dialog man pages. If you've created pdcurses for static linking no other library dependencies should be required.

You can automate the process by putting all these lines in a batch file or bash shell script.

An executable compiled using Open Watcom (along with source) is available at: http://criticalpressmedia.com/2011/02/mini-repository-for-windows-software-dialog-simple-user-interface/

Personal tools