[comp.sources.x] v06i006: xchess under HP-UX diffs, Patch1

argv%turnpike@Sun.COM (Dan Heller) (02/28/90)

Submitted-by: Konstantinos Konstantinides <uunet!hpkronos.hp.com!kk>
Posting-number: Volume 6, Issue 6
Archive-name: xchess-hpux/patch1

This file contains the differences so that xchess runs under HP-UX
K. Konstantinides
kk@hpkronos.hpl.hp.com

--------------------------
# This is a shell archive.  Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by Konstantinos Konstantinides <kk@hpkronos> on Fri Jan  5 10:12:40 1990
#
# This archive contains:
#	READ_HPUX	Makefile.hpux	chess_dif	
#

LANG=""; export LANG
PATH=/bin:/usr/bin:$PATH; export PATH

echo x - READ_HPUX
cat >READ_HPUX <<'@EOF'
Revision: Nov. 8, 1989
This is chess for the X11 window system

Since HP doesn't have the chesstool program, a small modification
in the code of gnuchess.c permits gnuchess to be used with the xchess program.
A new flag (-l level) in xchess permits the user to specify the search level
time limit (default is 30 sec).
After compiling gnuchess (make) and xchess (make -f Makefile.hpux in
the Xchess directory) , a typical command will be

xchess -i -c -p /usr/local/games/gnuchessr -l 20

This uses the english notation, to play with the computer, a game
of gnuchess, at a level of 20 sec (max) per move.

Another typical command will be

xchess -i -c -p /usr/local/games/gnuchessr -t 20 5

This requires from gnuchessr to play the first 20 moves in 5 minutes

Other options in xchess
 -f : recordfile
 -r : saved file

Of course you can play gnuchess with no xwindows (see the man page of
gnuchess)
-------------------------------------------------------
Revision: Sept. 26/89

Fixed the noisy-flag and the flash-flag problems.

For example, my .X11defaults now has
/*
 *xchess
 */
xchess*savemoves:       on
xchess*algebraic:       on
xchess*flash:           on
xchess*numflashes:      5
xchess*noisy:           on
xchess*progname:        /usr/local/games/gnuchessr

Then I play with: xchess -c -l 10

K. Konstantinides kk@hpkronos
@EOF

chmod 600 READ_HPUX

echo x - Makefile.hpux
cat >Makefile.hpux <<'@EOF'

# RCS Info: $Revision: 1.5 $ on $Date: 86/11/26 12:09:19 $
#           $Source: /users/faustus/xchess/RCS/Makefile,v $
# Copyright (c) 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#
# Makefile for xchess.

CC = cc -O

CFILES	=\
	board.c\
	button.c\
	clock.c\
	control.c\
	jail.c\
	message.c\
	parse.c\
	popup.c\
	program.c\
	record.c\
	std.c\
	valid.c\
	window.c\
	XCircle.c

COBJS	=\
	board.o\
	button.o\
	clock.o\
	control.o\
	jail.o\
	message.o\
	parse.o\
	popup.o\
	program.o\
	record.o\
	std.o\
	valid.o\
	window.o\
	XCircle.o

HFILES	=\
	std.h\
	xchess.h

SOURCE = $(CFILES)

ALLFILES = $(SOURCE) $(HFILES)
#DESTDIR = /global
DESTDIR = /usr/local/games
#INCLUDE = -I. -I$(DESTDIR)/include
INCLUDE = -I.

#DEFINES = -DDEF_PROGRAM=\"$(DESTDIR)/bin/gnuchessr\"
DEFINES = -DDEF_PROGRAM=\"$(DESTDIR)/gnuchessr\"

CFLAGS = $(DEFINES) $(INCLUDE) 
LINTFLAGS = -u -z -lc -DLINT $(DEFINES) $(INCLUDE)
LINTLIB = ../lib/llib-lX.ln
#LDFLAGS = -L$(DESTDIR)/lib -z -loldX -lX11 -lm
LDFLAGS = -loldX -lXw -lXt -lXext -lX11 -lm -lBSD
GPLDFLAGS = -z -lXMenu_p -lX -lm_p -g -pg

.c.o: $*.c
	$(CC) $(CFLAGS) -c $*.c +Nd2000 +Ns2000 +Ne1000
.s.o: $*.s
	$(CC) $(CFLAGS) -c $*.s

all: xchess scrollText.o
	@echo "All done."

everything: all tags depend lint wc
	@echo "All done."

xchess:	xchess.o $(COBJS) scrollText.o
	$(CC) -o xchess xchess.o $(COBJS) scrollText.o \
	$(LDFLAGS)

scrollText.o: scrollText.h scrollText.c

gpxchess: xchess.o $(COBJS)
	$(CC) -o gpxchess xchess.o $(COBJS) scrollText/libScroll.a \
	$(GPLDFLAGS)

lint:	$(SOURCE)
	lint $(LINTFLAGS) $(SOURCE) $(LINTLIB) | \
	grep -v "multiply declared"

qgrind: $(ALLFILES)
	qgrind -lc $(ALLFILES)

vgrind:	$(ALLFILES)
	vgrind -lc $(ALLFILES)

opt: all

reopt: all

