home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume15 / dmake-3.6 / part01 < prev    next >
Text File  |  1990-10-14  |  40KB  |  1,481 lines

  1. Newsgroups: comp.sources.misc
  2. X-UNIX-From: dvadura@watdragon.waterloo.edu
  3. subject: v15i053: dmake version 3.6 (part 01/25)
  4. from: Dennis Vadura <dvadura@watdragon.waterloo.edu>
  5. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  6.  
  7. Posting-number: Volume 15, Issue 53
  8. Submitted-by: Dennis Vadura <dvadura@watdragon.waterloo.edu>
  9. Archive-name: dmake-3.6/part01
  10.  
  11. #!/bin/sh
  12. # shar:    Shell Archiver  (v1.22)
  13. #
  14. # This is part 1 of a multipart archive                                    
  15. # do not concatenate these parts, unpack them in order with /bin/sh        
  16. #
  17. #    Run the following text with /bin/sh to create:
  18. #      vextern.h
  19. #      version.h
  20. #      unix
  21. #      unix/sysvr3
  22. #      unix/sysvr3/time.h
  23. #      unix/sysvr3/stdlib.h
  24. #      unix/sysvr3/stdarg.h
  25. #      unix/sysvr3/startup.mk
  26. #      unix/sysvr3/runargv.c
  27. #      unix/sysvr3/make.sh
  28. #      unix/sysvr3/config.mk
  29. #      unix/sysvr3/config.h
  30. #      unix/sysvr1
  31. #      unix/sysvr1/vfprintf.c
  32. #      unix/sysvr1/time.h
  33. #      unix/sysvr1/stdlib.h
  34. #      unix/sysvr1/stdarg.h
  35. #      unix/sysvr1/startup.mk
  36. #      unix/sysvr1/runargv.c
  37. #      unix/sysvr1/putenv.c
  38. #      unix/sysvr1/make.sh
  39. #      unix/sysvr1/config.mk
  40. #      unix/sysvr1/config.h
  41. #      unix/sysintf.h
  42. #      unix/startup.h
  43. #      unix/ruletab.c
  44. #      unix/rmprq.c
  45. #      unix/explode.c
  46. #      unix/dirbrk.c
  47. #      unix/config.mk
  48. #      unix/bsd43
  49. #      unix/bsd43/vf
  50. #      unix/bsd43/vf/vfprintf.c
  51. #      unix/bsd43/vf/startup.mk
  52. #      unix/bsd43/vf/memcpy.c
  53. #      unix/bsd43/vf/make.sh
  54. #      unix/bsd43/vf/ctype.h
  55. #      unix/bsd43/vf/config.mk
  56. #      unix/bsd43/uw
  57. #      unix/bsd43/uw/startup.mk
  58. #      unix/bsd43/uw/make.sh
  59. #      unix/bsd43/uw/config.mk
  60. #      unix/bsd43/utime.c
  61. #      unix/bsd43/tempnam.c
  62. #      unix/bsd43/string.h
  63. #      unix/bsd43/stdlib.h
  64. #      unix/bsd43/stdarg.h
  65. #      unix/bsd43/startup.mk
  66. #      unix/bsd43/setvbuf.c
  67. #      unix/bsd43/runargv.c
  68. #      unix/bsd43/putenv.c
  69. #      unix/bsd43/make.sh
  70. #      unix/bsd43/config.mk
  71. #      unix/bsd43/config.h
  72. #      unix/arlib.c
  73. #      unix/386ix
  74. #      unix/386ix/time.h
  75. #      unix/386ix/stdlib.h
  76. #      unix/386ix/stdarg.h
  77. #      unix/386ix/startup.mk
  78. #      unix/386ix/runargv.c
  79. #      unix/386ix/make.sh
  80. #      unix/386ix/config.mk
  81. #      unix/386ix/config.h
  82. #      unix/386ix/ar.h
  83. #      sysintf.c
  84. #      struct.h
  85. #      string.c
  86. #      stat.c
  87. #      rulparse.c
  88. #      readme
  89. #      readme/release
  90. #      readme/os2
  91. #      readme/msdos
  92. #      readme/cover
  93. #      quit.c
  94. #      percent.c
  95. #      path.c
  96. #      patchlvl.h
  97. #      parse.c
  98. #      msdos
  99. #      msdos/tccdos
  100. #      msdos/tccdos/utime.c
  101. #      msdos/tccdos/tempnam.c
  102. #      msdos/tccdos/startup.mk
  103. #      msdos/tccdos/objswp.rsp
  104. #      msdos/tccdos/obj.rsp
  105. #      msdos/tccdos/mkswp.bat
  106. #      msdos/tccdos/mk.bat
  107. #      msdos/tccdos/libswp.rsp
  108. #      msdos/tccdos/lib.rsp
  109. #      msdos/tccdos/config.mk
  110. #      msdos/tccdos/config.h
  111. #      msdos/sysintf.h
  112. #      msdos/switchar.c
  113. #      msdos/stdarg.h
  114. #      msdos/startup.h
  115. #      msdos/spawn.c
  116. #      msdos/runargv.c
  117. #      msdos/ruletab.c
  118. #      msdos/rmprq.c
  119. #      msdos/mscdos
  120. #      msdos/mscdos/tempnam.c
  121. #      msdos/mscdos/startup.mk
  122. #      msdos/mscdos/objswp.rsp
  123. #      msdos/mscdos/obj60swp.rsp
  124. #      msdos/mscdos/obj60.rsp
  125. #      msdos/mscdos/obj.rsp
  126. #      msdos/mscdos/mkswp.bat
  127. #      msdos/mscdos/mk60swp.bat
  128. #      msdos/mscdos/mk60.bat
  129. #      msdos/mscdos/mk.bat
  130. #      msdos/mscdos/libswp.rsp
  131. #      msdos/mscdos/lib60swp.rsp
  132. #      msdos/mscdos/lib60.rsp
  133. #      msdos/mscdos/lib.rsp
  134. #      msdos/mscdos/config.mk
  135. #      msdos/mscdos/config.h
  136. #      msdos/find.c
  137. #      msdos/exec.h
  138. #      msdos/exec.asm
  139. #      msdos/dirlib.h
  140. #      msdos/dirbrk.c
  141. #      msdos/config.mk
  142. #      msdos/arlib.c
  143. #      msdos/_chdir.c
  144. #      man
  145. #      man/dmake.tf
  146. #      man/dmake.p
  147. #      man/dmake.nc
  148. #      makefile
  149. #      makefile.mk
  150. #      make.c
  151. #      make.bat
  152. #      macparse.c
  153. #      infer.c
  154. #      imacs.c
  155. #      hash.c
  156. #      getinp.c
  157. #      function.c
  158. #      extern.h
  159. #      expand.c
  160. #      dump.c
  161. #      dmake.h
  162. #      dmake.c
  163. #      dag.c
  164. #      common
  165. #      common/stdmacs.h
  166. #      common/print.mk
  167. #      common/malloc.c
  168. #      common/itypes.h
  169. #      common/dbug.h
  170. #      common/dbug.c
  171. #      common/db.h
  172. #      common/alloc.h
  173. #      basename.c
  174. #      _updctl
  175. #      _install
  176. #      LICENSE
  177. #
  178. if test -r s2_seq_.tmp
  179. then echo "Must unpack archives in sequence!"
  180.      next=`cat s2_seq_.tmp`; echo "Please unpack part $next next"
  181.      exit 1; fi
  182. echo "x - extracting vextern.h (Text)"
  183. sed 's/^X//' << 'SHAR_EOF' > vextern.h &&
  184. X/* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/RCS/vextern.h,v 1.1 90/10/06 12:04:31 dvadura Exp $
  185. X-- SYNOPSIS -- global variable declarations.
  186. X-- 
  187. X-- DESCRIPTION
  188. X--     Leave _DEFINE_GLOBALS_ undefined and the following declarations
  189. X--    will be defined as global variables, otherwise you get the
  190. X--    external declarations to the same global variables.
  191. X--
  192. X-- AUTHOR
  193. X--      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  194. X--      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  195. X--
  196. X-- COPYRIGHT
  197. X--      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
  198. X-- 
  199. X--      This program is free software; you can redistribute it and/or
  200. X--      modify it under the terms of the GNU General Public License
  201. X--      (version 1), as published by the Free Software Foundation, and
  202. X--      found in the file 'LICENSE' included with this distribution.
  203. X-- 
  204. X--      This program is distributed in the hope that it will be useful,
  205. X--      but WITHOUT ANY WARRANTY; without even the implied warrant of
  206. X--      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  207. X--      GNU General Public License for more details.
  208. X-- 
  209. X--      You should have received a copy of the GNU General Public License
  210. X--      along with this program;  if not, write to the Free Software
  211. X--      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  212. X--
  213. X-- LOG
  214. X--     $Log:    vextern.h,v $
  215. X * Revision 1.1  90/10/06  12:04:31  dvadura
  216. X * dmake Release, Version 3.6
  217. X * 
  218. X*/
  219. X#include <stdio.h>
  220. X#include "stdmacs.h"
  221. X#include "struct.h"
  222. X#include "dmake.h"
  223. X
  224. X/* These two are defined in dir/ruletab.c and dir/dirbrk.c, and are always
  225. X * imported as externals by the other code.  Their defining modules do not
  226. X * #include this file. */
  227. Xextern    char*    DirBrkStr;    /* pointer to value of macro DIRBRKSTR    */
  228. Xextern    char**    Rule_tab;    /* Builtin rules */
  229. X
  230. X#ifndef _DEFINE_GLOBALS_
  231. X#define EXTERN    extern
  232. X#else
  233. X#define EXTERN
  234. X#endif
  235. X
  236. XEXTERN    int    Line_number;    /* Current line number in make file parse */
  237. XEXTERN    t_attr    Glob_attr;    /* Global attrs to control global ops     */
  238. XEXTERN    char*    Prep;        /* Value of macro PREP              */
  239. XEXTERN    char*    Makedir;    /* pointer to macro value for MAKEDIR     */
  240. XEXTERN    CELL     Start_dir;    /* cell for   macro value for .SETDIR      */
  241. XEXTERN    char*    Shell;        /* pointer to macro value for SHELL       */
  242. XEXTERN    char*    Shell_flags;    /* pointer to macro value for SHELLFLAGS  */
  243. XEXTERN    char*    GShell;        /* pointer to macro value for GROUPSHELL  */
  244. XEXTERN    char*    GShell_flags;    /* pointer to macro value for GROUPFLAGS  */
  245. XEXTERN    char*    Shell_metas;    /* pointer to macro value for SHELLMETAS  */
  246. XEXTERN    char*    Grp_suff;    /* pointer to macro value for GROUPSUFFIX */
  247. XEXTERN  char*   DirSepStr;    /* pointer to macro value for DIRSEPSTR   */
  248. XEXTERN    char*    Pname;        /* dmake process invoke name              */
  249. XEXTERN    char*    Pwd;        /* current working dir, value of PWD      */
  250. XEXTERN    char*    Augmake;    /* -A */
  251. XEXTERN    int    Target;        /* TRUE if target found in makefile       */
  252. XEXTERN    int    If_expand;    /* TRUE if calling Expand from getinp.c   */
  253. XEXTERN  int    If_multi;    /* M_MULTI for expand of single MULTI macs*/
  254. XEXTERN    int    Readenv;    /* TRUE if defining macro from environment*/
  255. XEXTERN    int    Makemkf;    /* TRUE if making makefile(s)          */
  256. XEXTERN    int    Nest_level;    /* Nesting level for .IF .ELSE .END ...   */
  257. XEXTERN    int    Def_targets;    /* TRUE if defining targets          */
  258. X
  259. XEXTERN    LINKPTR Fringe_hd;    /* Pointer to head of the fringe list      */
  260. XEXTERN    LINKPTR Fringe_tl;    /* Pointer to tail of the fringe list      */
  261. X
  262. XEXTERN  CELLPTR Recipe_cell;     /* Current CELL during expansion of recipe*/
  263. XEXTERN  HOWPTR  Recipe_how;     /* Current HOW during expansion of recipe */
  264. XEXTERN  HOWPTR  Current_target; /* HOW cell of current target being made  */
  265. XEXTERN  HOW     Root_how;    /* HOW CELL for root $(mktmp ..) fns      */
  266. XEXTERN  int    Wait_for_completion;
  267. XEXTERN  int    Doing_bang;
  268. XEXTERN  int    Packed_shell;    /* TRUE if packed args to use a shell      */
  269. XEXTERN  int    Swap_on_exec;    /* TRUE if going to swap on exec call     */
  270. X
  271. X/* Command line option flags are defined here.  They correspond one-for one
  272. X * with the flags defined in dmake.c */
  273. XEXTERN    int    Continue;    /* -k */
  274. XEXTERN    int    Get_env;    /* -e or -E */
  275. XEXTERN    int    Force;        /* -u */
  276. XEXTERN    int    Listing;    /* -p */
  277. XEXTERN    int    Rules;        /* -r */
  278. XEXTERN    int    Trace;        /* -n */
  279. XEXTERN    int    Touch;        /* -t */
  280. XEXTERN    int    Check;        /* -q */
  281. XEXTERN    int    Verbose;    /* -v */
  282. XEXTERN    int    Microsoft;    /* -M */
  283. XEXTERN    int    Transitive;    /* -T */
  284. X
  285. XEXTERN    HASHPTR    Macs[HASH_TABLE_SIZE];    /* hash table for macro defs    */
  286. XEXTERN    HASHPTR    Defs[HASH_TABLE_SIZE];    /* hash table for other defs    */
  287. X
  288. XEXTERN    char    *Buffer;        /* a general purpose buffer     */
  289. XEXTERN  int    Buffer_size;
  290. XEXTERN  int    Max_proclmt;        /* limit of max # of conc procs */
  291. XEXTERN    int    Max_proc;        /* max # of conc procs        */
  292. SHAR_EOF
  293. chmod 0440 vextern.h || echo "restore of vextern.h fails"
  294. echo "x - extracting version.h (Text)"
  295. sed 's/^X//' << 'SHAR_EOF' > version.h &&
  296. X/* dmake version number.  */
  297. X
  298. X#define VERSION "3.60"
  299. SHAR_EOF
  300. chmod 0440 version.h || echo "restore of version.h fails"
  301. echo mkdir - unix
  302. mkdir unix
  303. echo mkdir - unix/sysvr3
  304. mkdir unix/sysvr3
  305. echo "x - extracting unix/sysvr3/time.h (Text)"
  306. sed 's/^X//' << 'SHAR_EOF' > unix/sysvr3/time.h &&
  307. X/*
  308. X** Berkeley get this wrong!
  309. X*/
  310. X#ifndef    TIME_h
  311. X#define    TIME_h
  312. X
  313. Xtypedef    long    time_t;    /* this is the thing we use */
  314. X
  315. X#endif    TIME_h
  316. X
  317. SHAR_EOF
  318. chmod 0440 unix/sysvr3/time.h || echo "restore of unix/sysvr3/time.h fails"
  319. echo "x - extracting unix/sysvr3/stdlib.h (Text)"
  320. sed 's/^X//' << 'SHAR_EOF' > unix/sysvr3/stdlib.h &&
  321. X#ifndef _STDLIB_INCLUDED_
  322. X#define _STDLIB_INCLUDED_
  323. X
  324. Xextern /*GOTO*/ _exit();
  325. Xextern /*GOTO*/ exit();
  326. Xextern /*GOTO*/ abort();
  327. Xextern int system();
  328. Xextern char *getenv();
  329. Xextern char *calloc();
  330. Xextern char *malloc();
  331. Xextern char *realloc();
  332. Xextern free();
  333. Xextern int errno;
  334. X
  335. X#ifndef EIO
  336. X#    include <errno.h>
  337. X#endif
  338. X
  339. X#endif /* _STDLIB_INCLUDED_ */
  340. SHAR_EOF
  341. chmod 0440 unix/sysvr3/stdlib.h || echo "restore of unix/sysvr3/stdlib.h fails"
  342. echo "x - extracting unix/sysvr3/stdarg.h (Text)"
  343. sed 's/^X//' << 'SHAR_EOF' > unix/sysvr3/stdarg.h &&
  344. X/*
  345. X * stdarg.h
  346. X *
  347. X * defines ANSI style macros for accessing arguments of a function which takes
  348. X * a variable number of arguments
  349. X *
  350. X */
  351. X
  352. X#if !defined(__STDARG)
  353. X#define __STDARG
  354. X
  355. Xtypedef char *va_list;
  356. X
  357. X#define va_dcl int va_alist
  358. X#define va_start(ap,v)  ap = (va_list)&va_alist
  359. X#define va_arg(ap,t)    ((t*)(ap += sizeof(t)))[-1]
  360. X#define va_end(ap)      ap = NULL
  361. X#endif
  362. SHAR_EOF
  363. chmod 0440 unix/sysvr3/stdarg.h || echo "restore of unix/sysvr3/stdarg.h fails"
  364. echo "x - extracting unix/sysvr3/startup.mk (Text)"
  365. sed 's/^X//' << 'SHAR_EOF' > unix/sysvr3/startup.mk &&
  366. X# Generic UNIX DMAKE startup file.  Customize to suit your needs.
  367. X# Should work for both SYSV, and BSD 4.3
  368. X# See the documentation for a description of internally defined macros.
  369. X#
  370. X# Disable warnings for macros redefined here that were given
  371. X# on the command line.
  372. X__.SILENT := $(.SILENT)
  373. X.SILENT   := yes
  374. X
  375. X# Configuration parameters for DMAKE startup.mk file
  376. X# Set these to NON-NULL if you wish to turn the parameter on.
  377. X_HAVE_RCS    := yes        # yes => RCS  is installed.
  378. X_HAVE_SCCS    := yes        # yes => SCCS is installed.
  379. X
  380. X# Applicable suffix definitions
  381. XA := .a        # Libraries
  382. XE :=        # Executables
  383. XF := .f        # Fortran
  384. XO := .o        # Objects
  385. XP := .p        # Pascal
  386. XS := .s        # Assembler sources
  387. XV := ,v        # RCS suffix
  388. X
  389. X# Recipe execution configurations
  390. XSHELL        := /bin/sh
  391. XSHELLFLAGS    := -ce
  392. XGROUPSHELL    := $(SHELL)
  393. XGROUPFLAGS    := 
  394. XSHELLMETAS    := |();&<>?*][$$:\\#`'"
  395. XGROUPSUFFIX    :=
  396. XDIVFILE         = $(TMPFILE)
  397. X
  398. X# Standard C-language command names and flags
  399. X   CPP       := /lib/cpp        # C-preprocessor
  400. X   CC      := cc        # C-compiler and flags
  401. X   CFLAGS  +=
  402. X
  403. X   AS      := as        # Assembler and flags
  404. X   ASFLAGS += 
  405. X
  406. X   LD       = $(CC)        # Loader and flags
  407. X   LDFLAGS +=
  408. X   LDLIBS   =
  409. X
  410. X# Definition of $(MAKE) macro for recursive makes.
  411. X   MAKE = $(MAKECMD) $(MFLAGS)
  412. X
  413. X# Definition of Print command for this system.
  414. X   PRINT = lpr
  415. X
  416. X# Language and Parser generation Tools and their flags
  417. X   YACC      := yacc        # standard yacc
  418. X   YFLAGS +=
  419. X   YTAB      := y.tab        # yacc output files name stem.
  420. X
  421. X   LEX      := lex        # standard lex
  422. X   LFLAGS +=
  423. X   LEXYY  := lex.yy        # lex output file
  424. X
  425. X# Other Compilers, Tools and their flags
  426. X   PC    := pc            # pascal compiler
  427. X   RC    := f77            # ratfor compiler
  428. X   FC    := f77            # fortran compiler
  429. X
  430. X   CO       := co        # check out for RCS
  431. X   COFLAGS += -q
  432. X
  433. X   AR     := ar            # archiver
  434. X   ARFLAGS+= ruv
  435. X
  436. X   RM       := /bin/rm        # remove a file command
  437. X   RMFLAGS +=
  438. X
  439. X# Implicit generation rules for making inferences.
  440. X# We don't provide .yr or .ye rules here.  They're obsolete.
  441. X# Rules for making *$O
  442. X   %$O : %.c ; $(CC) $(CFLAGS) -c $<
  443. X   %$O : %$P ; $(PC) $(PFLAGS) -c $<
  444. X   %$O : %$S ; $(AS) $(ASFLAGS) $<
  445. X   %$O : %.cl ; class -c $<
  446. X   %$O : %.e %.r %.F %$F
  447. X    $(FC) $(RFLAGS) $(EFLAGS) $(FFLAGS) -c $<
  448. X
  449. X# Executables
  450. X   %$E : %$O ; $(LD) $(LDFLAGS) -o $@ $< $(LDLIBES)
  451. X
  452. X# lex and yacc rules
  453. X   %.c : %.y ; $(YACC)  $(YFLAGS) $<; mv $(YTAB).c $@
  454. X   %.c : %.l ; $(LEX)   $(LFLAGS) $<; mv $(LEXYY).c $@
  455. X
  456. X# This rule tells how to make *.out from it's immediate list of prerequisites
  457. X# UNIX only.
  458. X   %.out :; $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)
  459. X
  460. X# RCS support
  461. X.IF $(_HAVE_RCS)
  462. X   % : %$V $$(@:d)RCS/$$(@:f)$V;- $(CO) $(COFLAGS) $@
  463. X   .NOINFER : %$V $$(@:d)RCS/$$(@:f)$V
  464. X.END
  465. X
  466. X# SCCS support
  467. X.IF $(_HAVE_SCCS)
  468. X   % : s.% ; get $@
  469. X   .NOINFER : s.%
  470. X.END
  471. X
  472. X# Recipe to make archive files.
  473. X%$A :
  474. X[
  475. X   $(AR) $(ARFLAGS) $@ $?
  476. X   $(RM) $(RMFLAGS) $?
  477. X   ranlib $@
  478. X]
  479. X
  480. X# DMAKE uses this recipe to remove intermediate targets
  481. X.REMOVE :; $(RM) -f $<
  482. X
  483. X# AUGMAKE extensions for SYSV compatibility
  484. X@B = $(@:b)
  485. X@D = $(@:d)
  486. X@F = $(@:f)
  487. X*B = $(*:b)
  488. X*D = $(*:d)
  489. X*F = $(*:f)
  490. X<B = $(<:b)
  491. X<D = $(<:d)
  492. X<F = $(<:f)
  493. X?B = $(?:b)
  494. X?F = $(?:f)
  495. X?D = $(?:d)
  496. X
  497. X# Turn warnings back to previous setting.
  498. X.SILENT := $(__.SILENT)
  499. X
  500. X# Local startup file if any
  501. X.INCLUDE .IGNORE: "_startup.mk"
  502. SHAR_EOF
  503. chmod 0640 unix/sysvr3/startup.mk || echo "restore of unix/sysvr3/startup.mk fails"
  504. echo "x - extracting unix/sysvr3/runargv.c (Text)"
  505. sed 's/^X//' << 'SHAR_EOF' > unix/sysvr3/runargv.c &&
  506. X/* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/unix/sysvr3/RCS/runargv.c,v 1.1 90/10/06 12:06:42 dvadura Exp $
  507. X-- SYNOPSIS -- invoke a sub process.
  508. X-- 
  509. X-- DESCRIPTION
  510. X--     Use the standard methods of executing a sub process.
  511. X--
  512. X-- AUTHOR
  513. X--      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  514. X--      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  515. X--
  516. X-- COPYRIGHT
  517. X--      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
  518. X-- 
  519. X--      This program is free software; you can redistribute it and/or
  520. X--      modify it under the terms of the GNU General Public License
  521. X--      (version 1), as published by the Free Software Foundation, and
  522. X--      found in the file 'LICENSE' included with this distribution.
  523. X-- 
  524. X--      This program is distributed in the hope that it will be useful,
  525. X--      but WITHOUT ANY WARRANTY; without even the implied warrant of
  526. X--      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  527. X--      GNU General Public License for more details.
  528. X-- 
  529. X--      You should have received a copy of the GNU General Public License
  530. X--      along with this program;  if not, write to the Free Software
  531. X--      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  532. X--
  533. X-- LOG
  534. X--     $Log:    runargv.c,v $
  535. X * Revision 1.1  90/10/06  12:06:42  dvadura
  536. X * dmake Release, Version 3.6
  537. X * 
  538. X*/
  539. X
  540. X#include <signal.h>
  541. X#include "extern.h"
  542. X#include "sysintf.h"
  543. X#include "alloc.h"
  544. X
  545. Xtypedef struct prp {
  546. X   char *prp_cmd;
  547. X   int   prp_group;
  548. X   int   prp_ignore;
  549. X   int   prp_last;
  550. X   int     prp_shell;
  551. X   struct prp *prp_next;
  552. X   char  *prp_dir;
  553. X} RCP, *RCPPTR;
  554. X
  555. Xtypedef struct pr {
  556. X   int        pr_valid;
  557. X   int        pr_pid;
  558. X   CELLPTR    pr_target;
  559. X   HOWPTR    pr_how;
  560. X   int        pr_ignore;
  561. X   int        pr_last;
  562. X   RCPPTR      pr_recipe;
  563. X   RCPPTR      pr_recipe_end;
  564. X} PR;
  565. X
  566. Xstatic PR  *_procs    = NIL(PR);
  567. Xstatic int  _proc_cnt = 0;
  568. Xstatic int  _abort_flg= FALSE;
  569. Xstatic int  _use_i    = -1;
  570. Xstatic int  _do_upd   = 0;
  571. X
  572. Xstatic  void    _add_child ANSI((int, CELLPTR, HOWPTR, int, int));
  573. Xstatic  void    _attach_cmd ANSI((char *, int, int, CELLPTR, HOWPTR, int, int));
  574. Xstatic  void    _finished_child ANSI((int, int));
  575. Xstatic  int     _running ANSI((CELLPTR, HOWPTR));
  576. X
  577. Xint
  578. Xrunargv(target, how, ignore, group, last, shell, cmd)
  579. XCELLPTR target;
  580. XHOWPTR  how;
  581. Xint     ignore;
  582. Xint    group;
  583. Xint    last;
  584. Xint     shell;
  585. Xchar    *cmd;
  586. X{
  587. X   extern  int  errno;
  588. X   extern  char *sys_errlist[];
  589. X   int          pid;
  590. X   char         **argv;
  591. X
  592. X   if( _running(target, how) /*&& Max_proc != 1*/ ) {
  593. X      /* The command will be executed when the previous recipe
  594. X       * line completes. */
  595. X      _attach_cmd( cmd, group, ignore, target, how, last, shell );
  596. X      return(1);
  597. X   }
  598. X
  599. X   while( _proc_cnt == Max_proc )
  600. X      if( Wait_for_child(FALSE, -1) == -1 )  Fatal( "Lost a child" );
  601. X
  602. X   argv = Pack_argv( group, shell, cmd );
  603. X
  604. X   switch( pid=fork() ){
  605. X      int   wid;
  606. X      int   status;
  607. X
  608. X   case -1: /* fork failed */
  609. X      Error("%s: %s", argv[0], sys_errlist[errno]);
  610. X      Handle_result(-1, ignore, _abort_flg, target);
  611. X      return(-1);
  612. X
  613. X   case 0:  /* child */
  614. X      execvp(argv[0], argv);
  615. X      Continue = TRUE;   /* survive error message */
  616. X      Error("%s: %s", argv[0], sys_errlist[errno]);
  617. X      kill(getpid(), SIGTERM);
  618. X      /*NOTREACHED*/
  619. X
  620. X   default: /* parent */
  621. X      _add_child(pid, target, how, ignore, last);
  622. X   }
  623. X
  624. X   return(1);
  625. X}
  626. X
  627. X
  628. Xint
  629. XWait_for_child( abort_flg, pid )
  630. Xint abort_flg;
  631. Xint pid;
  632. X{
  633. X   int wid;
  634. X   int status;
  635. X   int waitchild;
  636. X
  637. X   waitchild = (pid == -1)? FALSE : Wait_for_completion;
  638. X
  639. X   do {
  640. X      if( (wid = wait(&status)) == -1 ) return(-1);
  641. X
  642. X      _abort_flg = abort_flg;
  643. X      _finished_child(wid, status);
  644. X      _abort_flg = FALSE;
  645. X   }
  646. X   while( waitchild && pid != wid );
  647. X
  648. X   return(0);
  649. X}
  650. X
  651. X
  652. Xvoid
  653. XClean_up_processes()
  654. X{
  655. X   register int i;
  656. X
  657. X   if( _procs != NIL(PR) ) {
  658. X      for( i=0; i<Max_proc; i++ )
  659. X     if( _procs[i].pr_valid )
  660. X        kill(_procs[i].pr_pid, SIGTERM);
  661. X
  662. X      while( Wait_for_child(TRUE, -1) != -1 );
  663. X   }
  664. X}
  665. X
  666. X
  667. Xstatic void
  668. X_add_child( pid, target, how, ignore, last )
  669. Xint    pid;
  670. XCELLPTR target;
  671. XHOWPTR  how;
  672. Xint    ignore;
  673. Xint     last;
  674. X{
  675. X   register int i;
  676. X   register PR *pp;
  677. X
  678. X   if( _procs == NIL(PR) ) {
  679. X      TALLOC( _procs, Max_proc, PR );
  680. X   }
  681. X
  682. X   if( (i = _use_i) == -1 )
  683. X      for( i=0; i<Max_proc; i++ )
  684. X     if( !_procs[i].pr_valid )
  685. X        break;
  686. X
  687. X   pp = _procs+i;
  688. X
  689. X   pp->pr_valid  = 1;
  690. X   pp->pr_pid    = pid;
  691. X   pp->pr_target = target;
  692. X   pp->pr_how    = how;
  693. X   pp->pr_ignore = ignore;
  694. X   pp->pr_last   = last;
  695. X
  696. X   Current_target = NIL(HOW);
  697. X
  698. X   _proc_cnt++;
  699. X
  700. X   if( Wait_for_completion ) Wait_for_child( FALSE, pid );
  701. X}
  702. X
  703. X
  704. Xstatic void
  705. X_finished_child(pid, status)
  706. Xint    pid;
  707. Xint    status;
  708. X{
  709. X   register int i;
  710. X   register PR *pp;
  711. X
  712. X   for( i=0; i<Max_proc; i++ )
  713. X      if( _procs[i].pr_valid && _procs[i].pr_pid == pid )
  714. X     break;
  715. X
  716. X   _procs[i].pr_valid = 0;
  717. X   _proc_cnt--;
  718. X
  719. X   if( _procs[i].pr_recipe != NIL(RCP) && !_abort_flg ) {
  720. X      RCPPTR rp = _procs[i].pr_recipe;
  721. X      char   *dir;
  722. X
  723. X      Current_target = _procs[i].pr_how;
  724. X      Handle_result( status, _procs[i].pr_ignore, FALSE, _procs[i].pr_target );
  725. X      Current_target = NIL(HOW);
  726. X
  727. X      _procs[i].pr_recipe = rp->prp_next;
  728. X
  729. X      _use_i = i;
  730. X      dir = _strdup(Get_current_dir());
  731. X      Set_dir( rp->prp_dir );
  732. X      runargv( _procs[i].pr_target, _procs[i].pr_how, rp->prp_ignore,
  733. X                 rp->prp_group, rp->prp_last, rp->prp_shell, rp->prp_cmd );
  734. X      Set_dir(dir);
  735. X      FREE(dir);
  736. X      FREE(rp->prp_dir);
  737. X      _use_i = -1;
  738. X
  739. X      FREE( rp->prp_cmd );
  740. X      FREE( rp );
  741. X
  742. X      if( _proc_cnt == Max_proc ) Wait_for_child( FALSE, -1 );
  743. X   }
  744. X   else {
  745. X      Unlink_temp_files( _procs[i].pr_how );
  746. X      Handle_result(status,_procs[i].pr_ignore,_abort_flg,_procs[i].pr_target);
  747. X
  748. X      if( _procs[i].pr_last && !Doing_bang )
  749. X     Update_time_stamp( _procs[i].pr_target, _procs[i].pr_how );
  750. X   }
  751. X}
  752. X
  753. X
  754. Xstatic int
  755. X_running( cp, how )
  756. XCELLPTR cp;
  757. XHOWPTR  how;
  758. X{
  759. X   register int i;
  760. X
  761. X   if( !_procs ) return(FALSE);
  762. X
  763. X   for( i=0; i<Max_proc; i++ )
  764. X      if( _procs[i].pr_valid &&
  765. X      _procs[i].pr_how == how &&
  766. X      _procs[i].pr_target == cp  )
  767. X     break;
  768. X     
  769. X   return( i != Max_proc );
  770. X}
  771. X
  772. X
  773. Xstatic void
  774. X_attach_cmd( cmd, group, ignore, cp, how, last, shell )
  775. Xchar    *cmd;
  776. Xint    group;
  777. Xint     ignore;
  778. XCELLPTR cp;
  779. XHOWPTR  how;
  780. Xint     last;
  781. Xint     shell;
  782. X{
  783. X   register int i;
  784. X   RCPPTR rp;
  785. X
  786. X   for( i=0; i<Max_proc; i++ )
  787. X      if( _procs[i].pr_valid &&
  788. X      _procs[i].pr_how == how &&
  789. X      _procs[i].pr_target == cp  )
  790. X     break;
  791. X
  792. X   TALLOC( rp, 1, RCP );
  793. X   rp->prp_cmd   = _strdup(cmd);
  794. X   rp->prp_group = group;
  795. X   rp->prp_ignore= ignore;
  796. X   rp->prp_last  = last;
  797. X   rp->prp_shell = shell;
  798. X   rp->prp_dir   = _strdup(Get_current_dir());
  799. X
  800. X   if( _procs[i].pr_recipe == NIL(RCP) )
  801. X      _procs[i].pr_recipe = _procs[i].pr_recipe_end = rp;
  802. X   else {
  803. X      _procs[i].pr_recipe_end->prp_next = rp;
  804. X      _procs[i].pr_recipe_end = rp;
  805. X   }
  806. X}
  807. SHAR_EOF
  808. chmod 0440 unix/sysvr3/runargv.c || echo "restore of unix/sysvr3/runargv.c fails"
  809. echo "x - extracting unix/sysvr3/make.sh (Text)"
  810. sed 's/^X//' << 'SHAR_EOF' > unix/sysvr3/make.sh &&
  811. Xmkdir objects
  812. Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/sysvr3 -O infer.c
  813. Xmv infer.o objects
  814. Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/sysvr3 -O make.c
  815. Xmv make.o objects
  816. Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/sysvr3 -O stat.c
  817. Xmv stat.o objects
  818. Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/sysvr3 -O expand.c
  819. Xmv expand.o objects
  820. Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/sysvr3 -O string.c
  821. Xmv string.o objects
  822. Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/sysvr3 -O hash.c
  823. Xmv hash.o objects
  824. Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/sysvr3 -O dag.c
  825. Xmv dag.o objects
  826. Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/sysvr3 -O dmake.c
  827. Xmv dmake.o objects
  828. Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/sysvr3 -O path.c
  829. Xmv path.o objects
  830. Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/sysvr3 -O imacs.c
  831. Xmv imacs.o objects
  832. Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/sysvr3 -O sysintf.c
  833. Xmv sysintf.o objects
  834. Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/sysvr3 -O parse.c
  835. Xmv parse.o objects
  836. Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/sysvr3 -O getinp.c
  837. Xmv getinp.o objects
  838. Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/sysvr3 -O quit.c
  839. Xmv quit.o objects
  840. Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/sysvr3 -O basename.c
  841. Xmv basename.o objects
  842. Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/sysvr3 -O dump.c
  843. Xmv dump.o objects
  844. Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/sysvr3 -O macparse.c
  845. Xmv macparse.o objects
  846. Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/sysvr3 -O rulparse.c
  847. Xmv rulparse.o objects
  848. Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/sysvr3 -O percent.c
  849. Xmv percent.o objects
  850. Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/sysvr3 -O function.c
  851. Xmv function.o objects
  852. Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/sysvr3 -O unix/arlib.c
  853. Xmv arlib.o objects
  854. Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/sysvr3 -O unix/dirbrk.c
  855. Xmv dirbrk.o objects
  856. Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/sysvr3 -O unix/explode.c
  857. Xmv explode.o objects
  858. Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/sysvr3 -O unix/rmprq.c
  859. Xmv rmprq.o objects
  860. Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/sysvr3 -O unix/ruletab.c
  861. Xmv ruletab.o objects
  862. Xcc -c -DHELP -I. -Icommon -Iunix -Iunix/sysvr3 -O unix/sysvr3/runargv.c
  863. Xmv runargv.o objects
  864. Xcc  -o dmake  objects/infer.o objects/make.o objects/stat.o objects/expand.o objects/string.o objects/hash.o objects/dag.o objects/dmake.o objects/path.o objects/imacs.o objects/sysintf.o objects/parse.o objects/getinp.o objects/quit.o objects/basename.o objects/dump.o objects/macparse.o objects/rulparse.o objects/percent.o objects/function.o objects/arlib.o objects/dirbrk.o objects/explode.o objects/rmprq.o objects/ruletab.o objects/runargv.o 
  865. SHAR_EOF
  866. chmod 0640 unix/sysvr3/make.sh || echo "restore of unix/sysvr3/make.sh fails"
  867. echo "x - extracting unix/sysvr3/config.mk (Text)"
  868. sed 's/^X//' << 'SHAR_EOF' > unix/sysvr3/config.mk &&
  869. X# This is the SysV R3 UNIX configuration file for DMAKE
  870. X#    It simply modifies the values of SRC, and checks to see if
  871. X#    OSENVIRONMENT is defined.  If so it includes the appropriate
  872. X#    config.mk file.
  873. X#
  874. X# It also sets the values of .SOURCE.c and .SOURCE.h to include the local
  875. X# directory.
  876. X#
  877. Xosrdir := $(OS)$(DIRSEPSTR)$(OSRELEASE)
  878. X
  879. X# The following are required sources
  880. XOSDSRC := runargv.c
  881. XSRC    += $(OSDSRC)
  882. X.SETDIR=$(osrdir) : $(OSDSRC)
  883. X
  884. X.SOURCE.h : $(osrdir)
  885. X
  886. X# Local configuration modifications for CFLAGS, there's local SysV includes
  887. X# too.
  888. XCFLAGS += -I$(osrdir)
  889. X
  890. X# See if we modify anything in the lower levels.
  891. X.IF $(OSENVIRONMENT) != $(NULL)
  892. X   .INCLUDE .IGNORE : $(osrdir)$(DIRSEPSTR)$(OSENVIRONMENT)$(DIRSEPSTR)config.mk
  893. X.END
  894. SHAR_EOF
  895. chmod 0640 unix/sysvr3/config.mk || echo "restore of unix/sysvr3/config.mk fails"
  896. echo "x - extracting unix/sysvr3/config.h (Text)"
  897. sed 's/^X//' << 'SHAR_EOF' > unix/sysvr3/config.h &&
  898. X/* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/unix/sysvr3/RCS/config.h,v 1.1 90/10/06 12:06:39 dvadura Exp $
  899. X-- SYNOPSIS -- Configurarion include file.
  900. X-- 
  901. X-- DESCRIPTION
  902. X--     There is one of these for each specific machine configuration.
  903. X--    It can be used to further tweek the machine specific sources
  904. X--    so that they compile.
  905. X--
  906. X-- AUTHOR
  907. X--      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  908. X--      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  909. X--
  910. X-- COPYRIGHT
  911. X--      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
  912. X-- 
  913. X--      This program is free software; you can redistribute it and/or
  914. X--      modify it under the terms of the GNU General Public License
  915. X--      (version 1), as published by the Free Software Foundation, and
  916. X--      found in the file 'LICENSE' included with this distribution.
  917. X-- 
  918. X--      This program is distributed in the hope that it will be useful,
  919. X--      but WITHOUT ANY WARRANTY; without even the implied warrant of
  920. X--      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  921. X--      GNU General Public License for more details.
  922. X-- 
  923. X--      You should have received a copy of the GNU General Public License
  924. X--      along with this program;  if not, write to the Free Software
  925. X--      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  926. X--
  927. X-- LOG
  928. X--     $Log:    config.h,v $
  929. X * Revision 1.1  90/10/06  12:06:39  dvadura
  930. X * dmake Release, Version 3.6
  931. X * 
  932. X*/
  933. X
  934. X/* define this for configurations that don't have the coreleft function
  935. X * so that the code compiles.  To my knowledge coreleft exists only on
  936. X * Turbo C, but it is needed here since the function is used in many debug
  937. X * macros. */
  938. X#define coreleft() 0L
  939. X
  940. X/* Define the getcwd function that is used in the code, since BSD does
  941. X * not have getcwd, but call it getwd instead. */
  942. Xextern char *getcwd ANSI((char *, int));
  943. X
  944. X/* Define setvbuf, SysV doesn't have one */
  945. X#define setvbuf(fp, bp, type, len) setbuf( fp, NULL );
  946. X
  947. X/* NCR Tower's don't define size_t */
  948. X#ifdef tower
  949. Xtypedef long size_t;
  950. X#endif
  951. SHAR_EOF
  952. chmod 0440 unix/sysvr3/config.h || echo "restore of unix/sysvr3/config.h fails"
  953. echo mkdir - unix/sysvr1
  954. mkdir unix/sysvr1
  955. echo "x - extracting unix/sysvr1/vfprintf.c (Text)"
  956. sed 's/^X//' << 'SHAR_EOF' > unix/sysvr1/vfprintf.c &&
  957. X/* From:
  958. X * John Limpert            johnl@gronk.UUCP        uunet!n3dmc!gronk!johnl
  959. X */
  960. X
  961. X#include <stdio.h>
  962. X#include <varargs.h>
  963. X
  964. X#ifndef BUFSIZ
  965. X#include <stdio.h>
  966. X#endif
  967. X
  968. X#ifndef va_dcl
  969. X#include <varargs.h>
  970. X#endif
  971. X
  972. Xint
  973. Xvsprintf(str, fmt, ap)
  974. X    char *str, *fmt;
  975. X    va_list ap;
  976. X{
  977. X    FILE f;
  978. X    int len;
  979. X
  980. X    f._flag = _IOWRT+_IOMYBUF;
  981. X    f._ptr = (char *)str;    /* My copy of BSD stdio.h has this as (char *)
  982. X                 * with a comment that it should be
  983. X                 * (unsigned char *).  Since this code is
  984. X                 * intended for use on a vanilla BSD system,
  985. X                 * we'll stick with (char *) for now.
  986. X                 */
  987. X    f._cnt = 32767;
  988. X    len = _doprnt(fmt, ap, &f);
  989. X    *f._ptr = 0;
  990. X    return (len);
  991. X}
  992. X
  993. Xint
  994. Xvfprintf(iop, fmt, ap)
  995. X    FILE *iop;
  996. X    char *fmt;
  997. X    va_list ap;
  998. X{
  999. X    int len;
  1000. X
  1001. X    len = _doprnt(fmt, ap, iop);
  1002. X    return (ferror(iop) ? EOF : len);
  1003. X}
  1004. X
  1005. Xint
  1006. Xvprintf(fmt, ap)
  1007. X    char *fmt;
  1008. X    va_list ap;
  1009. X{
  1010. X    int len;
  1011. X
  1012. X    len = _doprnt(fmt, ap, stdout);
  1013. X    return (ferror(stdout) ? EOF : len);
  1014. X}
  1015. SHAR_EOF
  1016. chmod 0644 unix/sysvr1/vfprintf.c || echo "restore of unix/sysvr1/vfprintf.c fails"
  1017. echo "x - extracting unix/sysvr1/time.h (Text)"
  1018. sed 's/^X//' << 'SHAR_EOF' > unix/sysvr1/time.h &&
  1019. X/*
  1020. X** Berkeley get this wrong!
  1021. X*/
  1022. X#ifndef    TIME_h
  1023. X#define    TIME_h
  1024. X
  1025. Xtypedef    long    time_t;    /* this is the thing we use */
  1026. X
  1027. X#endif    TIME_h
  1028. X
  1029. SHAR_EOF
  1030. chmod 0440 unix/sysvr1/time.h || echo "restore of unix/sysvr1/time.h fails"
  1031. echo "x - extracting unix/sysvr1/stdlib.h (Text)"
  1032. sed 's/^X//' << 'SHAR_EOF' > unix/sysvr1/stdlib.h &&
  1033. X#ifndef _STDLIB_INCLUDED_
  1034. X#define _STDLIB_INCLUDED_
  1035. X
  1036. Xextern /*GOTO*/ _exit();
  1037. Xextern /*GOTO*/ exit();
  1038. Xextern /*GOTO*/ abort();
  1039. Xextern int system();
  1040. Xextern char *getenv();
  1041. Xextern char *calloc();
  1042. Xextern char *malloc();
  1043. Xextern char *realloc();
  1044. Xextern free();
  1045. Xextern int errno;
  1046. X
  1047. X#ifndef EIO
  1048. X#    include <errno.h>
  1049. X#endif
  1050. X
  1051. X#endif /* _STDLIB_INCLUDED_ */
  1052. SHAR_EOF
  1053. chmod 0440 unix/sysvr1/stdlib.h || echo "restore of unix/sysvr1/stdlib.h fails"
  1054. echo "x - extracting unix/sysvr1/stdarg.h (Text)"
  1055. sed 's/^X//' << 'SHAR_EOF' > unix/sysvr1/stdarg.h &&
  1056. X/*
  1057. X * stdarg.h
  1058. X *
  1059. X * defines ANSI style macros for accessing arguments of a function which takes
  1060. X * a variable number of arguments
  1061. X *
  1062. X */
  1063. X
  1064. X#if !defined(__STDARG)
  1065. X#define __STDARG
  1066. X
  1067. Xtypedef char *va_list;
  1068. X
  1069. X#define va_dcl int va_alist
  1070. X#define va_start(ap,v)  ap = (va_list)&va_alist
  1071. X#define va_arg(ap,t)    ((t*)(ap += sizeof(t)))[-1]
  1072. X#define va_end(ap)      ap = NULL
  1073. X#endif
  1074. SHAR_EOF
  1075. chmod 0440 unix/sysvr1/stdarg.h || echo "restore of unix/sysvr1/stdarg.h fails"
  1076. echo "x - extracting unix/sysvr1/startup.mk (Text)"
  1077. sed 's/^X//' << 'SHAR_EOF' > unix/sysvr1/startup.mk &&
  1078. X# Generic UNIX DMAKE startup file.  Customize to suit your needs.
  1079. X# Should work for both SYSV, and BSD 4.3
  1080. X# See the documentation for a description of internally defined macros.
  1081. X#
  1082. X# Disable warnings for macros redefined here that were given
  1083. X# on the command line.
  1084. X__.SILENT := $(.SILENT)
  1085. X.SILENT   := yes
  1086. X
  1087. X# Configuration parameters for DMAKE startup.mk file
  1088. X# Set these to NON-NULL if you wish to turn the parameter on.
  1089. X_HAVE_RCS    := yes        # yes => RCS  is installed.
  1090. X_HAVE_SCCS    := yes        # yes => SCCS is installed.
  1091. X
  1092. X# Applicable suffix definitions
  1093. XA := .a        # Libraries
  1094. XE :=        # Executables
  1095. XF := .f        # Fortran
  1096. XO := .o        # Objects
  1097. XP := .p        # Pascal
  1098. XS := .s        # Assembler sources
  1099. XV := ,v        # RCS suffix
  1100. X
  1101. X# Recipe execution configurations
  1102. XSHELL        := /bin/sh
  1103. XSHELLFLAGS    := -ce
  1104. XGROUPSHELL    := $(SHELL)
  1105. XGROUPFLAGS    := 
  1106. XSHELLMETAS    := |();&<>?*][$$:\\#`'"
  1107. XGROUPSUFFIX    :=
  1108. XDIVFILE         = $(TMPFILE)
  1109. X
  1110. X# Standard C-language command names and flags
  1111. X   CPP       := /lib/cpp        # C-preprocessor
  1112. X   CC      := cc        # C-compiler and flags
  1113. X   CFLAGS  +=
  1114. X
  1115. X   AS      := as        # Assembler and flags
  1116. X   ASFLAGS += 
  1117. X
  1118. X   LD       = $(CC)        # Loader and flags
  1119. X   LDFLAGS +=
  1120. X   LDLIBS   =
  1121. X
  1122. X# Definition of $(MAKE) macro for recursive makes.
  1123. X   MAKE = $(MAKECMD) $(MFLAGS)
  1124. X
  1125. X# Definition of Print command for this system.
  1126. X   PRINT = lpr
  1127. X
  1128. X# Language and Parser generation Tools and their flags
  1129. X   YACC      := yacc        # standard yacc
  1130. X   YFLAGS +=
  1131. X   YTAB      := y.tab        # yacc output files name stem.
  1132. X
  1133. X   LEX      := lex        # standard lex
  1134. X   LFLAGS +=
  1135. X   LEXYY  := lex.yy        # lex output file
  1136. X
  1137. X# Other Compilers, Tools and their flags
  1138. X   PC    := pc            # pascal compiler
  1139. X   RC    := f77            # ratfor compiler
  1140. X   FC    := f77            # fortran compiler
  1141. X
  1142. X   CO       := co        # check out for RCS
  1143. X   COFLAGS += -q
  1144. X
  1145. X   AR     := ar            # archiver
  1146. X   ARFLAGS+= ruv
  1147. X
  1148. X   RM       := /bin/rm        # remove a file command
  1149. X   RMFLAGS +=
  1150. X
  1151. X# Implicit generation rules for making inferences.
  1152. X# We don't provide .yr or .ye rules here.  They're obsolete.
  1153. X# Rules for making *$O
  1154. X   %$O : %.c ; $(CC) $(CFLAGS) -c $<
  1155. X   %$O : %$P ; $(PC) $(PFLAGS) -c $<
  1156. X   %$O : %$S ; $(AS) $(ASFLAGS) $<
  1157. X   %$O : %.cl ; class -c $<
  1158. X   %$O : %.e %.r %.F %$F
  1159. X    $(FC) $(RFLAGS) $(EFLAGS) $(FFLAGS) -c $<
  1160. X
  1161. X# Executables
  1162. X   %$E : %$O ; $(LD) $(LDFLAGS) -o $@ $< $(LDLIBES)
  1163. X
  1164. X# lex and yacc rules
  1165. X   %.c : %.y ; $(YACC)  $(YFLAGS) $<; mv $(YTAB).c $@
  1166. X   %.c : %.l ; $(LEX)   $(LFLAGS) $<; mv $(LEXYY).c $@
  1167. X
  1168. X# This rule tells how to make *.out from it's immediate list of prerequisites
  1169. X# UNIX only.
  1170. X   %.out :; $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)
  1171. X
  1172. X# RCS support
  1173. X.IF $(_HAVE_RCS)
  1174. X   % : %$V $$(@:d)RCS/$$(@:f)$V;- $(CO) $(COFLAGS) $@
  1175. X   .NOINFER : %$V $$(@:d)RCS/$$(@:f)$V
  1176. X.END
  1177. X
  1178. X# SCCS support
  1179. X.IF $(_HAVE_SCCS)
  1180. X   % : s.% ; get $@
  1181. X   .NOINFER : s.%
  1182. X.END
  1183. X
  1184. X# Recipe to make archive files.
  1185. X%$A :
  1186. X[
  1187. X   $(AR) $(ARFLAGS) $@ $?
  1188. X   $(RM) $(RMFLAGS) $?
  1189. X   ranlib $@
  1190. X]
  1191. X
  1192. X# DMAKE uses this recipe to remove intermediate targets
  1193. X.REMOVE :; $(RM) -f $<
  1194. X
  1195. X# AUGMAKE extensions for SYSV compatibility
  1196. X@B = $(@:b)
  1197. X@D = $(@:d)
  1198. X@F = $(@:f)
  1199. X*B = $(*:b)
  1200. X*D = $(*:d)
  1201. X*F = $(*:f)
  1202. X<B = $(<:b)
  1203. X<D = $(<:d)
  1204. X<F = $(<:f)
  1205. X?B = $(?:b)
  1206. X?F = $(?:f)
  1207. X?D = $(?:d)
  1208. X
  1209. X# Turn warnings back to previous setting.
  1210. X.SILENT := $(__.SILENT)
  1211. X
  1212. X# Local startup file if any
  1213. X.INCLUDE .IGNORE: "_startup.mk"
  1214. SHAR_EOF
  1215. chmod 0640 unix/sysvr1/startup.mk || echo "restore of unix/sysvr1/startup.mk fails"
  1216. echo "x - extracting unix/sysvr1/runargv.c (Text)"
  1217. sed 's/^X//' << 'SHAR_EOF' > unix/sysvr1/runargv.c &&
  1218. X/* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/unix/sysvr1/RCS/runargv.c,v 1.1 90/10/06 12:06:32 dvadura Exp $
  1219. X-- SYNOPSIS -- invoke a sub process.
  1220. X-- 
  1221. X-- DESCRIPTION
  1222. X--     Use the standard methods of executing a sub process.
  1223. X--
  1224. X-- AUTHOR
  1225. X--      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  1226. X--      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  1227. X--
  1228. X-- COPYRIGHT
  1229. X--      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
  1230. X-- 
  1231. X--      This program is free software; you can redistribute it and/or
  1232. X--      modify it under the terms of the GNU General Public License
  1233. X--      (version 1), as published by the Free Software Foundation, and
  1234. X--      found in the file 'LICENSE' included with this distribution.
  1235. X-- 
  1236. X--      This program is distributed in the hope that it will be useful,
  1237. X--      but WITHOUT ANY WARRANTY; without even the implied warrant of
  1238. X--      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1239. X--      GNU General Public License for more details.
  1240. X-- 
  1241. X--      You should have received a copy of the GNU General Public License
  1242. X--      along with this program;  if not, write to the Free Software
  1243. X--      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1244. X--
  1245. X-- LOG
  1246. X--     $Log:    runargv.c,v $
  1247. X * Revision 1.1  90/10/06  12:06:32  dvadura
  1248. X * dmake Release, Version 3.6
  1249. X * 
  1250. X*/
  1251. X
  1252. X#include <signal.h>
  1253. X#include "extern.h"
  1254. X#include "sysintf.h"
  1255. X#include "alloc.h"
  1256. X
  1257. Xtypedef struct prp {
  1258. X   char *prp_cmd;
  1259. X   int   prp_group;
  1260. X   int   prp_ignore;
  1261. X   int   prp_last;
  1262. X   int     prp_shell;
  1263. X   struct prp *prp_next;
  1264. X   char  *prp_dir;
  1265. X} RCP, *RCPPTR;
  1266. X
  1267. Xtypedef struct pr {
  1268. X   int        pr_valid;
  1269. X   int        pr_pid;
  1270. X   CELLPTR    pr_target;
  1271. X   HOWPTR    pr_how;
  1272. X   int        pr_ignore;
  1273. X   int        pr_last;
  1274. X   RCPPTR      pr_recipe;
  1275. X   RCPPTR      pr_recipe_end;
  1276. X} PR;
  1277. X
  1278. Xstatic PR  *_procs    = NIL(PR);
  1279. Xstatic int  _proc_cnt = 0;
  1280. Xstatic int  _abort_flg= FALSE;
  1281. Xstatic int  _use_i    = -1;
  1282. Xstatic int  _do_upd   = 0;
  1283. X
  1284. Xstatic  void    _add_child ANSI((int, CELLPTR, HOWPTR, int, int));
  1285. Xstatic  void    _attach_cmd ANSI((char *, int, int, CELLPTR, HOWPTR, int, int));
  1286. Xstatic  void    _finished_child ANSI((int, int));
  1287. Xstatic  int     _running ANSI((CELLPTR, HOWPTR));
  1288. X
  1289. Xint
  1290. Xrunargv(target, how, ignore, group, last, shell, cmd)
  1291. XCELLPTR target;
  1292. XHOWPTR  how;
  1293. Xint     ignore;
  1294. Xint    group;
  1295. Xint    last;
  1296. Xint     shell;
  1297. Xchar    *cmd;
  1298. X{
  1299. X   extern  int  errno;
  1300. X   extern  char *sys_errlist[];
  1301. X   int          pid;
  1302. X   char         **argv;
  1303. X
  1304. X   if( _running(target, how) /*&& Max_proc != 1*/ ) {
  1305. X      /* The command will be executed when the previous recipe
  1306. X       * line completes. */
  1307. X      _attach_cmd( cmd, group, ignore, target, how, last, shell );
  1308. X      return(1);
  1309. X   }
  1310. X
  1311. X   while( _proc_cnt == Max_proc )
  1312. X      if( Wait_for_child(FALSE, -1) == -1 )  Fatal( "Lost a child" );
  1313. X
  1314. X   argv = Pack_argv( group, shell, cmd );
  1315. X
  1316. X   switch( pid=fork() ){
  1317. X      int   wid;
  1318. X      int   status;
  1319. X
  1320. X   case -1: /* fork failed */
  1321. X      Error("%s: %s", argv[0], sys_errlist[errno]);
  1322. X      Handle_result(-1, ignore, _abort_flg, target);
  1323. X      return(-1);
  1324. X
  1325. X   case 0:  /* child */
  1326. X      execvp(argv[0], argv);
  1327. X      Continue = TRUE;   /* survive error message */
  1328. X      Error("%s: %s", argv[0], sys_errlist[errno]);
  1329. X      kill(getpid(), SIGTERM);
  1330. X      /*NOTREACHED*/
  1331. X
  1332. X   default: /* parent */
  1333. X      _add_child(pid, target, how, ignore, last);
  1334. X   }
  1335. X
  1336. X   return(1);
  1337. X}
  1338. X
  1339. X
  1340. Xint
  1341. XWait_for_child( abort_flg, pid )
  1342. Xint abort_flg;
  1343. Xint pid;
  1344. X{
  1345. X   int wid;
  1346. X   int status;
  1347. X   int waitchild;
  1348. X
  1349. X   waitchild = (pid == -1)? FALSE : Wait_for_completion;
  1350. X
  1351. X   do {
  1352. X      if( (wid = wait(&status)) == -1 ) return(-1);
  1353. X
  1354. X      _abort_flg = abort_flg;
  1355. X      _finished_child(wid, status);
  1356. X      _abort_flg = FALSE;
  1357. X   }
  1358. X   while( waitchild && pid != wid );
  1359. X
  1360. X   return(0);
  1361. X}
  1362. X
  1363. X
  1364. Xvoid
  1365. XClean_up_processes()
  1366. X{
  1367. X   register int i;
  1368. X
  1369. X   if( _procs != NIL(PR) ) {
  1370. X      for( i=0; i<Max_proc; i++ )
  1371. X     if( _procs[i].pr_valid )
  1372. X        kill(_procs[i].pr_pid, SIGTERM);
  1373. X
  1374. X      while( Wait_for_child(TRUE, -1) != -1 );
  1375. X   }
  1376. X}
  1377. X
  1378. X
  1379. Xstatic void
  1380. X_add_child( pid, target, how, ignore, last )
  1381. Xint    pid;
  1382. XCELLPTR target;
  1383. XHOWPTR  how;
  1384. Xint    ignore;
  1385. Xint     last;
  1386. X{
  1387. X   register int i;
  1388. X   register PR *pp;
  1389. X
  1390. X   if( _procs == NIL(PR) ) {
  1391. X      TALLOC( _procs, Max_proc, PR );
  1392. X   }
  1393. X
  1394. X   if( (i = _use_i) == -1 )
  1395. X      for( i=0; i<Max_proc; i++ )
  1396. X     if( !_procs[i].pr_valid )
  1397. X        break;
  1398. X
  1399. X   pp = _procs+i;
  1400. X
  1401. X   pp->pr_valid  = 1;
  1402. X   pp->pr_pid    = pid;
  1403. X   pp->pr_target = target;
  1404. X   pp->pr_how    = how;
  1405. X   pp->pr_ignore = ignore;
  1406. X   pp->pr_last   = last;
  1407. X
  1408. X   Current_target = NIL(HOW);
  1409. X
  1410. X   _proc_cnt++;
  1411. X
  1412. X   if( Wait_for_completion ) Wait_for_child( FALSE, pid );
  1413. X}
  1414. X
  1415. X
  1416. Xstatic void
  1417. X_finished_child(pid, status)
  1418. Xint    pid;
  1419. Xint    status;
  1420. X{
  1421. X   register int i;
  1422. X   register PR *pp;
  1423. X
  1424. X   for( i=0; i<Max_proc; i++ )
  1425. X      if( _procs[i].pr_valid && _procs[i].pr_pid == pid )
  1426. X     break;
  1427. X
  1428. X   _procs[i].pr_valid = 0;
  1429. X   _proc_cnt--;
  1430. X
  1431. X   if( _procs[i].pr_recipe != NIL(RCP) && !_abort_flg ) {
  1432. X      RCPPTR rp = _procs[i].pr_recipe;
  1433. X      char   *dir;
  1434. X
  1435. X      Current_target = _procs[i].pr_how;
  1436. X      Handle_result( status, _procs[i].pr_ignore, FALSE, _procs[i].pr_target );
  1437. X      Current_target = NIL(HOW);
  1438. X
  1439. X      _procs[i].pr_recipe = rp->prp_next;
  1440. X
  1441. X      _use_i = i;
  1442. X      dir = _strdup(Get_current_dir());
  1443. X      Set_dir( rp->prp_dir );
  1444. X      runargv( _procs[i].pr_target, _procs[i].pr_how, rp->prp_ignore,
  1445. X                 rp->prp_group, rp->prp_last, rp->prp_shell, rp->prp_cmd );
  1446. X      Set_dir(dir);
  1447. X      FREE(dir);
  1448. X      FREE(rp->prp_dir);
  1449. X      _use_i = -1;
  1450. X
  1451. X      FREE( rp->prp_cmd );
  1452. X      FREE( rp );
  1453. X
  1454. X      if( _proc_cnt == Max_proc ) Wait_for_child( FALSE, -1 );
  1455. X   }
  1456. X   else {
  1457. X      Unlink_temp_files( _procs[i].pr_how );
  1458. X      Handle_result(status,_procs[i].pr_ignore,_abort_flg,_procs[i].pr_target);
  1459. X
  1460. X      if( _procs[i].pr_last && !Doing_bang )
  1461. X     Update_time_stamp( _procs[i].pr_target, _procs[i].pr_how );
  1462. X   }
  1463. X}
  1464. X
  1465. X
  1466. Xstatic int
  1467. X_running( cp, how )
  1468. XCELLPTR cp;
  1469. XHOWPTR  how;
  1470. X{
  1471. X   register int i;
  1472. X
  1473. X   if( !_procs ) return(FALSE);
  1474. SHAR_EOF
  1475. echo "End of part 1"
  1476. echo "File unix/sysvr1/runargv.c is continued in part 2"
  1477. echo "2" > s2_seq_.tmp
  1478. exit 0
  1479.  
  1480.