home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume19 / dmake / part32 < prev    next >
Encoding:
Text File  |  1991-05-13  |  40.2 KB  |  1,399 lines

  1. Newsgroups: comp.sources.misc
  2. From: Dennis Vadura <dvadura@watdragon.waterloo.edu>
  3. Subject:  v19i053:  dmake - dmake version 3.7, Part32/37
  4. Message-ID: <1991May13.145336.9683@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: 381e3d6f288864a58491b309f41e6e89
  6. Date: Mon, 13 May 1991 14:53:36 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: Dennis Vadura <dvadura@watdragon.waterloo.edu>
  10. Posting-number: Volume 19, Issue 53
  11. Archive-name: dmake/part32
  12. Supersedes: dmake-3.6: Volume 15, Issue 52-77
  13.  
  14. ---- Cut Here and feed the following to sh ----
  15. #!/bin/sh
  16. # this is dmake.shar.32 (part 32 of a multipart archive)
  17. # do not concatenate these parts, unpack them in order with /bin/sh
  18. # file dmake/tos/runargv.c continued
  19. #
  20. if test ! -r _shar_seq_.tmp; then
  21.     echo 'Please unpack part 1 first!'
  22.     exit 1
  23. fi
  24. (read Scheck
  25.  if test "$Scheck" != 32; then
  26.     echo Please unpack part "$Scheck" next!
  27.     exit 1
  28.  else
  29.     exit 0
  30.  fi
  31. ) < _shar_seq_.tmp || exit 1
  32. if test -f _shar_wnt_.tmp; then
  33. sed 's/^X//' << 'SHAR_EOF' >> 'dmake/tos/runargv.c' &&
  34. X
  35. PUBLIC int
  36. runargv(target, ignore, group, last, shell, cmd)
  37. CELLPTR target;
  38. int     ignore;
  39. int    group;
  40. int    last;
  41. int    shell;
  42. char    *cmd;
  43. {
  44. X   int status;
  45. X   char **argv;
  46. X
  47. X   argv = Pack_argv( group, shell, cmd );
  48. X   _add_child(target, ignore);
  49. X   status = spawnvp(P_WAIT, *argv, argv);
  50. X   if( status == -1 ) Error("%s: %s", argv[0], strerror(errno));
  51. X   _finished_child(status);
  52. X   if( last && !Doing_bang ) Update_time_stamp( target );
  53. X
  54. X   return( 0 );
  55. }
  56. X
  57. X
  58. PUBLIC void
  59. Clean_up_processes()
  60. {
  61. X   _abort_flg = TRUE;
  62. X   _finished_child(-1);
  63. }
  64. X
  65. X
  66. PUBLIC int
  67. Wait_for_child( abort_flg, pid )
  68. int abort_flg;
  69. int pid;
  70. {
  71. X   return(1);
  72. }
  73. X
  74. X
  75. static int     _valid = -1;
  76. static CELLPTR _tg;
  77. static int     _ignore;
  78. X
  79. static void
  80. _add_child( target, ignore )
  81. CELLPTR target;
  82. int    ignore;
  83. {
  84. X   _tg = target;
  85. X   _ignore = ignore;
  86. X   _valid = 0;
  87. X
  88. X   Current_target = NIL(CELL);
  89. }
  90. X
  91. X
  92. static void
  93. _finished_child(status)
  94. int    status;
  95. {
  96. X   if( _valid == -1 ) return;
  97. X   Unlink_temp_files( _tg );
  98. X   _valid = -1;
  99. X   Handle_result( status, _ignore, _abort_flg, _tg );
  100. }
  101. SHAR_EOF
  102. chmod 0640 dmake/tos/runargv.c ||
  103. echo 'restore of dmake/tos/runargv.c failed'
  104. Wc_c="`wc -c < 'dmake/tos/runargv.c'`"
  105. test 2542 -eq "$Wc_c" ||
  106.     echo 'dmake/tos/runargv.c: original size 2542, current size' "$Wc_c"
  107. rm -f _shar_wnt_.tmp
  108. fi
  109. # ============= dmake/tos/startup.h ==============
  110. if test -f 'dmake/tos/startup.h' -a X"$1" != X"-c"; then
  111.     echo 'x - skipping dmake/tos/startup.h (File already exists)'
  112.     rm -f _shar_wnt_.tmp
  113. else
  114. > _shar_wnt_.tmp
  115. sed 's/^X//' << 'SHAR_EOF' > 'dmake/tos/startup.h' &&
  116. /* This file contains the default value of the MAKESTARTUP variable.
  117. X * You must set the quoted string below to the default path to the startup
  118. X * variable, so that it gets compiled in.  LEAVE ROOTDIR at the front of
  119. X * the path.  This allows the user to customize his environment for dmake
  120. X * by setting up a new ROOTDIR environment variable. */
  121. X
  122. "MAKESTARTUP := $(ROOTDIR)/etc/startup.mk",
  123. SHAR_EOF
  124. chmod 0640 dmake/tos/startup.h ||
  125. echo 'restore of dmake/tos/startup.h failed'
  126. Wc_c="`wc -c < 'dmake/tos/startup.h'`"
  127. test 392 -eq "$Wc_c" ||
  128.     echo 'dmake/tos/startup.h: original size 392, current size' "$Wc_c"
  129. rm -f _shar_wnt_.tmp
  130. fi
  131. # ============= dmake/tos/startup.mk ==============
  132. if test -f 'dmake/tos/startup.mk' -a X"$1" != X"-c"; then
  133.     echo 'x - skipping dmake/tos/startup.mk (File already exists)'
  134.     rm -f _shar_wnt_.tmp
  135. else
  136. > _shar_wnt_.tmp
  137. sed 's/^X//' << 'SHAR_EOF' > 'dmake/tos/startup.mk' &&
  138. # Generic UNIX DMAKE startup file.  Customize to suit your needs.
  139. # Should work for both SYSV, and BSD 4.3
  140. # See the documentation for a description of internally defined macros.
  141. #
  142. # Disable warnings for macros redefined here that were given
  143. # on the command line.
  144. __.SILENT := $(.SILENT)
  145. .SILENT   := yes
  146. X
  147. # Configuration parameters for DMAKE startup.mk file
  148. # Set these to NON-NULL if you wish to turn the parameter on.
  149. _HAVE_RCS    :=         # yes => RCS  is installed.
  150. _HAVE_SCCS    :=         # yes => SCCS is installed.
  151. X
  152. # Applicable suffix definitions
  153. A := .olb    # Libraries
  154. E :=        # Executables
  155. F := .f        # Fortran
  156. O := .o        # Objects
  157. P := .p        # Pascal
  158. S := .s        # Assembler sources
  159. V := ,v        # RCS suffix
  160. X
  161. # Recipe execution configurations
  162. SHELL        := /bin/sh
  163. SHELLFLAGS    := 
  164. GROUPSHELL    := $(SHELL)
  165. GROUPFLAGS    := 
  166. SHELLMETAS    := |();&<>?*][$$:\\#`'"
  167. GROUPSUFFIX    := .bat
  168. DIVFILE         = $(TMPFILE)
  169. X
  170. # Standard C-language command names and flags
  171. X   CPP       := /gnu/lib/cpp    # C-preprocessor
  172. X   CC      := gcc        # C-compiler and flags
  173. X   CFLAGS  +=
  174. X
  175. X   AS      := /gnu/lib/as    # Assembler and flags
  176. X   ASFLAGS += 
  177. X
  178. X   LD       = $(CC)        # Loader and flags
  179. X   LDFLAGS +=
  180. X   LDLIBS   =
  181. X
  182. # Definition of $(MAKE) macro for recursive makes.
  183. X   MAKE = $(MAKECMD) $(MFLAGS)
  184. X
  185. # Definition of Print command for this system.
  186. X   PRINT = lpr
  187. X
  188. # Language and Parser generation Tools and their flags
  189. X   YACC      := yacc        # standard yacc
  190. X   YFLAGS +=
  191. X   YTAB      := y.tab        # yacc output files name stem.
  192. X
  193. X   LEX      := lex        # standard lex
  194. X   LFLAGS +=
  195. X   LEXYY  := lex.yy        # lex output file
  196. X
  197. # Other Compilers, Tools and their flags
  198. X   PC    := pc            # pascal compiler
  199. X   RC    := f77            # ratfor compiler
  200. X   FC    := f77            # fortran compiler
  201. X
  202. X   CO       := co        # check out for RCS
  203. X   COFLAGS += -q
  204. X
  205. X   AR     := gar        # archiver
  206. X   ARFLAGS+= ruv
  207. X
  208. X   RM       := /gnu/bin/rm    # remove a file command
  209. X   RMFLAGS +=
  210. X
  211. # Implicit generation rules for making inferences.
  212. # We don't provide .yr or .ye rules here.  They're obsolete.
  213. # Rules for making *$O
  214. X   %$O : %.c ; $(CC) $(CFLAGS) -c $<
  215. X   %$O : %$P ; $(PC) $(PFLAGS) -c $<
  216. X   %$O : %$S ; $(AS) $(ASFLAGS) $<
  217. X   %$O : %.cl ; class -c $<
  218. X   %$O : %.e %.r %.F %$F
  219. X    $(FC) $(RFLAGS) $(EFLAGS) $(FFLAGS) -c $<
  220. X
  221. # Executables
  222. X   %$E : %$O ; $(LD) $(LDFLAGS) -o $@ $< $(LDLIBES)
  223. X
  224. # lex and yacc rules
  225. X   %.c : %.y ; $(YACC)  $(YFLAGS) $<; mv $(YTAB).c $@
  226. X   %.c : %.l ; $(LEX)   $(LFLAGS) $<; mv $(LEXYY).c $@
  227. X
  228. # This rule tells how to make *.out from it's immediate list of prerequisites
  229. # UNIX only.
  230. X   %.out :; $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)
  231. X
  232. # RCS support
  233. .IF $(_HAVE_RCS)
  234. X   % : %$V $$(@:d)RCS/$$(@:f)$V;- $(CO) $(COFLAGS) $@
  235. X   .NOINFER : %$V $$(@:d)RCS/$$(@:f)$V
  236. .END
  237. X
  238. # SCCS support
  239. .IF $(_HAVE_SCCS)
  240. X   % : s.% ; get $@
  241. X   .NOINFER : s.%
  242. .END
  243. X
  244. # Recipe to make archive files.
  245. %$A :
  246. [
  247. X   $(AR) $(ARFLAGS) $@ $?
  248. X   $(RM) $(RMFLAGS) $?
  249. X   ranlib $@
  250. ]
  251. X
  252. # DMAKE uses this recipe to remove intermediate targets
  253. .REMOVE :; $(RM) -f $<
  254. X
  255. # AUGMAKE extensions for SYSV compatibility
  256. @B = $(@:b)
  257. @D = $(@:d)
  258. @F = $(@:f)
  259. *B = $(*:b)
  260. *D = $(*:d)
  261. *F = $(*:f)
  262. <B = $(<:b)
  263. <D = $(<:d)
  264. <F = $(<:f)
  265. ?B = $(?:b)
  266. ?F = $(?:f)
  267. ?D = $(?:d)
  268. X
  269. # Turn warnings back to previous setting.
  270. .SILENT := $(__.SILENT)
  271. X
  272. # Local startup file if any
  273. .INCLUDE .IGNORE: "_startup.mk"
  274. SHAR_EOF
  275. chmod 0640 dmake/tos/startup.mk ||
  276. echo 'restore of dmake/tos/startup.mk failed'
  277. Wc_c="`wc -c < 'dmake/tos/startup.mk'`"
  278. test 3233 -eq "$Wc_c" ||
  279.     echo 'dmake/tos/startup.mk: original size 3233, current size' "$Wc_c"
  280. rm -f _shar_wnt_.tmp
  281. fi
  282. # ============= dmake/tos/sysintf.h ==============
  283. if test -f 'dmake/tos/sysintf.h' -a X"$1" != X"-c"; then
  284.     echo 'x - skipping dmake/tos/sysintf.h (File already exists)'
  285.     rm -f _shar_wnt_.tmp
  286. else
  287. > _shar_wnt_.tmp
  288. sed 's/^X//' << 'SHAR_EOF' > 'dmake/tos/sysintf.h' &&
  289. /*
  290. ** assorted bits of system interface, for common routines inside dmake.
  291. ** System specific code can be found in the config.h files for each
  292. ** of the system specifications.
  293. */
  294. X
  295. #define STAT stat
  296. #define VOID_LCACHE(l,m) (void) void_lcache(l,m)
  297. #define Hook_std_writes(A)
  298. #definf GETPID getpid()
  299. X
  300. /*
  301. ** standard C items
  302. */
  303. X
  304. /*
  305. ** DOS interface standard items
  306. */
  307. #define    getswitchar()    '-'
  308. X
  309. /*
  310. ** make parameters
  311. */
  312. #define    MAX_PATH_LEN    1024
  313. SHAR_EOF
  314. chmod 0640 dmake/tos/sysintf.h ||
  315. echo 'restore of dmake/tos/sysintf.h failed'
  316. Wc_c="`wc -c < 'dmake/tos/sysintf.h'`"
  317. test 442 -eq "$Wc_c" ||
  318.     echo 'dmake/tos/sysintf.h: original size 442, current size' "$Wc_c"
  319. rm -f _shar_wnt_.tmp
  320. fi
  321. # ============= dmake/tos/tempnam.c ==============
  322. if test -f 'dmake/tos/tempnam.c' -a X"$1" != X"-c"; then
  323.     echo 'x - skipping dmake/tos/tempnam.c (File already exists)'
  324.     rm -f _shar_wnt_.tmp
  325. else
  326. > _shar_wnt_.tmp
  327. sed 's/^X//' << 'SHAR_EOF' > 'dmake/tos/tempnam.c' &&
  328. /*LINTLIBRARY*/
  329. #include <stdio.h>
  330. #include <string.h>
  331. #include <stdlib.h>
  332. X
  333. #define max(A,B) (((A)<(B))?(B):(A))
  334. X
  335. extern char *mktemp();
  336. extern int access();
  337. X
  338. static char *cpdir();
  339. static char  *seed="AAA";
  340. X
  341. /* BSD stdio.h doesn't define P_tmpdir, so let's do it here */
  342. #ifndef P_tmpdir
  343. static char *P_tmpdir = "/tmp";
  344. #endif
  345. X
  346. char *
  347. tempnam(dir, prefix)
  348. char *dir;        /* use this directory please (if non-NULL) */
  349. char *prefix;        /* use this (if non-NULL) as filename prefix */
  350. {
  351. X   register char *p, *q, *tmpdir;
  352. X   int            tl=0, dl=0, pl;
  353. X
  354. X   pl = strlen(P_tmpdir);
  355. X
  356. X   if( (tmpdir = getenv("TMPDIR")) != NULL ) tl = strlen(tmpdir);
  357. X   if( dir != NULL ) dl = strlen(dir);
  358. X
  359. X   if( (p = malloc((unsigned)(max(max(dl,tl),pl)+16))) == NULL )
  360. X     return(NULL);
  361. X
  362. X   *p = '\0';
  363. X
  364. X   if( (tl == 0) || (access( cpdir(p, tmpdir), 3) != 0) )
  365. X     if( (dl == 0) || (access( cpdir(p, dir), 3) != 0) )
  366. X    if( access( cpdir(p, P_tmpdir),   3) != 0 )
  367. X       if( access( cpdir(p, "/tmp"),  3) != 0 )
  368. X          return(NULL);
  369. X
  370. X   (void) strcat(p, "/");
  371. X   if(prefix)
  372. X   {
  373. X      *(p+strlen(p)+5) = '\0';
  374. X      (void)strncat(p, prefix, 5);
  375. X   }
  376. X
  377. X   (void)strcat(p, seed);
  378. X   (void)strcat(p, "XXXXXX");
  379. X
  380. X   q = seed;
  381. X   while(*q == 'Z') *q++ = 'A';
  382. X   ++*q;
  383. X
  384. X   if(*mktemp(p) == '\0') return(NULL);
  385. X   return(p);
  386. }
  387. X
  388. X
  389. X
  390. static char *
  391. cpdir(buf, str)
  392. char *buf;
  393. char *str;
  394. {
  395. X   char *p;
  396. X
  397. X   if(str != NULL)
  398. X   {
  399. X      (void) strcpy(buf, str);
  400. X      p = buf - 1 + strlen(buf);
  401. X      if(*p == '/') *p = '\0';
  402. X   }
  403. X
  404. X   return(buf);
  405. }
  406. SHAR_EOF
  407. chmod 0640 dmake/tos/tempnam.c ||
  408. echo 'restore of dmake/tos/tempnam.c failed'
  409. Wc_c="`wc -c < 'dmake/tos/tempnam.c'`"
  410. test 1506 -eq "$Wc_c" ||
  411.     echo 'dmake/tos/tempnam.c: original size 1506, current size' "$Wc_c"
  412. rm -f _shar_wnt_.tmp
  413. fi
  414. # ============= dmake/unix/386ix/ar.h ==============
  415. if test ! -d 'dmake/unix'; then
  416.     mkdir 'dmake/unix'
  417. fi
  418. if test ! -d 'dmake/unix/386ix'; then
  419.     mkdir 'dmake/unix/386ix'
  420. fi
  421. if test -f 'dmake/unix/386ix/ar.h' -a X"$1" != X"-c"; then
  422.     echo 'x - skipping dmake/unix/386ix/ar.h (File already exists)'
  423.     rm -f _shar_wnt_.tmp
  424. else
  425. > _shar_wnt_.tmp
  426. sed 's/^X//' << 'SHAR_EOF' > 'dmake/unix/386ix/ar.h' &&
  427. #define PORTAR 1
  428. #include "/usr/include/ar.h"
  429. SHAR_EOF
  430. chmod 0640 dmake/unix/386ix/ar.h ||
  431. echo 'restore of dmake/unix/386ix/ar.h failed'
  432. Wc_c="`wc -c < 'dmake/unix/386ix/ar.h'`"
  433. test 46 -eq "$Wc_c" ||
  434.     echo 'dmake/unix/386ix/ar.h: original size 46, current size' "$Wc_c"
  435. rm -f _shar_wnt_.tmp
  436. fi
  437. # ============= dmake/unix/386ix/config.h ==============
  438. if test -f 'dmake/unix/386ix/config.h' -a X"$1" != X"-c"; then
  439.     echo 'x - skipping dmake/unix/386ix/config.h (File already exists)'
  440.     rm -f _shar_wnt_.tmp
  441. else
  442. > _shar_wnt_.tmp
  443. sed 's/^X//' << 'SHAR_EOF' > 'dmake/unix/386ix/config.h' &&
  444. /* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/unix/386ix/RCS/config.h,v 1.1 91/05/06 15:27:43 dvadura Exp $
  445. -- SYNOPSIS -- Configurarion include file.
  446. -- 
  447. -- DESCRIPTION
  448. --     There is one of these for each specific machine configuration.
  449. --    It can be used to further tweek the machine specific sources
  450. --    so that they compile.
  451. --
  452. -- AUTHOR
  453. --      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  454. --      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  455. --
  456. -- COPYRIGHT
  457. --      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
  458. -- 
  459. --      This program is free software; you can redistribute it and/or
  460. --      modify it under the terms of the GNU General Public License
  461. --      (version 1), as published by the Free Software Foundation, and
  462. --      found in the file 'LICENSE' included with this distribution.
  463. -- 
  464. --      This program is distributed in the hope that it will be useful,
  465. --      but WITHOUT ANY WARRANTY; without even the implied warrant of
  466. --      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  467. --      GNU General Public License for more details.
  468. -- 
  469. --      You should have received a copy of the GNU General Public License
  470. --      along with this program;  if not, write to the Free Software
  471. --      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  472. --
  473. -- LOG
  474. --     $Log:    config.h,v $
  475. X * Revision 1.1  91/05/06  15:27:43  dvadura
  476. X * dmake Release Version 3.7
  477. X * 
  478. */
  479. X
  480. /* define this for configurations that don't have the coreleft function
  481. X * so that the code compiles.  To my knowledge coreleft exists only on
  482. X * Turbo C, but it is needed here since the function is used in many debug
  483. X * macros. */
  484. #define coreleft() 0L
  485. X
  486. /* Define the getcwd function that is used in the code, since BSD does
  487. X * not have getcwd, but call it getwd instead. */
  488. extern char *getcwd ANSI((char *, int));
  489. X
  490. /* Define setvbuf, SysV doesn't have one */
  491. #define setvbuf(fp, bp, type, len) setbuf( fp, NULL );
  492. X
  493. /* We don't care about CONST */
  494. #define CONST
  495. SHAR_EOF
  496. chmod 0640 dmake/unix/386ix/config.h ||
  497. echo 'restore of dmake/unix/386ix/config.h failed'
  498. Wc_c="`wc -c < 'dmake/unix/386ix/config.h'`"
  499. test 1998 -eq "$Wc_c" ||
  500.     echo 'dmake/unix/386ix/config.h: original size 1998, current size' "$Wc_c"
  501. rm -f _shar_wnt_.tmp
  502. fi
  503. # ============= dmake/unix/386ix/config.mk ==============
  504. if test -f 'dmake/unix/386ix/config.mk' -a X"$1" != X"-c"; then
  505.     echo 'x - skipping dmake/unix/386ix/config.mk (File already exists)'
  506.     rm -f _shar_wnt_.tmp
  507. else
  508. > _shar_wnt_.tmp
  509. sed 's/^X//' << 'SHAR_EOF' > 'dmake/unix/386ix/config.mk' &&
  510. # This is the 386IX UNIX configuration file for DMAKE
  511. #    It simply modifies the values of SRC, and checks to see if
  512. #    OSENVIRONMENT is defined.  If so it includes the appropriate
  513. #    config.mk file.
  514. #
  515. # It also sets the values of .SOURCE.c and .SOURCE.h to include the local
  516. # directory.
  517. #
  518. osrdir := $(OS)$(DIRSEPSTR)$(OSRELEASE)
  519. X
  520. # The following are required sources
  521. OSDSRC := 
  522. .IF $(OSDSRC)
  523. X   SRC += $(OSDSRC)
  524. X   .SETDIR=$(osrdir) : $(OSDSRC)
  525. .END
  526. X
  527. .SOURCE.h : $(osrdir)
  528. X
  529. # Local configuration modifications for CFLAGS, there's local SysV includes
  530. # too.
  531. CFLAGS += -I$(osrdir)
  532. X
  533. # See if we modify anything in the lower levels.
  534. .IF $(OSENVIRONMENT) != $(NULL)
  535. X   .INCLUDE .IGNORE : $(osrdir)$(DIRSEPSTR)$(OSENVIRONMENT)$(DIRSEPSTR)config.mk
  536. .END
  537. SHAR_EOF
  538. chmod 0640 dmake/unix/386ix/config.mk ||
  539. echo 'restore of dmake/unix/386ix/config.mk failed'
  540. Wc_c="`wc -c < 'dmake/unix/386ix/config.mk'`"
  541. test 745 -eq "$Wc_c" ||
  542.     echo 'dmake/unix/386ix/config.mk: original size 745, current size' "$Wc_c"
  543. rm -f _shar_wnt_.tmp
  544. fi
  545. # ============= dmake/unix/386ix/make.sh ==============
  546. if test -f 'dmake/unix/386ix/make.sh' -a X"$1" != X"-c"; then
  547.     echo 'x - skipping dmake/unix/386ix/make.sh (File already exists)'
  548.     rm -f _shar_wnt_.tmp
  549. else
  550. > _shar_wnt_.tmp
  551. sed 's/^X//' << 'SHAR_EOF' > 'dmake/unix/386ix/make.sh' &&
  552. mkdir objects
  553. cc -c -I. -Iunix -Iunix/386ix -O infer.c
  554. mv infer.o objects
  555. cc -c -I. -Iunix -Iunix/386ix -O make.c
  556. mv make.o objects
  557. cc -c -I. -Iunix -Iunix/386ix -O stat.c
  558. mv stat.o objects
  559. cc -c -I. -Iunix -Iunix/386ix -O expand.c
  560. mv expand.o objects
  561. cc -c -I. -Iunix -Iunix/386ix -O dmstring.c
  562. mv dmstring.o objects
  563. cc -c -I. -Iunix -Iunix/386ix -O hash.c
  564. mv hash.o objects
  565. cc -c -I. -Iunix -Iunix/386ix -O dag.c
  566. mv dag.o objects
  567. cc -c -I. -Iunix -Iunix/386ix -O dmake.c
  568. mv dmake.o objects
  569. cc -c -I. -Iunix -Iunix/386ix -O path.c
  570. mv path.o objects
  571. cc -c -I. -Iunix -Iunix/386ix -O imacs.c
  572. mv imacs.o objects
  573. cc -c -I. -Iunix -Iunix/386ix -O sysintf.c
  574. mv sysintf.o objects
  575. cc -c -I. -Iunix -Iunix/386ix -O parse.c
  576. mv parse.o objects
  577. cc -c -I. -Iunix -Iunix/386ix -O getinp.c
  578. mv getinp.o objects
  579. cc -c -I. -Iunix -Iunix/386ix -O quit.c
  580. mv quit.o objects
  581. cc -c -I. -Iunix -Iunix/386ix -O state.c
  582. mv state.o objects
  583. cc -c -I. -Iunix -Iunix/386ix -O basename.c
  584. mv basename.o objects
  585. cc -c -I. -Iunix -Iunix/386ix -O dmdump.c
  586. mv dmdump.o objects
  587. cc -c -I. -Iunix -Iunix/386ix -O macparse.c
  588. mv macparse.o objects
  589. cc -c -I. -Iunix -Iunix/386ix -O rulparse.c
  590. mv rulparse.o objects
  591. cc -c -I. -Iunix -Iunix/386ix -O percent.c
  592. mv percent.o objects
  593. cc -c -I. -Iunix -Iunix/386ix -O function.c
  594. mv function.o objects
  595. cc -c -I. -Iunix -Iunix/386ix -O unix/arlib.c
  596. mv arlib.o objects
  597. cc -c -I. -Iunix -Iunix/386ix -O unix/dirbrk.c
  598. mv dirbrk.o objects
  599. cc -c -I. -Iunix -Iunix/386ix -O unix/rmprq.c
  600. mv rmprq.o objects
  601. cc -c -I. -Iunix -Iunix/386ix -O unix/ruletab.c
  602. mv ruletab.o objects
  603. cc -c -I. -Iunix -Iunix/386ix -O unix/runargv.c
  604. mv runargv.o objects
  605. cc  -o dmake  objects/infer.o objects/make.o objects/stat.o objects/expand.o objects/dmstring.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/state.o objects/basename.o objects/dmdump.o objects/macparse.o objects/rulparse.o objects/percent.o objects/function.o objects/arlib.o objects/dirbrk.o objects/rmprq.o objects/ruletab.o objects/runargv.o 
  606. cp unix/386ix/startup.mk startup.mk
  607. SHAR_EOF
  608. chmod 0640 dmake/unix/386ix/make.sh ||
  609. echo 'restore of dmake/unix/386ix/make.sh failed'
  610. Wc_c="`wc -c < 'dmake/unix/386ix/make.sh'`"
  611. test 2126 -eq "$Wc_c" ||
  612.     echo 'dmake/unix/386ix/make.sh: original size 2126, current size' "$Wc_c"
  613. rm -f _shar_wnt_.tmp
  614. fi
  615. # ============= dmake/unix/386ix/public.h ==============
  616. if test -f 'dmake/unix/386ix/public.h' -a X"$1" != X"-c"; then
  617.     echo 'x - skipping dmake/unix/386ix/public.h (File already exists)'
  618.     rm -f _shar_wnt_.tmp
  619. else
  620. > _shar_wnt_.tmp
  621. sed 's/^X//' << 'SHAR_EOF' > 'dmake/unix/386ix/public.h' &&
  622. /* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/unix/386ix/RCS/public.h,v 1.1 91/05/06 15:27:45 dvadura Exp Locker: dvadura $
  623. -- WARNING  -- This file is AUTOMATICALLY GENERATED DO NOT EDIT IT
  624. --
  625. -- SYNOPSIS -- Local functions exported to be visible by others.
  626. --
  627. -- DESCRIPTION
  628. --      This file is generated by 'genpub'.  Function declarations
  629. --      that appear in this file are extracted by 'genpub' from
  630. --      source files.  Any function in the source file whose definition
  631. --      appears like:
  632. --
  633. --          PUBLIC return_type
  634. --          function( arg_list );
  635. --          type_expr1 arg1;
  636. --          ...
  637. --
  638. --      has its definition extracted and a line of the form:
  639. --
  640. --          return_type function ANSI((type_expr1,type_expr2,...));
  641. --
  642. --      entered into the output file.
  643. --
  644. -- AUTHOR
  645. --      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  646. --      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  647. --
  648. -- COPYRIGHT
  649. --      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
  650. -- 
  651. --      This program is free software; you can redistribute it and/or
  652. --      modify it under the terms of the GNU General Public License
  653. --      (version 1), as published by the Free Software Foundation, and
  654. --      found in the file 'LICENSE' included with this distribution.
  655. -- 
  656. --      This program is distributed in the hope that it will be useful,
  657. --      but WITHOUT ANY WARRANTY; without even the implied warrant of
  658. --      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  659. --      GNU General Public License for more details.
  660. -- 
  661. --      You should have received a copy of the GNU General Public License
  662. --      along with this program;  if not, write to the Free Software
  663. --      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  664. --
  665. -- LOG
  666. --     $Log:    public.h,v $
  667. X * Revision 1.1  91/05/06  15:27:45  dvadura
  668. X * dmake Release Version 3.7
  669. X * 
  670. */
  671. X
  672. #ifndef _DMAKE_PUBLIC_h
  673. #define _DMAKE_PUBLIC_h
  674. X
  675. void Infer_recipe ANSI((CELLPTR, CELLPTR));
  676. int Make_targets ANSI(());
  677. int Exec_commands ANSI((CELLPTR));
  678. void Pop_dir ANSI((int));
  679. void Append_line ANSI((char *, int, FILE *, char *, int, int));
  680. void Stat_target ANSI((CELLPTR, int));
  681. char * Expand ANSI((char *));
  682. char * Apply_edit ANSI((char *, char *, char *, int, int));
  683. void Map_esc ANSI((char *));
  684. char* Apply_modifiers ANSI((int, char *));
  685. char* Tokenize ANSI((char *, char *));
  686. char * _strjoin ANSI((char *, char *, int, int));
  687. char * _stradd ANSI((char *, char *, int));
  688. char * _strapp ANSI((char *, char *));
  689. char * _strdup ANSI((char *));
  690. char * _strpbrk ANSI((char *, char *));
  691. char * _strspn ANSI((char *, char *));
  692. char * _strstr ANSI((char *, char *));
  693. char * _substr ANSI((char *, char *));
  694. uint16 Hash ANSI((char *, uint32 *));
  695. HASHPTR Get_name ANSI((char *, HASHPTR *, int));
  696. HASHPTR Search_table ANSI((HASHPTR *, char *, uint16 *, uint32 *));
  697. HASHPTR Def_macro ANSI((char *, char *, int));
  698. CELLPTR Def_cell ANSI((char *));
  699. LINKPTR Add_prerequisite ANSI((CELLPTR, CELLPTR, int, int));
  700. void Clear_prerequisites ANSI((CELLPTR));
  701. int Test_circle ANSI((CELLPTR, int));
  702. STRINGPTR Def_recipe ANSI((char *, STRINGPTR, int, int));
  703. t_attr Rcp_attribute ANSI((char *));
  704. int main ANSI((int, char **));
  705. FILE * Openfile ANSI((char *, int, int));
  706. FILE * Closefile ANSI(());
  707. FILE * Search_file ANSI((char *, char **));
  708. char * Filename ANSI(());
  709. void No_ram ANSI(());
  710. int Usage ANSI((int));
  711. int Version ANSI(());
  712. char * Get_suffix ANSI((char *));
  713. char * Build_path ANSI((char *, char *));
  714. void Make_rules ANSI(());
  715. void Create_macro_vars ANSI(());
  716. time_t Do_stat ANSI((char *, char *, char **));
  717. int Do_touch ANSI((char *, char *, char **));
  718. void Void_lib_cache ANSI((char *, char *));
  719. time_t Do_time ANSI(());
  720. int Do_cmnd ANSI((char *, int, int, CELLPTR, int, int, int));
  721. char ** Pack_argv ANSI((int, int, char *));
  722. char * Read_env_string ANSI((char *));
  723. int Write_env_string ANSI((char *, char *));
  724. void ReadEnvironment ANSI(());
  725. void Catch_signals ANSI((void (*)()));
  726. void Clear_signals ANSI(());
  727. void Prolog ANSI((int, char* []));
  728. void Epilog ANSI((int));
  729. char * Get_current_dir ANSI(());
  730. int Set_dir ANSI((char*));
  731. char Get_switch_char ANSI(());
  732. FILE* Get_temp ANSI((char **, char *, int));
  733. FILE * Start_temp ANSI((char *, CELLPTR, char **));
  734. void Open_temp_error ANSI((char *, char *));
  735. void Link_temp ANSI((CELLPTR, FILE *, char *));
  736. void Close_temp ANSI((CELLPTR, FILE *));
  737. void Unlink_temp_files ANSI((CELLPTR));
  738. void Handle_result ANSI((int, int, int, CELLPTR));
  739. void Update_time_stamp ANSI((CELLPTR));
  740. void Parse ANSI((FILE *));
  741. int Get_line ANSI((char *, FILE *));
  742. char * Do_comment ANSI((char *, char **, int));
  743. char * Get_token ANSI((TKSTRPTR, char *, int));
  744. void Quit ANSI(());
  745. void Read_state ANSI(());
  746. void Write_state ANSI(());
  747. int Check_state ANSI((CELLPTR, STRINGPTR *, int));
  748. char* basename ANSI((char *));
  749. void Dump ANSI(());
  750. void Dump_recipe ANSI((STRINGPTR));
  751. int Parse_macro ANSI((char *, int));
  752. int Macro_op ANSI((char *));
  753. int Parse_rule_def ANSI((int *));
  754. int Rule_op ANSI((char *));
  755. void Add_recipe_to_list ANSI((char *, int, int));
  756. void Bind_rules_to_targets ANSI((int));
  757. int Set_group_attributes ANSI((char *));
  758. DFALINKPTR Match_dfa ANSI((char *));
  759. void Check_circle_dfa ANSI(());
  760. void Add_nfa ANSI((char *));
  761. char * Exec_function ANSI((char *));
  762. time_t seek_arch ANSI((char *, char *));
  763. int If_root_path ANSI((char *));
  764. void Remove_prq ANSI((CELLPTR));
  765. int runargv ANSI((CELLPTR, int, int, int, int, char *));
  766. int Wait_for_child ANSI((int, int));
  767. void Clean_up_processes ANSI(());
  768. X
  769. #endif
  770. SHAR_EOF
  771. chmod 0640 dmake/unix/386ix/public.h ||
  772. echo 'restore of dmake/unix/386ix/public.h failed'
  773. Wc_c="`wc -c < 'dmake/unix/386ix/public.h'`"
  774. test 5521 -eq "$Wc_c" ||
  775.     echo 'dmake/unix/386ix/public.h: original size 5521, current size' "$Wc_c"
  776. rm -f _shar_wnt_.tmp
  777. fi
  778. # ============= dmake/unix/386ix/startup.mk ==============
  779. if test -f 'dmake/unix/386ix/startup.mk' -a X"$1" != X"-c"; then
  780.     echo 'x - skipping dmake/unix/386ix/startup.mk (File already exists)'
  781.     rm -f _shar_wnt_.tmp
  782. else
  783. > _shar_wnt_.tmp
  784. sed 's/^X//' << 'SHAR_EOF' > 'dmake/unix/386ix/startup.mk' &&
  785. # Generic UNIX DMAKE startup file.  Customize to suit your needs.
  786. # Should work for both SYSV, and BSD 4.3
  787. # See the documentation for a description of internally defined macros.
  788. #
  789. # Disable warnings for macros redefined here that were given
  790. # on the command line.
  791. __.SILENT := $(.SILENT)
  792. .SILENT   := yes
  793. X
  794. # Configuration parameters for DMAKE startup.mk file
  795. # Set these to NON-NULL if you wish to turn the parameter on.
  796. _HAVE_RCS    := yes        # yes => RCS  is installed.
  797. _HAVE_SCCS    := yes        # yes => SCCS is installed.
  798. X
  799. # Applicable suffix definitions
  800. A := .a        # Libraries
  801. E :=        # Executables
  802. F := .f        # Fortran
  803. O := .o        # Objects
  804. P := .p        # Pascal
  805. S := .s        # Assembler sources
  806. V := ,v        # RCS suffix
  807. X
  808. # Recipe execution configurations
  809. SHELL        := /bin/sh
  810. SHELLFLAGS    := -ce
  811. GROUPSHELL    := $(SHELL)
  812. GROUPFLAGS    := 
  813. SHELLMETAS    := |();&<>?*][$$:\\#`'"
  814. GROUPSUFFIX    :=
  815. DIVFILE         = $(TMPFILE)
  816. X
  817. # Standard C-language command names and flags
  818. X   CPP       := /lib/cpp        # C-preprocessor
  819. X   CC      := cc        # C-compiler and flags
  820. X   CFLAGS  +=
  821. X
  822. X   AS      := as        # Assembler and flags
  823. X   ASFLAGS += 
  824. X
  825. X   LD       = $(CC)        # Loader and flags
  826. X   LDFLAGS +=
  827. X   LDLIBS   =
  828. X
  829. # Definition of $(MAKE) macro for recursive makes.
  830. X   MAKE = $(MAKECMD) $(MFLAGS)
  831. X
  832. # Definition of Print command for this system.
  833. X   PRINT = lpr
  834. X
  835. # Language and Parser generation Tools and their flags
  836. X   YACC      := yacc        # standard yacc
  837. X   YFLAGS +=
  838. X   YTAB      := y.tab        # yacc output files name stem.
  839. X
  840. X   LEX      := lex        # standard lex
  841. X   LFLAGS +=
  842. X   LEXYY  := lex.yy        # lex output file
  843. X
  844. # Other Compilers, Tools and their flags
  845. X   PC    := pc            # pascal compiler
  846. X   RC    := f77            # ratfor compiler
  847. X   FC    := f77            # fortran compiler
  848. X
  849. X   CO       := co        # check out for RCS
  850. X   COFLAGS += -q
  851. X
  852. X   AR     := ar            # archiver
  853. X   ARFLAGS+= ruv
  854. X
  855. X   RM       := /bin/rm        # remove a file command
  856. X   RMFLAGS +=
  857. X
  858. # Implicit generation rules for making inferences.
  859. # We don't provide .yr or .ye rules here.  They're obsolete.
  860. # Rules for making *$O
  861. X   %$O : %.c ; $(CC) $(CFLAGS) -c $<
  862. X   %$O : %$P ; $(PC) $(PFLAGS) -c $<
  863. X   %$O : %$S ; $(AS) $(ASFLAGS) $<
  864. X   %$O : %.cl ; class -c $<
  865. X   %$O : %.e %.r %.F %$F
  866. X    $(FC) $(RFLAGS) $(EFLAGS) $(FFLAGS) -c $<
  867. X
  868. # Executables
  869. X   %$E : %$O ; $(LD) $(LDFLAGS) -o $@ $< $(LDLIBES)
  870. X
  871. # lex and yacc rules
  872. X   %.c : %.y ; $(YACC)  $(YFLAGS) $<; mv $(YTAB).c $@
  873. X   %.c : %.l ; $(LEX)   $(LFLAGS) $<; mv $(LEXYY).c $@
  874. X
  875. # This rule tells how to make *.out from it's immediate list of prerequisites
  876. # UNIX only.
  877. X   %.out :; $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)
  878. X
  879. # RCS support
  880. .IF $(_HAVE_RCS)
  881. X   % : %$V $$(@:d)RCS/$$(@:f)$V;- $(CO) $(COFLAGS) $@
  882. X   .NOINFER : %$V $$(@:d)RCS/$$(@:f)$V
  883. .END
  884. X
  885. # SCCS support
  886. .IF $(_HAVE_SCCS)
  887. X   % : s.% ; get $@
  888. X   .NOINFER : s.%
  889. .END
  890. X
  891. # Recipe to make archive files.
  892. %$A :
  893. [
  894. X   $(AR) $(ARFLAGS) $@ $?
  895. X   $(RM) $(RMFLAGS) $?
  896. X   ranlib $@
  897. ]
  898. X
  899. # DMAKE uses this recipe to remove intermediate targets
  900. .REMOVE :; $(RM) -f $<
  901. X
  902. # AUGMAKE extensions for SYSV compatibility
  903. @B = $(@:b)
  904. @D = $(@:d)
  905. @F = $(@:f)
  906. *B = $(*:b)
  907. *D = $(*:d)
  908. *F = $(*:f)
  909. <B = $(<:b)
  910. <D = $(<:d)
  911. <F = $(<:f)
  912. ?B = $(?:b)
  913. ?F = $(?:f)
  914. ?D = $(?:d)
  915. X
  916. # Turn warnings back to previous setting.
  917. .SILENT := $(__.SILENT)
  918. X
  919. # Local startup file if any
  920. .INCLUDE .IGNORE: "_startup.mk"
  921. SHAR_EOF
  922. chmod 0640 dmake/unix/386ix/startup.mk ||
  923. echo 'restore of dmake/unix/386ix/startup.mk failed'
  924. Wc_c="`wc -c < 'dmake/unix/386ix/startup.mk'`"
  925. test 3221 -eq "$Wc_c" ||
  926.     echo 'dmake/unix/386ix/startup.mk: original size 3221, current size' "$Wc_c"
  927. rm -f _shar_wnt_.tmp
  928. fi
  929. # ============= dmake/unix/386ix/stdarg.h ==============
  930. if test -f 'dmake/unix/386ix/stdarg.h' -a X"$1" != X"-c"; then
  931.     echo 'x - skipping dmake/unix/386ix/stdarg.h (File already exists)'
  932.     rm -f _shar_wnt_.tmp
  933. else
  934. > _shar_wnt_.tmp
  935. sed 's/^X//' << 'SHAR_EOF' > 'dmake/unix/386ix/stdarg.h' &&
  936. /*
  937. X * stdarg.h
  938. X *
  939. X * defines ANSI style macros for accessing arguments of a function which takes
  940. X * a variable number of arguments
  941. X *
  942. X */
  943. X
  944. #if !defined(__STDARG)
  945. #define __STDARG
  946. X
  947. typedef char *va_list;
  948. X
  949. #define va_dcl int va_alist
  950. #define va_start(ap,v)  ap = (va_list)&va_alist
  951. #define va_arg(ap,t)    ((t*)(ap += sizeof(t)))[-1]
  952. #define va_end(ap)      ap = NULL
  953. #endif
  954. SHAR_EOF
  955. chmod 0640 dmake/unix/386ix/stdarg.h ||
  956. echo 'restore of dmake/unix/386ix/stdarg.h failed'
  957. Wc_c="`wc -c < 'dmake/unix/386ix/stdarg.h'`"
  958. test 373 -eq "$Wc_c" ||
  959.     echo 'dmake/unix/386ix/stdarg.h: original size 373, current size' "$Wc_c"
  960. rm -f _shar_wnt_.tmp
  961. fi
  962. # ============= dmake/unix/386ix/stdlib.h ==============
  963. if test -f 'dmake/unix/386ix/stdlib.h' -a X"$1" != X"-c"; then
  964.     echo 'x - skipping dmake/unix/386ix/stdlib.h (File already exists)'
  965.     rm -f _shar_wnt_.tmp
  966. else
  967. > _shar_wnt_.tmp
  968. sed 's/^X//' << 'SHAR_EOF' > 'dmake/unix/386ix/stdlib.h' &&
  969. #ifndef _STDLIB_INCLUDED_
  970. #define _STDLIB_INCLUDED_
  971. X
  972. extern /*GOTO*/ _exit();
  973. extern /*GOTO*/ exit();
  974. extern /*GOTO*/ abort();
  975. extern int system();
  976. extern char *getenv();
  977. extern char *calloc();
  978. extern char *malloc();
  979. extern char *realloc();
  980. extern free();
  981. extern int errno;
  982. X
  983. #ifndef EIO
  984. #    include <errno.h>
  985. #endif
  986. X
  987. #endif /* _STDLIB_INCLUDED_ */
  988. SHAR_EOF
  989. chmod 0640 dmake/unix/386ix/stdlib.h ||
  990. echo 'restore of dmake/unix/386ix/stdlib.h failed'
  991. Wc_c="`wc -c < 'dmake/unix/386ix/stdlib.h'`"
  992. test 346 -eq "$Wc_c" ||
  993.     echo 'dmake/unix/386ix/stdlib.h: original size 346, current size' "$Wc_c"
  994. rm -f _shar_wnt_.tmp
  995. fi
  996. # ============= dmake/unix/386ix/time.h ==============
  997. if test -f 'dmake/unix/386ix/time.h' -a X"$1" != X"-c"; then
  998.     echo 'x - skipping dmake/unix/386ix/time.h (File already exists)'
  999.     rm -f _shar_wnt_.tmp
  1000. else
  1001. > _shar_wnt_.tmp
  1002. sed 's/^X//' << 'SHAR_EOF' > 'dmake/unix/386ix/time.h' &&
  1003. /*
  1004. ** Berkeley get this wrong!
  1005. */
  1006. #ifndef    TIME_h
  1007. #define    TIME_h
  1008. X
  1009. typedef    long    time_t;    /* this is the thing we use */
  1010. X
  1011. #endif    TIME_h
  1012. X
  1013. SHAR_EOF
  1014. chmod 0640 dmake/unix/386ix/time.h ||
  1015. echo 'restore of dmake/unix/386ix/time.h failed'
  1016. Wc_c="`wc -c < 'dmake/unix/386ix/time.h'`"
  1017. test 133 -eq "$Wc_c" ||
  1018.     echo 'dmake/unix/386ix/time.h: original size 133, current size' "$Wc_c"
  1019. rm -f _shar_wnt_.tmp
  1020. fi
  1021. # ============= dmake/unix/arlib.c ==============
  1022. if test -f 'dmake/unix/arlib.c' -a X"$1" != X"-c"; then
  1023.     echo 'x - skipping dmake/unix/arlib.c (File already exists)'
  1024.     rm -f _shar_wnt_.tmp
  1025. else
  1026. > _shar_wnt_.tmp
  1027. sed 's/^X//' << 'SHAR_EOF' > 'dmake/unix/arlib.c' &&
  1028. /* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/unix/RCS/arlib.c,v 1.1 91/05/06 15:27:25 dvadura Exp $
  1029. -- SYNOPSIS -- Unix archive manipulation code.
  1030. -- 
  1031. -- DESCRIPTION
  1032. --     Originally this code was provided by Eric Gisin of MKS.  I took
  1033. --    his code and completely rewrote it adding cacheing of lib members
  1034. --    and other various optimizations.  I kept the overal functional
  1035. --    idea of the library routines as they are similar to those in GNU
  1036. --    make and felt it advantageous to maintain a similar interface.
  1037. --
  1038. -- AUTHOR
  1039. --      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  1040. --      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  1041. --
  1042. -- COPYRIGHT
  1043. --      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
  1044. -- 
  1045. --      This program is free software; you can redistribute it and/or
  1046. --      modify it under the terms of the GNU General Public License
  1047. --      (version 1), as published by the Free Software Foundation, and
  1048. --      found in the file 'LICENSE' included with this distribution.
  1049. -- 
  1050. --      This program is distributed in the hope that it will be useful,
  1051. --      but WITHOUT ANY WARRANTY; without even the implied warrant of
  1052. --      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1053. --      GNU General Public License for more details.
  1054. -- 
  1055. --      You should have received a copy of the GNU General Public License
  1056. --      along with this program;  if not, write to the Free Software
  1057. --      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1058. --
  1059. -- LOG
  1060. --     $Log:    arlib.c,v $
  1061. X * Revision 1.1  91/05/06  15:27:25  dvadura
  1062. X * dmake Release Version 3.7
  1063. X * 
  1064. */
  1065. X
  1066. #include <ar.h>
  1067. #include "extern.h"
  1068. #include "sysintf.h"
  1069. X
  1070. /* By defining the defines below it is possible to configure the library
  1071. X * code for library cacheing/non-cacheing, ASCII archive headers, and a full
  1072. X * decode of the ar_hdr fields in the scan_ar function. */
  1073. X
  1074. #ifndef ASCARCH
  1075. #define ASCARCH            1    /* ASCII time stored in archive    */
  1076. #endif
  1077. X
  1078. #ifndef LC
  1079. #define LC            1    /* Turn on library cacheing    */
  1080. #endif
  1081. X
  1082. #ifndef DECODE_ALL_AR_FIELDS
  1083. #define DECODE_ALL_AR_FIELDS    0    /* decode only fields make needs*/
  1084. #endif
  1085. X
  1086. #if LC
  1087. #  define FOUND_MEMBER    FALSE
  1088. #else
  1089. #  define FOUND_MEMBER    TRUE
  1090. #  define _cache_member(a, b, c)
  1091. #  define _check_cache(a, b, c, d)    FALSE
  1092. #endif
  1093. X
  1094. #define MAXFNAME      255       /* Max length of member name    */
  1095. #define    MAXMNAME    8    /* Max module name < MAXFNAME    */
  1096. X
  1097. X
  1098. /* This struct is used to pass the library and member inrmation about the
  1099. X * routines that perform the library seeking/cacheing */
  1100. struct ar_args {
  1101. X   char   *lib;
  1102. X   char   *member;
  1103. X   time_t time;
  1104. };
  1105. X
  1106. X
  1107. typedef struct AR {
  1108. X   char    ar_name[MAXFNAME+1];      /* File name */
  1109. X   long    ar_size;                  /* Size in bytes */
  1110. X   time_t  ar_time;                  /* Modification time */
  1111. X
  1112. #ifdef DOS
  1113. X   char    ar_modname[MAXMNAME+1];   /* DOS module name */
  1114. #endif
  1115. X
  1116. #if DECODE_ALL_AR_FIELDS
  1117. X   uint16  ar_mode;                  /* File mode */
  1118. X   uint16  ar_uid;                     /* File owner */
  1119. X   uint16  ar_gid;                   /* File group owner */
  1120. #endif
  1121. } AR, *ARPTR;
  1122. X
  1123. X
  1124. static int ar_scan  ANSI((FILE *,
  1125. X              int (*) ANSI((FILE *, struct AR *, struct ar_args *)),
  1126. X              struct ar_args *));
  1127. static int ar_touch ANSI(( FILE *, time_t ));
  1128. static int time_function  ANSI(( FILE *, struct AR *, struct ar_args * ));
  1129. static int touch_function ANSI(( FILE *, struct AR *, struct ar_args * ));
  1130. X
  1131. #if LC
  1132. static int _cache_member ANSI((char *, char *, time_t));
  1133. static int _check_cache  ANSI((char *, char *, time_t *, int));
  1134. #endif
  1135. X
  1136. /* decoded archive header */
  1137. static AR    _ar;
  1138. static off_t arhdroffset;  /* member seek offset */
  1139. X
  1140. X
  1141. PUBLIC time_t
  1142. seek_arch(name, lib)/*
  1143. ======================
  1144. X   Look for module 'name' inside 'lib'.  If compiled with cacheing then first
  1145. X   check to see if the specified lib is cached.  If so then return that time
  1146. X   stamp instead of looking into the library. */
  1147. char    *name;
  1148. char     *lib;
  1149. {
  1150. X   FILE   *f;
  1151. X   int    rv;
  1152. X   time_t mtime;
  1153. X   struct ar_args args;
  1154. X
  1155. X   /* Check the cache first (if there is a cache) */
  1156. X   if( _check_cache(name, lib, &mtime, FALSE) )  return( mtime );
  1157. X
  1158. X   /* Open the lib file and perform the scan of the members, looking
  1159. X    * for our particular member.  If cacheing is enabled it will be
  1160. X    * taken care of automatically during the scan. */
  1161. X
  1162. X   args.lib    = lib;
  1163. X   args.member = name;
  1164. X   args.time   = (time_t)0L;
  1165. X
  1166. X   if( (f = fopen(lib, "r")) == NIL(FILE) ) return( (time_t)0L );
  1167. X   rv = ar_scan(f, time_function, &args );
  1168. X   fclose( f );
  1169. X
  1170. X   if( rv < 0 ) Fatal("(%s): Invalid library format", lib);
  1171. X
  1172. X   return( args.time );
  1173. }
  1174. X
  1175. X
  1176. int
  1177. touch_arch(name, lib)/*
  1178. =======================
  1179. X   Look for module 'name' inside 'lib'.  If compiled with cacheing then first
  1180. X   check to see if the specified lib is cached.  If so then set that time
  1181. X   stamp and write it into the library.  Returns 0 on success, non-zero
  1182. X   on failure. */
  1183. char   *name;
  1184. char   *lib;
  1185. {
  1186. X   FILE   *f;
  1187. X   int    rv;
  1188. X   struct ar_args args;
  1189. X
  1190. X   /* Open the lib file and perform the scan of the members, looking
  1191. X    * for our particular member.  If cacheing is enabled it will be
  1192. X    * taken care of automatically during the scan. */
  1193. X
  1194. X   args.lib    = lib;
  1195. X   args.member = name;
  1196. X   args.time   = (time_t)0L;
  1197. X
  1198. X   if( (f = fopen(lib, "r+")) == NIL(FILE) ) return( (time_t)1L );
  1199. X   rv = ar_scan(f, touch_function, &args );
  1200. X   fclose( f );
  1201. X
  1202. X   if( rv < 0 ) Fatal("(%s): Invalid library format", lib);
  1203. X
  1204. X   return( 0 );
  1205. }
  1206. X
  1207. X
  1208. X
  1209. static int
  1210. time_function(f, arp, argp)/*
  1211. =============================
  1212. X   get library member's time, if it matches than return it in argp, if
  1213. X   cacheing is enabled than cache the library members also. */
  1214. FILE           *f;      /* library file          */
  1215. struct AR      *arp;    /* library member header */
  1216. struct ar_args *argp;
  1217. {
  1218. X   int rv = _cache_member( arp->ar_name, argp->lib, arp->ar_time );
  1219. X
  1220. X   if( strcmp(argp->member, arp->ar_name) == 0 ) {
  1221. X      argp->time = arp->ar_time;
  1222. X
  1223. X      if( arp->ar_time == 0 && !(Glob_attr & A_SILENT) )
  1224. X         Warning( "(%s): Can't extract library member timestamp; using EPOCH",
  1225. X              argp->member);
  1226. X
  1227. X      return( rv );  /* 1 => no cacheing, 0 => cacheing */
  1228. X   }
  1229. X
  1230. X   return( FALSE ); /* continue scan */
  1231. }
  1232. X
  1233. X
  1234. X
  1235. static int
  1236. touch_function(f, arp, argp)/*
  1237. ==============================
  1238. X   Update library member's time stamp, and write new time value into cache
  1239. X   if required. */
  1240. FILE           *f;      /* library file */
  1241. struct AR      *arp;    /* library member header */
  1242. struct ar_args *argp;
  1243. {
  1244. X   extern time_t time ANSI(( time_t * ));
  1245. X   time_t now = time((time_t*) NULL);  /* Current time.          */
  1246. X
  1247. X   if( strcmp(argp->member, arp->ar_name) == 0 ) {
  1248. X      _check_cache( argp->member, argp->lib, &now, TRUE );
  1249. X      ar_touch(f, now );
  1250. X
  1251. X      return( TRUE );
  1252. X   }
  1253. X
  1254. X   return( FALSE ); /* continue scan */
  1255. }
  1256. X
  1257. X
  1258. X
  1259. X
  1260. static int
  1261. ar_scan(f, function, arg)/*
  1262. ===========================
  1263. X   Scan the opened archive, and call the given function for each member found.
  1264. X   The function will be called with the file positioned at the beginning of
  1265. X   the member and it can read up to arp->ar_size bytes of the archive member.
  1266. X   If the function returns 1, we stop and return 1.  We return 0 at the end
  1267. X   of the archive, or -1 if the archive has invalid format.  This interface
  1268. X   is more general than required by "make", but it can be used by other
  1269. X   utilities.  */
  1270. register FILE *f;
  1271. int      (*function) ANSI((FILE *, struct AR *, struct ar_args *));
  1272. struct   ar_args *arg;
  1273. {
  1274. X   extern long atol ANSI((char *));
  1275. X   register char *p;
  1276. X   struct ar_hdr arhdr;   /* archive member header   */
  1277. X   int         nsize;   /* size of member name     */
  1278. #if defined(_AIX)
  1279. X   struct fl_hdr flhdr;   /* archive file header     */
  1280. X   char   magic[SAIAMAG]; /* size of magic string    */
  1281. #else
  1282. #if ASCARCH
  1283. X   char magic[SARMAG];
  1284. #else
  1285. X   unsigned short word;
  1286. #endif
  1287. #endif
  1288. X
  1289. X   fseek( f, 0L, 0 );    /* Start at the beginning of the archive file */
  1290. X
  1291. #if ASCARCH
  1292. #if defined(_AIX)
  1293. X   fread( (char *)&flhdr, sizeof(flhdr), 1, f );
  1294. X   if( strncmp(flhdr.fl_magic,AIAMAG, SAIAMAG) != 0 ) return(-1);
  1295. X   fseek(f, atol(flhdr.fl_fstmoff), 0 ); /* postition to first member */
  1296. #else
  1297. X   fread( magic, sizeof(magic), 1, f );
  1298. X   if( strncmp(magic, ARMAG, SARMAG) != 0 ) return( -1 );
  1299. #endif
  1300. #else
  1301. X   fread( (char*)&word, sizeof(word), 1, f );
  1302. X   if( word != ARMAG ) return( -1 );
  1303. #endif
  1304. X
  1305. X   /* scan the library, calling `function' for each member
  1306. X    */
  1307. X   while( 1 ) {
  1308. X      arhdroffset = ftell(f);
  1309. #if defined(_AIX)
  1310. X      if( fread((char*)&arhdr,sizeof(arhdr)-sizeof(arhdr._ar_name),1,f)!=1)
  1311. X         break;
  1312. X      nsize = atoi(arhdr.ar_namlen);
  1313. X      fseek(f, arhdroffset+(unsigned long)(((struct ar_hdr *)0)->_ar_name.ar_name), 0);
  1314. X      if( fread((char*)_ar.ar_name,nsize,1,f)!=1)
  1315. X         break;
  1316. X      _ar.ar_name[nsize]='\0';
  1317. #else
  1318. X      if( fread((char*) &arhdr, sizeof(arhdr), 1, f) != 1 ) break;
  1319. X      strncpy(_ar.ar_name, arhdr.ar_name, nsize = sizeof(arhdr.ar_name));
  1320. #endif
  1321. X
  1322. X      for( p = &_ar.ar_name[nsize];
  1323. X           --p >= _ar.ar_name && *p == ' ';);
  1324. X
  1325. X      p[1] = '\0';
  1326. X      if( *p == '/' ) *p = 0;     /* SysV has trailing '/' */
  1327. X
  1328. #if !defined(_AIX)
  1329. #if ASCARCH
  1330. X      if( strncmp(arhdr.ar_fmag, ARFMAG, sizeof(arhdr.ar_fmag)) != 0 )
  1331. X         return( -1 );
  1332. X      _ar.ar_time = atol(arhdr.ar_date);
  1333. X      _ar.ar_size = atol(arhdr.ar_size);
  1334. #else
  1335. X      _ar.ar_time = arhdr.ar_date;
  1336. X      _ar.ar_size = arhdr.ar_size;
  1337. #endif
  1338. #else
  1339. #if ASCARCH
  1340. X      _ar.ar_time = atol(arhdr.ar_date);
  1341. X      _ar.ar_size = atol(arhdr.ar_nxtmem);
  1342. #else
  1343. X      _ar.ar_time = arhdr.ar_date;
  1344. X      _ar.ar_size = arhdr.ar_nxtmem;
  1345. #endif
  1346. #endif
  1347. X
  1348. X
  1349. #if DECODE_ALL_AR_FIELDS
  1350. #if ASCARCH
  1351. X      _ar.ar_mode = atoi(arhdr.ar_mode);
  1352. X      _ar.ar_uid  = atoi(arhdr.ar_uid);
  1353. X      _ar.ar_gid  = atoi(arhdr.ar_gid);
  1354. #else
  1355. X      _ar.ar_mode = arhdr.ar_mode;
  1356. X      _ar.ar_uid = arhdr.ar_uid;
  1357. X      _ar.ar_gid = arhdr.ar_gid;
  1358. #endif
  1359. #endif
  1360. X
  1361. X      if( (*function)(f, &_ar, arg) ) return( 1 );
  1362. #if defined(_AIX)
  1363. X      if( _ar.ar_size == 0L ) break;
  1364. X      fseek( f, (long) _ar.ar_size, 0 );
  1365. #else
  1366. X      fseek( f, arhdroffset + sizeof(arhdr) + (_ar.ar_size+1 & ~1L), 0 );
  1367. #endif
  1368. X   }
  1369. X
  1370. #if !defined(_AIX)
  1371. X   if( !feof(f) ) return( -1 );
  1372. #endif
  1373. X   return 0;
  1374. }
  1375. X
  1376. X
  1377. X
  1378. static int
  1379. ar_touch( f, now )/*
  1380. ====================
  1381. X   touch module header timestamp. */
  1382. FILE   *f;
  1383. time_t now;
  1384. {
  1385. X   struct ar_hdr arhdr;                /* external archive header */
  1386. SHAR_EOF
  1387. true || echo 'restore of dmake/unix/arlib.c failed'
  1388. fi
  1389. echo 'End of part 32, continue with part 33'
  1390. echo 33 > _shar_seq_.tmp
  1391. exit 0
  1392.  
  1393. exit 0 # Just in case...
  1394. -- 
  1395. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1396. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1397. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1398. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1399.