dvadura@watdragon.waterloo.edu (Dennis Vadura) (10/15/90)
Posting-number: Volume 15, Issue 60 Submitted-by: Dennis Vadura <dvadura@watdragon.waterloo.edu> Archive-name: dmake-3.6/part08 #!/bin/sh # this is part 8 of a multipart archive # do not concatenate these parts, unpack them in order with /bin/sh # file msdos/tccdos/config.mk continued # CurArch=8 if test ! -r s2_seq_.tmp then echo "Please unpack part 1 first!" exit 1; fi ( read Scheck if test "$Scheck" != $CurArch then echo "Please unpack part $Scheck next!" exit 1; else exit 0; fi ) < s2_seq_.tmp || exit 1 echo "x - Continuing file msdos/tccdos/config.mk" sed 's/^X//' << 'SHAR_EOF' >> msdos/tccdos/config.mk X# directory. X# Xosrdir := $(OS)$(DIRSEPSTR)$(OSRELEASE) X X# tlink does not know how to deal with tmpfiles that have e:\ in their path. XTMPDIR := X.EXPORT : TMPDIR X X# Definition of macros for library, and C startup code. XLDLIBS = c:/lib.tcc/c$(MODEL) XCSTARTUP = c:/lib.tcc/c0$(MODEL).obj X X# The following sources are required for TURBO C 2.0 XOSR_SRC = tempnam.c utime.c X.SETDIR=$(osrdir) : $(OSR_SRC) X XSRC += $(OSR_SRC) X.SOURCE.h : $(osrdir) X X# Local configuration modifications for CFLAGS. Make sure your turboc.cfg X# file contains a -D__STDC__=1 and -DM_I86=1, if not then uncomment the line X# below! X#CFLAGS += -DM_I86=1 -D__STDC__=1 X X# You can get a smaller executable still, buy adding a -1 to the list of X# flags below, but then you can't run this on an 8086/88 cpu. X#CFLAGS += -1 XCFLAGS += -I$(osrdir) -f- -d -O -N- -w-nod $(C_$(MODEL)) XASFLAGS += -t -mx $(S_$(MODEL)) X X# See if we modify anything in the lower levels. X.IF $(OSENVIRONMENT) != $(NULL) X .INCLUDE .IGNORE : $(osrdir)$(DIRSEPSTR)$(OSENVIRONMENT)$(DIRSEPSTR)config.mk X.END X XC_s = XC_m = -mm XC_c = -mc XC_l = -ml X XS_s = -dmsmall XS_m = -dmmedium XS_c = -dmcompact XS_l = -dmlarge SHAR_EOF echo "File msdos/tccdos/config.mk is complete" chmod 0640 msdos/tccdos/config.mk || echo "restore of msdos/tccdos/config.mk fails" echo "x - extracting msdos/tccdos/config.h (Text)" sed 's/^X//' << 'SHAR_EOF' > msdos/tccdos/config.h && X/* RCS -- $Header: /u2/dvadura/src/generic/dmake/src/msdos/tccdos/RCS/config.h,v 1.1 90/10/06 12:05:10 dvadura Exp $ X-- SYNOPSIS -- Configurarion include file. X-- X-- DESCRIPTION X-- There is one of these for each specific machine configuration. X-- It can be used to further tweek the machine specific sources X-- so that they compile. X-- X-- AUTHOR X-- Dennis Vadura, dvadura@watdragon.uwaterloo.ca X-- CS DEPT, University of Waterloo, Waterloo, Ont., Canada X-- X-- COPYRIGHT X-- Copyright (c) 1990 by Dennis Vadura. All rights reserved. X-- X-- This program is free software; you can redistribute it and/or X-- modify it under the terms of the GNU General Public License X-- (version 1), as published by the Free Software Foundation, and X-- found in the file 'LICENSE' included with this distribution. X-- X-- This program is distributed in the hope that it will be useful, X-- but WITHOUT ANY WARRANTY; without even the implied warrant of X-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X-- GNU General Public License for more details. X-- X-- You should have received a copy of the GNU General Public License X-- along with this program; if not, write to the Free Software X-- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X-- X-- LOG X-- $Log: config.h,v $ X * Revision 1.1 90/10/06 12:05:10 dvadura X * dmake Release, Version 3.6 X * X*/ X X/* define this for configurations that don't have the coreleft function X * so that the code compiles. To my knowledge coreleft exists only on X * Turbo C, but it is needed here since the function is used in many debug X * macros. */ X/*#define coreleft() 0L*/ Xextern unsigned int coreleft(); X#define SIGQUIT SIGTERM /* turbo C doesn't understand SIGQUIT */ X X/*No parallelism in DOS so don't need to explode the graph. */ X#define Explode_prq(a,b,c) SHAR_EOF chmod 0440 msdos/tccdos/config.h || echo "restore of msdos/tccdos/config.h fails" echo "x - extracting msdos/sysintf.h (Text)" sed 's/^X//' << 'SHAR_EOF' > msdos/sysintf.h && X/* X** assorted bits of system interface X*/ X#include <sys/types.h> X#include <sys/stat.h> X#include <signal.h> X X#define STAT stat X#define VOID_LCACHE(l,m) Xextern char * tempnam(); Xextern char * getcwd(); X X/* X** standard C items X*/ X X/* X** DOS interface standard items X*/ X#define chdir(p) _chdir(p) X X/* X** make parameters X*/ X#define MAX_PATH_LEN 64 X SHAR_EOF chmod 0440 msdos/sysintf.h || echo "restore of msdos/sysintf.h fails" echo "x - extracting msdos/switchar.c (Text)" sed 's/^X//' << 'SHAR_EOF' > msdos/switchar.c && X/* X** return switch char X*/ X#if defined(OS2) X#include <stdlib.h> X#else X#include <dos.h> X#endif /* OS2 */ X#include <stdio.h> X#include "stdmacs.h" X Xgetswitchar()/* X=============== X Try the environment first. If you don't find SWITCHAR there, then use X the DOS call. The call is undocumented, and doesn't work for DOS versions X 4.0 and up, so the check of the environment will fix that. */ X{ X#if defined(M_I86) X#if !defined(OS2) X union REGS rg; X#endif /* ! OS2 */ X static char *_env_switchar = NIL(char); X X if( _env_switchar != NIL(char) || X (_env_switchar = (char *)getenv("SWITCHAR")) != NIL(char) ) X return(*_env_switchar); X X#if !defined(OS2) X rg.h.ah = 0x37; /* switch char request */ X rg.h.al = 0; /* get (not set) */ X X intdos(&rg, &rg); X return (rg.h.dl); X#endif /* ! OS2 */ X#endif /* M_I86 */ X X return ('-'); X} SHAR_EOF chmod 0440 msdos/switchar.c || echo "restore of msdos/switchar.c fails" echo "x - extracting msdos/stdarg.h (Text)" sed 's/^X//' << 'SHAR_EOF' > msdos/stdarg.h && X/* X * stdarg.h X * X * defines ANSI style macros for accessing arguments of a function which takes X * a variable number of arguments X * X */ X X#if !defined(__STDARG) X#define __STDARG X Xtypedef char *va_list; X X#define va_dcl int va_alist X#define va_start(ap,v) ap = (va_list)&va_alist X#define va_arg(ap,t) ((t*)(ap += sizeof(t)))[-1] X#define va_end(ap) ap = NULL X#endif SHAR_EOF chmod 0440 msdos/stdarg.h || echo "restore of msdos/stdarg.h fails" echo "x - extracting msdos/startup.h (Text)" sed 's/^X//' << 'SHAR_EOF' > msdos/startup.h && X/* This file contains the default value of the MAKESTARTUP variable. X * You must set the quoted string below to the default path to the startup X * variable, so that it gets compiled in. LEAVE ROOTDIR at the front of X * the path. This allows the user to customize his environment for dmake X * by setting up a new ROOTDIR environment variable. */ X X"MAKESTARTUP := $(ROOTDIR)/etc/startup.mk", SHAR_EOF chmod 0440 msdos/startup.h || echo "restore of msdos/startup.h fails" echo "x - extracting msdos/spawn.c (Text)" sed 's/^X//' << 'SHAR_EOF' > msdos/spawn.c && X/* RCS -- $Header: /u2/dvadura/src/generic/dmake/src/msdos/RCS/spawn.c,v 1.1 90/10/06 12:05:46 dvadura Exp $ X-- SYNOPSIS -- spawnvpe code to emulate spawnvpe call common to DOS compilers. X-- X-- DESCRIPTION X-- This implementation is further integrated into dmake in that it X-- determines the program to execute and if it's extension is either X-- .bat or .ksh it executes it using the appropriate shell based on the X-- setting of .MKSARGS. Additionally if .MKSARGS is set then in addition X-- to the command tail getting built the arguments are also passed in the X-- environment pursuant to the published MKS argument passing conventions. X-- If the variable Swap_on_exec is set and the DOS OS supports it X-- then the dmake executable image is swapped to secondary storage prior X-- to running the child process. This is requested by setting the X-- appropriate flag in the call to exec. X-- X-- This and the exec.asm routine are derived from work that was supplied X-- to me by Kent Williams (williams@umaxc.weeg.uiowa.edu) and by X-- Len Reed, (..!gatech!holos0!lbr or holos0!lbr@gatech.edu., Holos X-- Software, Inc., Tucker, Ga.). I sincerely acknowledge their help since X-- their Turbo C, and MSC 6.0 code lead directly to this combined X-- swapping exec that hopefully works with either compiler in all memory X-- models. X-- X-- AUTHOR X-- Dennis Vadura, dvadura@watdragon.uwaterloo.ca X-- CS DEPT, University of Waterloo, Waterloo, Ont., Canada X-- X-- COPYRIGHT X-- Copyright (c) 1990 by Dennis Vadura. All rights reserved. X-- X-- This program is free software; you can redistribute it and/or X-- modify it under the terms of the GNU General Public License X-- (version 1), as published by the Free Software Foundation, and X-- found in the file 'LICENSE' included with this distribution. X-- X-- This program is distributed in the hope that it will be useful, X-- but WITHOUT ANY WARRANTY; without even the implied warrant of X-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X-- GNU General Public License for more details. X-- X-- You should have received a copy of the GNU General Public License X-- along with this program; if not, write to the Free Software X-- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X-- X-- LOG X-- $Log: spawn.c,v $ X * Revision 1.1 90/10/06 12:05:46 dvadura X * dmake Release, Version 3.6 X * X*/ X X#include <stdio.h> X#include <stdlib.h> X#include <process.h> X#include <dos.h> X#include <errno.h> X#include <string.h> X#include <alloc.h> X#include "dirlib.h" X#include "exec.h" X#include "sysintf.h" X#include "extern.h" X X#ifdef DEBUG Xstatic void _dump_blocks(); X#endif X Xextern int Interrupted; X X/* variables and functions local to this file */ Xstatic char *_findexec ANSI((char *, int *)); Xstatic char **_getpath ANSI(()); Xstatic void _dos_free ANSI((char far *)); Xstatic char far *_dos_alloc ANSI((uint16)); X Xstatic uint16 _swap_mask; Xstatic int _mks_args; Xstatic char dot_com[] = ".COM", X dot_exe[] = ".EXE", X dot_bat[] = ".BAT", X dot_ksh[] = ".KSH"; X X/* Kinds of executables */ X#define SCR 1 X#define COM 2 X#define EXE 4 X#define ALL (SCR|COM|EXE) X X/* How to make a long pointer */ X#define CF(x) (char far *)x X X#if defined(_MSC60_) X#define CONST const X#else X#define CONST X#endif X Xint Xspawnvpe(mode, program, av, ep)/* X================================= X Spawn a process using an environment and a vector of arguments. X The code computes a new environment, puts the MKS arguments into X it if need be, and calls the appropriate routines to search the X path and to invoke the process. */ Xint mode; Xchar *program; XCONST char **av; XCONST char **ep; X{ X char **envp = ep; /* Cause we are going to mess with it. */ X char **argv = av; /* Same with this one. */ X char cmdtail[129]; X char far *envsave; X char far *environment; X char *tail; X char *swptmp; X unsigned int envsize; X unsigned int cmdsize; X int cmdtailen; X int i; X int doswap; X X /* First check to see if we can find the program to execute this way we X * don't alloc the environment and other such stuff prior to figuring out X * we don't know how to run the program. */ Xfind_program: X if((program = _findexec(program, &i)) == NIL(char)) { X errno = ENOENT; X return( -1 ); X } X X /* i is set to TRUE in _findexec if the exec is a shell X * script (either .BAT or .KSH file), returns FALSE for all others. */ X if( i && !Packed_shell ) { X /* Restore the spaces into the command line that were erased by X * the previous call to Pack_argv. This enables us to repack the X * command as a shell command using Pack_argv again. */ X for( i=0; argv[i] != NIL(char); i++ ) { X int x = strlen(argv[i]); X if( argv[i+1] != NIL(char) ) argv[i][x] = ' '; X } X X argv = Pack_argv( FALSE, TRUE, *argv ); X X /* Go and find the program again, I hate goto's but it seems silly to X * use tail recursion just for aesthetic purity here :-) */ X program = *argv; X goto find_program; X } X X /* Compute size of *argv vector for passing as MKS style arguments */ X cmdsize = strlen(*argv)+2; X X /* So we have decided on a program to run, therefore pack the command tail X * and build the environment to pass to the exec code. This loop packs the X * DOS command tail, and computes the size of all arguments for the MKS X * argument passing convention. Note that we reserve one less byte in the X * command tail if we are not using MKS style argument passing. X * X * Make sure the command tail contains at leat a space. Some commands fail X * to work if the command tail is only a \r, STUPID DOS! */ X cmdtailen = (_mks_args = ((Glob_attr & A_MKSARGS) != 0))?3:2; X tail = cmdtail+1; X X if( argv[1] != NIL(char) ) X for( i=1; argv[i] != NIL(char); i++ ) { X int arglen = strlen(argv[i]); X X cmdsize += arglen+2; /* Compute all args size for MKS */ X X if( (cmdtailen += arglen+1) <= 128 ) { X register char *p = argv[i]; X tail[-1] = ' '; /* put in the space */ X while( *tail++ = *p++ ); /* put in the arg */ X } X else if( !_mks_args ) { X errno = E2BIG; /* unless its MKS exit if arglist */ X return(-1); /* is too long. */ X } X } X else X *tail++ = ' '; X X /* Finish the command tail set up, placing the length in the first byte, X * and the \r \n \0 at the end for DOS, MKS and us respectively. */ X *cmdtail = tail-cmdtail-2; X tail[-1] = '\r'; X if( _mks_args ) *tail++ = '\n'; X *tail = '\0'; X X /* Compute size of environment, skipping any MKS arguments passed in our X * environment */ X for(; *envp && **envp == '~'; envp++ ); X for(i=0, envsize=_mks_args?cmdsize:1; envp[i] != NIL(char); i++ ) X envsize += strlen(envp[i]) + 1; X envsize += strlen(program)+3; /* Save space for program name */ X X /* Set up temporary file for swapping */ X swptmp = (doswap=Swap_on_exec&_swap_mask)?tempnam(NIL(char),"mk"):""; X X /* Allocate an appropriate sized environment block and align it on a X * paragraph boundary. It will later get copied to an appropriately low X * place in the executable image so that when we swap out the environment X * is still present. Use X * _dos_alloc X * _dos_free X * to allocate and free the environment segment */ X X envsave = environment = _dos_alloc( envsize = ((envsize+16)>>4) ); X X /* First copy the arguments preceeded by ~ character if we are using X * MKS style argument passing */ X if( _mks_args ) X for(; *argv; argv++) { X register char *p = *argv; X X *environment++ = '~'; X while( *environment++ = *p++ ); /* Far dest, poss near ptr */ X } X X /* Now stick in the current evironment vectors. */ X for(; *envp; envp++) { X register char *p = *envp; X while( *environment++ = *p++ ); /* Far dest, poss near ptr */ X } X X /* Terminate the environment with a NULL char, and then a word containing X * the number 1 (why? beats me, but probably has something to do with X * sticking the program name at the end of the environment, and is possibly X * headed for an extension to argument passing conventions in future DOS X * versions. For now all they have is the name of the program. */ X *environment++ = '\0'; *environment++ = '\0'; *environment++ = '\1'; X { X register char *p = program; X while( *environment++ = *p++ ); /* Far dest, poss near ptr */ X } X X /* Clear the interrupted flag, and exec */ X Interrupted = 0; X i = exec(doswap,CF(program),CF(cmdtail),FP_SEG(environment),envsize, X CF(swptmp)); X X /* Now free the environment segment */ X _dos_free( envsave ); X if( doswap ) FREE(swptmp); X X /* If swap was interrupted then quit properly from dmake. */ X if( Interrupted ) Quit(); X X return(i); X} X X X/* X** _findexec finds executables on the path. X** Note that it is pretty simple to add support for other executable types X** (shell scripts, etc. X** X** This follows the command.com behavior very closely. X*/ Xstatic char * X_findexec( s, is_shell )/* X========================== X Cloned closely from code provided by Kent Williams. Stripped his down to X a reduced search since dmake doesn't need to recompute the PATH vector X each time it does the search since it cannot alter the path vector once X it begins to make recipes. Also modified it to use findfirst and findnext X as provided for dirlib package that I got off the net. */ Xchar *s; Xint *is_shell; X{ X unsigned found_flags; X char **pathv = NIL(char *); X char *ext = NIL(char); X char *buf = NIL(char); X char *p[2]; X char *dot_scr; X char *dot; X X p[0] = ""; p[1] = NIL(char); X if( strchr("./\\", *s) || s[1] == ':' ) X pathv = p; X else if( (pathv = _getpath()) == NIL(char *) ) X return( NIL(char) ); X X /* Compute the extension we need if any. */ X if( (dot = strrchr(s,'.')) != NIL(char) && X dot > strrchr(s,'/') && dot > strrchr(s,'\\') ) X ext = dot+1; X X dot_scr = _mks_args ? dot_ksh : dot_bat; X *is_shell = FALSE; X X for( found_flags = 0; *pathv && !found_flags; pathv++ ) { X DTA dta; X X if( !ext ) { X char *name; X buf = Build_path( *pathv, name=_strjoin(s, ".???", -1, FALSE) ); X FREE(name); X } X else X buf = Build_path( *pathv, s ); X X if( findfirst(strupr(buf), &dta) != NIL(DTA) ) { X if( !ext ) { X char *dot; X X /* search order is .com .exe (.ksh || .bat) X * there has to be a '.' */ X do { X dot = strrchr(dta.name,'.'); X if(0 == strcmp(dot,dot_com)) X found_flags |= COM; X else if(0 == strcmp(dot,dot_exe)) X found_flags |= EXE; X else if( 0 == strcmp(dot,dot_scr) ) X found_flags |= SCR; X } while( found_flags != ALL && findnext(&dta) != NIL(DTA) ); X X if(found_flags & COM) ext = dot_com; X else if(found_flags & EXE) ext = dot_exe; X else if(found_flags & SCR) { X ext = dot_scr; X *is_shell = TRUE; X } X X if( found_flags ) { X char *name; X buf = Build_path( *pathv, name=_strjoin(s,ext,-1,FALSE) ); X FREE(name); X strupr(buf); X } X } X else X break; X } X } X X return( buf ); X} X X X/* X** getpath turns the DOS path into a char *vector, It is gotten and X** transformed only once since dmake can't modify the value of PATH while X** it is making targets. X*/ Xstatic char ** X_getpath() X{ X static char **dir = NIL(char *); X register char *p; X X if( !dir ) { X register char *t; X int i; X char *semi = NIL(char); X X /* Check the DOS version number here. If it is < 3.0 then we don't X * even want to think about executing the swapping code. Permanently X * set swap to 0. */ X _swap_mask = (_osmajor < 3) ? 0x0 : 0xffff; X X if( (p = getenv("PATH")) == NIL(char) ) p = ""; X for( i=0, t=p; *t; t++ ) if( *t == ';' ) i++; X X TALLOC(dir, i+1, char *); X p = _strdup(p); X X for( i=0; p; p = semi ? (semi+1):NIL(char),i++ ){ X if( (semi = strchr(p,';')) != NIL(char) ) *semi = '\0'; X dir[i] = p; X } X } X X return( dir ); X} X X Xstatic char far * X_dos_alloc( size )/* X==================== X This routine allocates size paragraphs from DOS. It changes the memory X allocation strategy to allocate from the tail and then changes it back. X to using first fit. */ Xuint16 size; X{ X union REGS r; X union REGS t; X X r.x.ax = 0x5801; X r.x.bx = 0x0002; X intdos( &r, &r ); X X r.h.ah = 0x48; X r.x.bx = size; X X intdos( &r, &r ); X if( r.x.cflag ) No_ram(); X X t.x.ax = 0x5801; X t.x.bx = 0x0000; X intdos( &t, &t ); X X return( (char far *) MK_FP(r.x.ax, 0) ); X} X X X#if defined(_MSC60_) X#pragma pack(1) X#endif Xtypedef struct { X char mode; X unsigned int owner; X unsigned int size; X} MB, *MBPTR; X#if defined(_MSC60_) X#pragma pack() X#endif X Xstatic void X_dos_free( pblock )/* X===================== X ALERT!!!! Major GROSSNESS HERE!!!! This routine calls DOS free to free X a block of memory and then walks the DOS allocation chain from the current X psp forward and coallesces any free blocks it finds into one large free X block. This prevents the No more memory error that was being caused by X long makes causing fragmentation of DOS memory. I can probably avoid this X by using some weird combination of DOS calls, but I would have to figger X out what calls under DOS cause the coalesce to happen. Haven't found this X so far so, for now, I will just go with this. It work fine on my box :-)*/ Xchar far *pblock; X{ X union REGS r; X struct SREGS s; X MB far *p; X MB far *t; X int flag = 0; X X s.es = FP_SEG(pblock); X r.h.ah = 0x49; X intdosx( &r, &r, &s ); X if( r.x.cflag ) Fatal( "FREE SEG" ); X X p = (MB far *) MK_FP(_psp-1, 0); X X while(1) { X if( p->owner == 0 ) X if( !flag ) { X t = p; X flag++; X } X else if( FP_SEG(t)+t->size+1 == FP_SEG(p) ) X t->size += p->size+1; X X if( p->mode == 'Z' ) break; X p = (MB far *) MK_FP(FP_SEG(p)+p->size+1, 0); X } X X} X X X#ifdef DBUG Xstatic void X_dump_blocks()/* X================ X Walk DOS memory blocks and dump their headers. */ X{ X MB far *p; X X p = (MB far *) MK_FP( _psp-1, 0 ); X X while(1) { X printf( "%c 0x%04x 0x%04x 0x%04x:%d\n", p->mode, FP_SEG(p), p->owner, X p->size, p->size ); X X if( p->mode == 'Z' ) break; X p = (MB far *) MK_FP( FP_SEG(p)+p->size+1, 0 ); X } X} X#endif SHAR_EOF chmod 0440 msdos/spawn.c || echo "restore of msdos/spawn.c fails" echo "x - extracting msdos/runargv.c (Text)" sed 's/^X//' << 'SHAR_EOF' > msdos/runargv.c && X/* RCS -- $Header: /u2/dvadura/src/generic/dmake/src/msdos/RCS/runargv.c,v 1.1 90/10/06 12:05:30 dvadura Exp $ X-- SYNOPSIS -- run a sub process. X-- X-- DESCRIPTION X-- Use spawn to run a subprocess. X-- X-- AUTHOR X-- Dennis Vadura, dvadura@watdragon.uwaterloo.ca X-- CS DEPT, University of Waterloo, Waterloo, Ont., Canada X-- X-- COPYRIGHT X-- Copyright (c) 1990 by Dennis Vadura. All rights reserved. X-- X-- This program is free software; you can redistribute it and/or X-- modify it under the terms of the GNU General Public License X-- (version 1), as published by the Free Software Foundation, and X-- found in the file 'LICENSE' included with this distribution. X-- X-- This program is distributed in the hope that it will be useful, X-- but WITHOUT ANY WARRANTY; without even the implied warrant of X-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X-- GNU General Public License for more details. X-- X-- You should have received a copy of the GNU General Public License X-- along with this program; if not, write to the Free Software X-- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X-- X-- LOG X-- $Log: runargv.c,v $ X * Revision 1.1 90/10/06 12:05:30 dvadura X * dmake Release, Version 3.6 X * X*/ X X#include "sysintf.h" X#include "extern.h" X#include <process.h> X#include <string.h> X#include <errno.h> X Xstatic int _abort_flg = FALSE; Xstatic void _add_child ANSI((CELLPTR, HOWPTR, int)); Xstatic void _finished_child ANSI((int)); X Xint Xrunargv(target, how, ignore, group, last, shell, cmd) XCELLPTR target; XHOWPTR how; Xint ignore; Xint group; Xint last; Xint shell; Xchar *cmd; X{ X extern char **environ; X int status; X char **argv; X X argv = Pack_argv( group, shell, cmd ); X _add_child(target, how, ignore); X status = spawnvpe(P_WAIT, *argv, argv, environ); X if( status == -1 ) Error("%s: %s", argv[0], strerror(errno)); X _finished_child(status); X if( last && !Doing_bang ) Update_time_stamp( target, how ); X X return( 0 ); X} X X Xvoid XClean_up_processes() X{ X _abort_flg = TRUE; X _finished_child(-1); X} X X Xint XWait_for_child( abort_flg, pid ) Xint abort_flg; Xint pid; X{ X return(1); X} X X Xstatic int _valid = -1; Xstatic CELLPTR _tg; Xstatic HOWPTR _how; Xstatic int _ignore; X Xstatic void X_add_child( target, how, ignore ) XCELLPTR target; XHOWPTR how; Xint ignore; X{ X _tg = target; X _ignore = ignore; X _how = how; X _valid = 0; X X Current_target = NIL(HOW); X} X X Xstatic void X_finished_child(status) Xint status; X{ X if( _valid == -1 ) return; X Unlink_temp_files( _how ); X _valid = -1; X Handle_result( status, _ignore, _abort_flg, _tg ); X} SHAR_EOF chmod 0440 msdos/runargv.c || echo "restore of msdos/runargv.c fails" echo "x - extracting msdos/ruletab.c (Text)" sed 's/^X//' << 'SHAR_EOF' > msdos/ruletab.c && X/* RCS -- $Header: /u2/dvadura/src/generic/dmake/src/msdos/RCS/ruletab.c,v 1.1 90/10/06 12:05:28 dvadura Exp $ X-- SYNOPSIS -- Default initial configuration of dmake. X-- X-- DESCRIPTION X-- Define here the initial set of rules that are defined before X-- dmake performs any processing. X-- X-- AUTHOR X-- Dennis Vadura, dvadura@watdragon.uwaterloo.ca X-- CS DEPT, University of Waterloo, Waterloo, Ont., Canada X-- X-- COPYRIGHT X-- Copyright (c) 1990 by Dennis Vadura. All rights reserved. X-- X-- This program is free software; you can redistribute it and/or X-- modify it under the terms of the GNU General Public License X-- (version 1), as published by the Free Software Foundation, and X-- found in the file 'LICENSE' included with this distribution. X-- X-- This program is distributed in the hope that it will be useful, X-- but WITHOUT ANY WARRANTY; without even the implied warrant of X-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X-- GNU General Public License for more details. X-- X-- You should have received a copy of the GNU General Public License X-- along with this program; if not, write to the Free Software X-- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X-- X-- LOG X-- $Log: ruletab.c,v $ X * Revision 1.1 90/10/06 12:05:28 dvadura X * dmake Release, Version 3.6 X * X*/ X X/* These are control macros for dmake that MUST be defined at some point X * if they are NOT dmake will not work! These are default definitions. They X * may be overridden inside the .STARTUP makefile, they are here X * strictly so that dmake can parse the STARTUP makefile */ X Xstatic char *_rules[] = { X "MAXLINELENGTH := 2046", X "MAXPROCESSLIMIT := 1", X "MAXPROCESS := 1", X ".IMPORT .IGNORE: ROOTDIR", X ".MAKEFILES : makefile.mk makefile", X ".SOURCE : .NULL", X#include "startup.h" X 0 }; X Xchar **Rule_tab = _rules; /* for sundry reasons in Get_environment() */ X SHAR_EOF chmod 0440 msdos/ruletab.c || echo "restore of msdos/ruletab.c fails" echo "x - extracting msdos/rmprq.c (Text)" sed 's/^X//' << 'SHAR_EOF' > msdos/rmprq.c && X/* RCS -- $Header: /u2/dvadura/src/generic/dmake/src/msdos/RCS/rmprq.c,v 1.1 90/10/06 12:05:26 dvadura Exp $ X-- SYNOPSIS -- remove prerequisites code. X-- X-- DESCRIPTION X-- This code is different for DOS and for UNIX and parallel make X-- architectures since the parallel case requires the rm's to be X-- run in parallel, whereas DOS guarantees to run them sequentially. X-- X-- AUTHOR X-- Dennis Vadura, dvadura@watdragon.uwaterloo.ca X-- CS DEPT, University of Waterloo, Waterloo, Ont., Canada X-- X-- COPYRIGHT X-- Copyright (c) 1990 by Dennis Vadura. All rights reserved. X-- X-- This program is free software; you can redistribute it and/or X-- modify it under the terms of the GNU General Public License X-- (version 1), as published by the Free Software Foundation, and X-- found in the file 'LICENSE' included with this distribution. X-- X-- This program is distributed in the hope that it will be useful, X-- but WITHOUT ANY WARRANTY; without even the implied warrant of X-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the X-- GNU General Public License for more details. X-- X-- You should have received a copy of the GNU General Public License X-- along with this program; if not, write to the Free Software X-- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. X-- X-- LOG X-- $Log: rmprq.c,v $ X * Revision 1.1 90/10/06 12:05:26 dvadura X * dmake Release, Version 3.6 X * X*/ X X#include "extern.h" X#include "alloc.h" X Xvoid XRemove_prq( tcp ) XCELLPTR tcp; X{ X tcp->ce_flag &= ~(F_MADE|F_VISITED); X tcp->CE_HOW->hw_flag &= ~(F_MADE|F_VISITED); X tcp->ce_time = 0L; X X Make( tcp, tcp->CE_HOW, NIL(CELL) ); X} SHAR_EOF chmod 0440 msdos/rmprq.c || echo "restore of msdos/rmprq.c fails" echo mkdir - msdos/mscdos mkdir msdos/mscdos echo "x - extracting msdos/mscdos/tempnam.c (Text)" sed 's/^X//' << 'SHAR_EOF' > msdos/mscdos/tempnam.c && X/*LINTLIBRARY*/ X#include <stdio.h> X#include <string.h> X#include <stdlib.h> X#include <time.h> X X#if defined(max) X# undef max X#endif X#define max(A,B) (((A)<(B))?(B):(A)) X Xextern char *mktemp(); Xextern int access(); Xint _access(); X X/* MSC stdio.h defines P_tmpdir, so let's undo it here */ X/* Under DOS leave the default tmpdir pointing here! */ X#ifdef P_tmpdir X#undef P_tmpdir X#endif Xstatic char *P_tmpdir = ""; X Xchar * Xtempnam(dir, prefix) Xchar *dir; /* use this directory please (if non-NULL) */ Xchar *prefix; /* use this (if non-NULL) as filename prefix */ X{ X static int count = 0; X register char *p, *q, *tmpdir; X int tl=0, dl=0, pl; X time_t ctm; X char buf[30]; X X pl = strlen(P_tmpdir); X X if( (tmpdir = getenv("TMPDIR")) != NULL ) tl = strlen(tmpdir); X if( dir != NULL ) dl = strlen(dir); X X if( (p = malloc((unsigned)(max(max(dl,tl),pl)+12))) == NULL ) X return(NULL); X X *p = '\0'; X X if( (tl == 0) || (_access( strcpy(p, tmpdir), 0) != 0) ) X if( (dl == 0) || (_access( strcpy(p, dir), 0) != 0) ) X if( _access( strcpy(p, P_tmpdir), 0) != 0 ) X if( !prefix ) X prefix = "tp"; X X if(prefix) X { X *(p+strlen(p)+2) = '\0'; X (void)strncat(p, prefix, 2); X } X X sprintf( buf, "%ld", (long) time((time_t *)0) ); X (void)strcat(p, buf+strlen(buf)-6 ); X sprintf( buf, "%03d", count++ ); X q=p+strlen(p)-6; X *q++ = buf[0]; X *q++ = buf[1]; X *q++ = buf[2]; X X if( (q = strrchr(p,'.')) != NULL ) *q = '\0'; X X return(p); X} X X X X_access( name, flag ) Xchar *name; Xint flag; X{ X char *p; X int r; X X if( name == NULL || !*name ) return(1); /* NULL dir means current dir */ X r = access( name, flag ); X p = name+strlen(name)-1; X if(*p != '/' && *p != '\\') strcat( p, "/" ); X X return( r ); X} SHAR_EOF chmod 0440 msdos/mscdos/tempnam.c || echo "restore of msdos/mscdos/tempnam.c fails" echo "x - extracting msdos/mscdos/startup.mk (Text)" sed 's/^X//' << 'SHAR_EOF' > msdos/mscdos/startup.mk && X# MSDOS DMAKE startup file. Customize to suit your needs. X# Assumes MKS toolkit for the tool commands, and Microsoft C. Change as req'd. X# See the documentation for a description of internally defined macros. X# X# Disable warnings for macros redefined here that were given X# on the command line. X__.SILENT := $(.SILENT) X.SILENT := yes X X# Configuration parameters for DMAKE startup.mk file X# Set these to NON-NULL if you wish to turn the parameter on. X_HAVE_RCS := yes # yes => RCS is installed. X_HAVE_SCCS := # yes => SCCS is installed. X X# Applicable suffix definitions XA := .lib # Libraries XE := .exe # Executables XF := .for # Fortran XO := .obj # Objects XP := .pas # Pascal XS := .asm # Assembler sources XV := # RCS suffix X X# See if these are defined XTMPDIR := $(ROOTDIR)/tmp X.IMPORT .IGNORE : TMPDIR SHELL COMSPEC X X# Recipe execution configurations X# First set SHELL, If it is not defined, use COMSPEC, otherwise X# it is assumed to be MKS Korn SHELL. X.IF $(SHELL) == $(NULL) X.IF $(COMSPEC) == $(NULL) X SHELL := $(ROOTDIR)/bin/sh$E X.ELSE X SHELL := $(COMSPEC) X.END X.END XGROUPSHELL := $(SHELL) X X# Now set remaining arguments depending on which SHELL we X# are going to use. COMSPEC (assumed to be command.com) or X# MKS Korn Shell. X.IF $(SHELL)==$(COMSPEC) X SHELLFLAGS := $(SWITCHAR)c X GROUPFLAGS := $(SHELLFLAGS) X SHELLMETAS := *"?<> X GROUPSUFFIX := .bat X DIRSEPSTR := \\ X DIVFILE = $(TMPFILE:s,/,\) X.ELSE X SHELLFLAGS := -c X GROUPFLAGS := X SHELLMETAS := *"?<>|()&][$$\#`' X GROUPSUFFIX := .ksh X .MKSARGS := yes X DIVFILE = $(TMPFILE:s,/,${DIVSEP_shell_${DIVSHELL}}) X DIVSEP_shell_yes := \\\ X DIVSEP_shell_no := \\ X.END X X# Standard C-language command names and flags X CC := cl # C-compiler and flags X CFLAGS += X X AS := masm # Assembler and flags X ASFLAGS += X X LD = link # Loader and flags X LDFLAGS += X LDLIBS = X X# Definition of $(MAKE) macro for recursive makes. X MAKE = $(MAKECMD) $(MFLAGS) X X# Language and Parser generation Tools and their flags X YACC := yacc # standard yacc X YFLAGS += X YTAB := ytab # yacc output files name stem. X X LEX := lex # standard lex X LFLAGS += X LEXYY := lex_yy # lex output file X X# Other Compilers, Tools and their flags X PC := any_pc # pascal compiler X RC := anyf77 # ratfor compiler X FC := anyf77 # fortran compiler X X CO := co # check out for RCS X COFLAGS += -q X X AR := ar # archiver X ARFLAGS+= ruv X X RM := rm # remove a file command X RMFLAGS += X X# Implicit generation rules for making inferences. X# We don't provide .yr or .ye rules here. They're obsolete. X# Rules for making *$O X %$O : %.c ; $(CC) $(CFLAGS) -c $< X %$O : %$P ; $(PC) $(PFLAGS) -c $< X %$O : %$S ; $(AS) $(ASFLAGS) $(<:s,/,\); X %$O : %.cl ; class -c $< X %$O : %.e %.r %.F %$F ; $(FC) $(RFLAGS) $(EFLAGS) $(FFLAGS) -c $< X X# Executables X %$E : %$O ; $(CC) $(LDFLAGS) -o$@ $< $(LDLIBS) X X# lex and yacc rules X %.c : %.y ; $(YACC) $(YFLAGS) $<; mv $(YTAB).c $@ X %.c : %.l ; $(LEX) $(LFLAGS) $<; mv $(LEXYY).c $@ X X# RCS support X.IF $(_HAVE_RCS) X % : $$(@:d)RCS$$(DIRSEPSTR)$$(@:f)$V;- $(CO) $(COFLAGS) $@ X .NOINFER : $$(@:d)RCS$$(DIRSEPSTR)$$(@:f)$V X.END X X# SCCS support X.IF $(_HAVE_SCCS) X % : s.% ; get $@ X .NOINFER : s.% X.END X X# Recipe to make archive files. X%$A : X[ X $(AR) $(ARFLAGS) $@ $? X $(RM) $(RMFLAGS) $? X] X X# DMAKE uses this recipe to remove intermediate targets X.REMOVE :; $(RM) -f $< X X# AUGMAKE extensions for SYSV compatibility X@B = $(@:b) X@D = $(@:d) X@F = $(@:f) X*B = $(*:b) X*D = $(*:d) X*F = $(*:f) X<B = $(<:b) X<D = $(<:d) X<F = $(<:f) X?B = $(?:b) X?F = $(?:f) X?D = $(?:d) X X# Turn warnings back to previous setting. X.SILENT := $(__.SILENT) X X# Local init file if any, gets parsed before user makefile X.INCLUDE .IGNORE: "_startup.mk" SHAR_EOF chmod 0640 msdos/mscdos/startup.mk || echo "restore of msdos/mscdos/startup.mk fails" echo "x - extracting msdos/mscdos/objswp.rsp (Text)" sed 's/^X//' << 'SHAR_EOF' > msdos/mscdos/objswp.rsp && Xobjects\exec.obj+ Xobjects\infer.obj+ Xobjects\make.obj+ Xobjects\stat.obj+ Xobjects\expand.obj+ Xobjects\string.obj+ Xobjects\hash.obj+ Xobjects\dag.obj+ Xobjects\dmake.obj+ Xobjects\path.obj+ Xobjects\imacs.obj+ Xobjects\sysintf.obj+ Xobjects\parse.obj+ Xobjects\getinp.obj+ Xobjects\quit.obj+ Xobjects\basename.obj+ Xobjects\dump.obj+ Xobjects\macparse.obj+ Xobjects\rulparse.obj+ Xobjects\percent.obj+ Xobjects\function.obj+ Xobjects\ruletab.obj+ Xobjects\dirbrk.obj+ Xobjects\runargv.obj+ Xobjects\arlib.obj+ Xobjects\_chdir.obj+ Xobjects\switchar.obj+ Xobjects\rmprq.obj+ Xobjects\find.obj+ Xobjects\spawn.obj+ Xobjects\tempnam.obj SHAR_EOF chmod 0640 msdos/mscdos/objswp.rsp || echo "restore of msdos/mscdos/objswp.rsp fails" echo "x - extracting msdos/mscdos/obj60swp.rsp (Text)" sed 's/^X//' << 'SHAR_EOF' > msdos/mscdos/obj60swp.rsp && Xobjects\exec.obj+ Xobjects\infer.obj+ Xobjects\make.obj+ Xobjects\stat.obj+ Xobjects\expand.obj+ Xobjects\string.obj+ Xobjects\hash.obj+ Xobjects\dag.obj+ Xobjects\dmake.obj+ Xobjects\path.obj+ Xobjects\imacs.obj+ Xobjects\sysintf.obj+ Xobjects\parse.obj+ Xobjects\getinp.obj+ Xobjects\quit.obj+ Xobjects\basename.obj+ Xobjects\dump.obj+ Xobjects\macparse.obj+ Xobjects\rulparse.obj+ Xobjects\percent.obj+ Xobjects\function.obj+ Xobjects\ruletab.obj+ Xobjects\dirbrk.obj+ Xobjects\runargv.obj+ Xobjects\arlib.obj+ Xobjects\_chdir.obj+ Xobjects\switchar.obj+ Xobjects\rmprq.obj+ Xobjects\find.obj+ Xobjects\spawn.obj+ Xobjects\tempnam.obj SHAR_EOF chmod 0640 msdos/mscdos/obj60swp.rsp || echo "restore of msdos/mscdos/obj60swp.rsp fails" echo "x - extracting msdos/mscdos/obj60.rsp (Text)" sed 's/^X//' << 'SHAR_EOF' > msdos/mscdos/obj60.rsp && Xobjects\infer.obj+ Xobjects\make.obj+ Xobjects\stat.obj+ Xobjects\expand.obj+ Xobjects\string.obj+ Xobjects\hash.obj+ Xobjects\dag.obj+ Xobjects\dmake.obj+ Xobjects\path.obj+ Xobjects\imacs.obj+ Xobjects\sysintf.obj+ Xobjects\parse.obj+ Xobjects\getinp.obj+ Xobjects\quit.obj+ Xobjects\basename.obj+ Xobjects\dump.obj+ Xobjects\macparse.obj+ Xobjects\rulparse.obj+ Xobjects\percent.obj+ Xobjects\function.obj+ Xobjects\ruletab.obj+ Xobjects\dirbrk.obj+ Xobjects\runargv.obj+ Xobjects\arlib.obj+ Xobjects\_chdir.obj+ Xobjects\switchar.obj+ Xobjects\rmprq.obj+ Xobjects\tempnam.obj SHAR_EOF chmod 0640 msdos/mscdos/obj60.rsp || echo "restore of msdos/mscdos/obj60.rsp fails" echo "x - extracting msdos/mscdos/obj.rsp (Text)" sed 's/^X//' << 'SHAR_EOF' > msdos/mscdos/obj.rsp && Xobjects\infer.obj+ Xobjects\make.obj+ Xobjects\stat.obj+ Xobjects\expand.obj+ Xobjects\string.obj+ Xobjects\hash.obj+ Xobjects\dag.obj+ Xobjects\dmake.obj+ Xobjects\path.obj+ Xobjects\imacs.obj+ Xobjects\sysintf.obj+ Xobjects\parse.obj+ Xobjects\getinp.obj+ Xobjects\quit.obj+ Xobjects\basename.obj+ Xobjects\dump.obj+ Xobjects\macparse.obj+ Xobjects\rulparse.obj+ Xobjects\percent.obj+ Xobjects\function.obj+ Xobjects\ruletab.obj+ Xobjects\dirbrk.obj+ Xobjects\runargv.obj+ Xobjects\arlib.obj+ Xobjects\_chdir.obj+ Xobjects\switchar.obj+ Xobjects\rmprq.obj+ Xobjects\tempnam.obj SHAR_EOF chmod 0640 msdos/mscdos/obj.rsp || echo "restore of msdos/mscdos/obj.rsp fails" echo "x - extracting msdos/mscdos/mkswp.bat (Text)" sed 's/^X//' << 'SHAR_EOF' > msdos/mscdos/mkswp.bat && Xmkdir objects Xmasm -t -mx -Dmcompact msdos\exec.asm; Xmv exec.obj objects Xcl -c -DHELP -I. -Icommon -Imsdos -Imsdos\mscdos -D__STDC__=1 -DM_I86=1 -mc -Zp infer.c Xmv infer.obj objects Xcl -c -DHELP -I. -Icommon -Imsdos -Imsdos\mscdos -D__STDC__=1 -DM_I86=1 -mc -Zp make.c Xmv make.obj objects Xcl -c -DHELP -I. -Icommon -Imsdos -Imsdos\mscdos -D__STDC__=1 -DM_I86=1 -mc -Zp stat.c Xmv stat.obj objects Xcl -c -DHELP -I. -Icommon -Imsdos -Imsdos\mscdos -D__STDC__=1 -DM_I86=1 -mc -Zp expand.c Xmv expand.obj objects Xcl -c -DHELP -I. -Icommon -Imsdos -Imsdos\mscdos -D__STDC__=1 -DM_I86=1 -mc -Zp string.c Xmv string.obj objects Xcl -c -DHELP -I. -Icommon -Imsdos -Imsdos\mscdos -D__STDC__=1 -DM_I86=1 -mc -Zp hash.c Xmv hash.obj objects Xcl -c -DHELP -I. -Icommon -Imsdos -Imsdos\mscdos -D__STDC__=1 -DM_I86=1 -mc -Zp dag.c Xmv dag.obj objects Xcl -c -DHELP -I. -Icommon -Imsdos -Imsdos\mscdos -D__STDC__=1 -DM_I86=1 -mc -Zp dmake.c Xmv dmake.obj objects Xcl -c -DHELP -I. -Icommon -Imsdos -Imsdos\mscdos -D__STDC__=1 -DM_I86=1 -mc -Zp path.c Xmv path.obj objects Xcl -c -DHELP -I. -Icommon -Imsdos -Imsdos\mscdos -D__STDC__=1 -DM_I86=1 -mc -Zp imacs.c Xmv imacs.obj objects Xcl -c -DHELP -I. -Icommon -Imsdos -Imsdos\mscdos -D__STDC__=1 -DM_I86=1 -mc -Zp sysintf.c Xmv sysintf.obj objects Xcl -c -DHELP -I. -Icommon -Imsdos -Imsdos\mscdos -D__STDC__=1 -DM_I86=1 -mc -Zp parse.c Xmv parse.obj objects Xcl -c -DHELP -I. -Icommon -Imsdos -Imsdos\mscdos -D__STDC__=1 -DM_I86=1 -mc -Zp getinp.c SHAR_EOF echo "End of part 8" echo "File msdos/mscdos/mkswp.bat is continued in part 9" echo "9" > s2_seq_.tmp exit 0