install: all

source:	$(SOURCE) 

tags: $(ALLFILES)
	ctags -w -t *.c *.h > /dev/null 2>&1

wc: $(ALLFILES)
	@wc $(ALLFILES)

print: $(ALLFILES)
	@pr $(ALLFILES)

clean:
	rm -f *.o *.a *.out xchess tags foo tmp

tar:
	tar -cvf xchess.tar Makefile *.h *.c *.bitmap *.icon *.cur *.1\
	scrollText/Makefile scrollText/*.h scrollText/*.c scrollText/*.1\
	scrollText/*.3

$(ALLFILES):
	co $@

depend: $(SOURCE)
	cc -M $(CFLAGS) $(CFILES) > makedep
	echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
	echo '$$r makedep' >>eddep
	echo 'w' >>eddep
	ed - Makefile < eddep
	rm eddep makedep 
	echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
	echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
	echo '# see make depend above' >> Makefile

#-----------------------------------------------------------------
# DO NOT DELETE THIS LINE -- make depend uses it
# DEPENDENCIES MUST END AT END OF FILE

xchess.o $(COBJS): $(HFILES)

@EOF

chmod 644 Makefile.hpux

echo x - chess_dif
cat >chess_dif <<'@EOF'
---control.c
131c131
< 		message_add(win, "Hey, you touch it, you move it, buddy.\n",
---
> 		message_add(win, "Hey, you move it now, buddy.\n",
237a238
> 	    if(win2->display != 0)
---program.c
1d0
< 
33a33,35
> #ifdef hpux
> #include <time.h>
> #else
34a37
> #endif
42,43c45,46
< program_init(name)
< 	char *name;
---
> program_init(name,level)
> 	char *name, *level;
48a52
> 	extern int flag;
64,65c68,69
< 			execl("/usr/ucb/rsh", "rsh", proghost, name,
< 					moves, time, 
---
> 			execl("/usr/ucb/rsh", "remsh", proghost, name,level,
> 			/*		moves, time,  */
68c72,80
< 			execl(name, name, moves, time, (char *) NULL);
---
> 		switch (flag) {
> 		case 0 :execl(name, name, (char *) NULL);
> 			break;
> 		case 1 :execl(name, name, level, (char *) NULL);
> 			break;
> 		case 2 :execl(name, name, moves, time, (char *) NULL);
> 			break;
> 		default:execl(name, name, (char *) NULL);
> 			}
---std.c
1d0
< 
247a247,253
> 
> #ifdef  hpux
> #define index   strchr
> #define rindex  strrchr
> #define bcopy(a,b,c)    memcpy(b,a,c)
> #define bzero(a,b)      memset(a,0,b)
> #endif
---std.h
1d0
< 
31a31,33
> #ifdef hpux
> #undef BSD
> #endif
41a44,46
> #ifdef  hpux
> #include <string.h>
> #else
42a48
> #endif
---window.c
414c414
< 		0, LineSolid, 0, 0);
---
> 		flash_size, LineSolid, 0, 0);
---xchess.c
1d0
< 
24c23
<  *           $Source: /usr/local/src/source/X.V11R3/contrib/games/xchess/Xchess/RCS/xchess.c,v $
---
>  *           $Source: /usr/local/src/source/X.V11R3/contrib/games/xchess/Xchess/ RCS/xchess.c,v $
26,27c25,26
<  *	Permission is granted to do anything with this code except sell it
<  *	or remove this message.
---
>  *      Permission is granted to do anything with this code except sell it
>  *      or remove this message.
31,32c30,31
< \t[ -t moves/timeunit ] [ -c ] [ -p program ]  [ -b ] [ -bnw ] [ -s ]\n\
< \t[ -n ] [ -h host ] [ -v ] [ -R ] [ whitedisplay ] [ blackdisplay ]"
---
> \t[ -t moves timelimit(min) ] [ -c ] [ -p program ]  [ -b ] [ -bnw ] [ -s ]\n\
> \t[ -n ] [ -h host ] [ -v ] [ -R ] [ whitedisplay ] [ blackdisplay ] [-l level]"
44a44,45
> char *level;
> int flag=0;
87c88
< 	signal(SIGCHLD, die);
---
> 	signal(SIGCHLD, die); 
117a119
> 				flag = 2;
119,120c121,123
< 				if (s = index(*av, '/'))
< 					timeunit = atoi(s + 1) * 60;
---
> 				av++; ac--;
> 				if (*av)
> 					timeunit = atoi(*av) * 60;
130a134,142
> 		} else if (eq(*av, "-l")) {
> 			av++; ac --;
> 			if (*av)
> 				{
> 				level = *av;
> 				flag =1;
> 				}
> 			else
> 				goto usage;
182c194
< 		if (!program_init(progname))
---
> 		if (!program_init(progname,level))
@EOF

chmod 644 chess_dif

exit 0

dan
-----------------------------------------------------------
		    O'Reilly && Associates
		argv@sun.com / argv@ora.com
	   632 Petaluma Ave, Sebastopol, CA 95472 
     800-338-NUTS, in CA: 800-533-NUTS, FAX 707-829-0104
    Opinions expressed reflect those of the author only.