home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume31 / mkskel / part01 < prev    next >
Encoding:
Text File  |  1992-08-25  |  36.8 KB  |  1,356 lines

  1. Newsgroups: comp.sources.misc
  2. From: Michel.Fingerhut@ircam.fr (Michel Fingerhut)
  3. Subject:  v31i127: mkskel - create a skeleton for commonly used files, Part01/01
  4. Message-ID: <1992Aug26.150548.5216@sparky.imd.sterling.com>
  5. X-Md4-Signature: b7b5aedc1f09ff3b58aa4b957d1dc665
  6. Date: Wed, 26 Aug 1992 15:05:48 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: Michel.Fingerhut@ircam.fr (Michel Fingerhut)
  10. Posting-number: Volume 31, Issue 127
  11. Archive-name: mkskel/part01
  12. Environment: Perl
  13.  
  14. Mkskel is a perl script used to create a "skeleton" file for commonly used
  15. files, such as C programs, Makefiles, etc..., where a standard format is
  16. required (e.g., including copyright, version control ...).  It is easy to
  17. tailor, and easier to use:
  18.  
  19.     Create a skeletal C file:
  20.  
  21.     mkskel t.c
  22.  
  23.     Create a skeletal Makefile for a target library from sources:
  24.  
  25.     mkskel Makefile mylib.a *.c *.h *.[1-8]
  26.  
  27.     Same, but for executable target:
  28.  
  29.     mkskel Makefile myprog *.c *.h *.[1-8]
  30.  
  31. -------------------------------- cut here -------------------------------------
  32. #! /bin/sh
  33. # This is a shell archive.  Remove anything before this line, then feed it
  34. # into a shell via "sh file" or similar.  To overwrite existing files,
  35. # type "sh file -c".
  36. # Contents:  README Makefile lib lib/COPYRIGHT lib/Makefile
  37. #   lib/skel.README lib/skel.c lib/skel.cc lib/skel.csh lib/skel.h
  38. #   lib/skel.lisp lib/skel.make lib/skel.man lib/skel.perl lib/skel.sh
  39. #   mkskel.1 mkskel.pl
  40. # Wrapped by kent@sparky on Wed Aug 26 10:01:28 1992
  41. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  42. echo If this archive is complete, you will see the following message:
  43. echo '          "shar: End of archive 1 (of 1)."'
  44. if test -f 'README' -a "${1}" != "-c" ; then 
  45.   echo shar: Will not clobber existing file \"'README'\"
  46. else
  47.   echo shar: Extracting \"'README'\" \(392 characters\)
  48.   sed "s/^X//" >'README' <<'END_OF_FILE'
  49. XThis program is used to create "skeleton" files for the most common languages,
  50. Xinterpreters or data files (.h and, most notably, Makefiles).  The prototype
  51. Xfor those skeleton files are easy to create, tailor and maintain.
  52. X
  53. XINSTALLATION
  54. X
  55. XConfiguration consists in modifying a couple of variables in the mkskel.sh
  56. Xfile, together with the paths to the standard interpreters in the %langs
  57. Xarray.
  58. END_OF_FILE
  59.   if test 392 -ne `wc -c <'README'`; then
  60.     echo shar: \"'README'\" unpacked with wrong size!
  61.   fi
  62.   # end of 'README'
  63. fi
  64. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  65.   echo shar: Will not clobber existing file \"'Makefile'\"
  66. else
  67.   echo shar: Extracting \"'Makefile'\" \(1620 characters\)
  68.   sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  69. X#
  70. X#            Copyright (c) 1992 by IRCAM
  71. X#                All rights reserved.
  72. X#
  73. X#  For any information regarding this and other IRCAM software, please
  74. X#  send email to:
  75. X#                              manager@ircam.fr
  76. X#
  77. X
  78. X#
  79. X# Makefile    1.6 IRCAM 8/25/92
  80. X#
  81. X# Makefile for mkskel
  82. X#
  83. X# Modification history
  84. X#
  85. X#  5-Aug-92 - Michel Fingerhut (fingerhu@ircam.fr)
  86. X#
  87. X
  88. XMAKEFILE    := Makefile
  89. XTARGET        := mkskel
  90. XROOTDIR        := /usr/local
  91. XOWNER        := root
  92. XGROUP        := wheel
  93. X# Where executables and man pages go
  94. XBINDIR        := $(ROOTDIR)/bin
  95. XLIBDIR        := $(ROOTDIR)/lib
  96. XMANDIR        := $(ROOTDIR)/man
  97. XDESTDIR        := $(BINDIR)
  98. XSHFILES        :=  mkskel.pl 
  99. XTAPE        :=  /dev/rmt0h
  100. XMANFILES1    :=  mkskel.1 
  101. XMANFILES    :=  mkskel.1        
  102. XLIBFILES    := lib/Makefile lib/COPYRIGHT $(wildcard lib/skel.*)
  103. XINSTMANFILES    := $(addprefix $(MANDIR)/man1/, $(MANFILES1))
  104. X
  105. XSOURCE        := README $(MAKEFILE) $(MANFILES) $(DOCFILES) $(SHFILES) \
  106. X           $(OTHERS) $(INCLUDES) $(YACCFILES) $(LEXFILES) \
  107. X           $(CFILES) $(FFILES) $(ASFILES)
  108. XLISTFILES    := $(MAKEFILE) $(SHFILES) $(INCLUDES) $(YACCFILES) \
  109. X           $(LEXFILES) $(CFILES) $(FFILES) $(ASFILES)
  110. X
  111. X.PHONY: all install uninstall clean depend
  112. Xall:     $(TARGET)
  113. X
  114. Xinstall: $(DESTDIR)/$(TARGET) $(INSTMANFILES)
  115. X    cd lib; $(MAKE) install
  116. X
  117. X
  118. Xuninstall:
  119. X    rm -f $(DESTDIR)/$(TARGET) $(INSTMANFILES)
  120. X    cd lib; $(MAKE) install
  121. X
  122. Xdepend:
  123. X
  124. X$(TARGET):      $(TARGET).pl
  125. X    cat $< > $@
  126. X    chmod a+x $@
  127. X
  128. X$(DESTDIR)/$(TARGET): $(TARGET)
  129. X    install -c -o $(OWNER) -g $(GROUP) -m 0755 $< $@
  130. X
  131. X$(MANDIR)/man1/% : %
  132. X    install -c -o $(OWNER) -g $(GROUP) -m 0644 $< $@
  133. X
  134. Xshar:
  135. X    shar $(SOURCE) $(LIBFILES) > mkskel.shar
  136. Xtar:
  137. X    tar rfcb $(TAPE) 20 $(SOURCE)
  138. X
  139. Xclean:
  140. X    -rm -f $(OBJECTS)
  141. X    sccs clean
  142. X
  143. END_OF_FILE
  144.   if test 1620 -ne `wc -c <'Makefile'`; then
  145.     echo shar: \"'Makefile'\" unpacked with wrong size!
  146.   fi
  147.   # end of 'Makefile'
  148. fi
  149. if test ! -d 'lib' ; then
  150.     echo shar: Creating directory \"'lib'\"
  151.     mkdir 'lib'
  152. fi
  153. if test -f 'lib/COPYRIGHT' -a "${1}" != "-c" ; then 
  154.   echo shar: Will not clobber existing file \"'lib/COPYRIGHT'\"
  155. else
  156.   echo shar: Extracting \"'lib/COPYRIGHT'\" \(392 characters\)
  157.   sed "s/^X//" >'lib/COPYRIGHT' <<'END_OF_FILE'
  158. X$$COB
  159. X$$COM            Copyright (c) $$YEAR by $$ORG
  160. X$$COM                All rights reserved.
  161. X$$COM
  162. X$$COM  For any information regarding this and other $$ORG software, please
  163. X$$COM  send email to:
  164. X$$COM                              $$MANAGER
  165. X$$COE
  166. X
  167. X$$COB
  168. X$$COM $$FILENAME    $$IDSTRING
  169. X$$COM
  170. X$$COM REPLACE WITH ONE LINE DESCRIPTION OF CONTENTS OF FILE
  171. X$$COM
  172. X$$COM $$LOGSTRING
  173. X$$COM
  174. X$$COM $$DATE - $$AUTHOR
  175. X$$COE
  176. END_OF_FILE
  177.   if test 392 -ne `wc -c <'lib/COPYRIGHT'`; then
  178.     echo shar: \"'lib/COPYRIGHT'\" unpacked with wrong size!
  179.   fi
  180.   # end of 'lib/COPYRIGHT'
  181. fi
  182. if test -f 'lib/Makefile' -a "${1}" != "-c" ; then 
  183.   echo shar: Will not clobber existing file \"'lib/Makefile'\"
  184. else
  185.   echo shar: Extracting \"'lib/Makefile'\" \(909 characters\)
  186.   sed "s/^X//" >'lib/Makefile' <<'END_OF_FILE'
  187. X#
  188. X#            Copyright (c) 1992 by IRCAM
  189. X#                All rights reserved.
  190. X#
  191. X#  For any information regarding this and other IRCAM software, please
  192. X#  send email to:
  193. X#                              manager@ircam.fr
  194. X#
  195. X
  196. X#
  197. X# Makefile    %I% IRCAM %G%
  198. X#
  199. X# Makefile for mkskel/lib
  200. X#
  201. X# Modification history
  202. X#
  203. X#  5-Aug-92 - Nadia Boulanger (fingerhu@ircam.fr)
  204. X#
  205. X
  206. XMAKEFILE    := Makefile
  207. XROOTDIR        := /usr/local
  208. XOWNER        := root
  209. XGROUP        := wheel
  210. XLIBDIR        := $(ROOTDIR)/lib/mkskel
  211. XSOURCES        := COPYRIGHT skel.README skel.c skel.cc skel.csh skel.h \
  212. X           skel.lisp skel.make skel.man skel.perl skel.sh
  213. XINSTFILES    := $(addprefix $(LIBDIR)/, $(SOURCES))
  214. X
  215. X.PHONY: all install uninstall clean depend
  216. Xall:
  217. X
  218. Xinstall: $(LIBDIR) $(INSTFILES)
  219. X
  220. Xuninstall:
  221. X    rm -f $(LIBDIR)
  222. X
  223. Xdepend:
  224. X
  225. X$(LIBDIR):
  226. X    -mkdir $@; chown $(OWNER).$(ROOT) $@
  227. X
  228. X$(LIBDIR)/%: %
  229. X    install -c -o $(OWNER) -g $(GROUP) -m 0644 $< $@
  230. X
  231. Xtar:
  232. X    tar rfcb $(TAPE) 20 $(SOURCE)
  233. X
  234. Xclean:
  235. X    sccs clean
  236. END_OF_FILE
  237.   if test 909 -ne `wc -c <'lib/Makefile'`; then
  238.     echo shar: \"'lib/Makefile'\" unpacked with wrong size!
  239.   fi
  240.   # end of 'lib/Makefile'
  241. fi
  242. if test -f 'lib/skel.README' -a "${1}" != "-c" ; then 
  243.   echo shar: Will not clobber existing file \"'lib/skel.README'\"
  244. else
  245.   echo shar: Extracting \"'lib/skel.README'\" \(20 characters\)
  246.   sed "s/^X//" >'lib/skel.README' <<'END_OF_FILE'
  247. X@@INCLUDE COPYRIGHT
  248. END_OF_FILE
  249.   if test 20 -ne `wc -c <'lib/skel.README'`; then
  250.     echo shar: \"'lib/skel.README'\" unpacked with wrong size!
  251.   fi
  252.   # end of 'lib/skel.README'
  253. fi
  254. if test -f 'lib/skel.c' -a "${1}" != "-c" ; then 
  255.   echo shar: Will not clobber existing file \"'lib/skel.c'\"
  256. else
  257.   echo shar: Extracting \"'lib/skel.c'\" \(134 characters\)
  258.   sed "s/^X//" >'lib/skel.c' <<'END_OF_FILE'
  259. X#ifndef lint
  260. X@@IF SCCS
  261. Xstatic char sccsid[]= "$$IDSTRING";
  262. X@@ELSE
  263. Xstatic char rcsid[]= "$$IDSTRING";
  264. X@@FI
  265. X#endif
  266. X
  267. X@@INCLUDE COPYRIGHT
  268. END_OF_FILE
  269.   if test 134 -ne `wc -c <'lib/skel.c'`; then
  270.     echo shar: \"'lib/skel.c'\" unpacked with wrong size!
  271.   fi
  272.   # end of 'lib/skel.c'
  273. fi
  274. if test -f 'lib/skel.cc' -a "${1}" != "-c" ; then 
  275.   echo shar: Will not clobber existing file \"'lib/skel.cc'\"
  276. else
  277.   echo shar: Extracting \"'lib/skel.cc'\" \(134 characters\)
  278.   sed "s/^X//" >'lib/skel.cc' <<'END_OF_FILE'
  279. X#ifndef lint
  280. X@@IF SCCS
  281. Xstatic char sccsid[]= "$$IDSTRING";
  282. X@@ELSE
  283. Xstatic char rcsid[]= "$$IDSTRING";
  284. X@@FI
  285. X#endif
  286. X
  287. X@@INCLUDE COPYRIGHT
  288. END_OF_FILE
  289.   if test 134 -ne `wc -c <'lib/skel.cc'`; then
  290.     echo shar: \"'lib/skel.cc'\" unpacked with wrong size!
  291.   fi
  292.   # end of 'lib/skel.cc'
  293. fi
  294. if test -f 'lib/skel.csh' -a "${1}" != "-c" ; then 
  295.   echo shar: Will not clobber existing file \"'lib/skel.csh'\"
  296. else
  297.   echo shar: Extracting \"'lib/skel.csh'\" \(36 characters\)
  298.   sed "s/^X//" >'lib/skel.csh' <<'END_OF_FILE'
  299. X#!$$INTERPRETER
  300. X@@INCLUDE COPYRIGHT
  301. END_OF_FILE
  302.   if test 36 -ne `wc -c <'lib/skel.csh'`; then
  303.     echo shar: \"'lib/skel.csh'\" unpacked with wrong size!
  304.   fi
  305.   # end of 'lib/skel.csh'
  306. fi
  307. if test -f 'lib/skel.h' -a "${1}" != "-c" ; then 
  308.   echo shar: Will not clobber existing file \"'lib/skel.h'\"
  309. else
  310.   echo shar: Extracting \"'lib/skel.h'\" \(20 characters\)
  311.   sed "s/^X//" >'lib/skel.h' <<'END_OF_FILE'
  312. X@@INCLUDE COPYRIGHT
  313. END_OF_FILE
  314.   if test 20 -ne `wc -c <'lib/skel.h'`; then
  315.     echo shar: \"'lib/skel.h'\" unpacked with wrong size!
  316.   fi
  317.   # end of 'lib/skel.h'
  318. fi
  319. if test -f 'lib/skel.lisp' -a "${1}" != "-c" ; then 
  320.   echo shar: Will not clobber existing file \"'lib/skel.lisp'\"
  321. else
  322.   echo shar: Extracting \"'lib/skel.lisp'\" \(20 characters\)
  323.   sed "s/^X//" >'lib/skel.lisp' <<'END_OF_FILE'
  324. X@@INCLUDE COPYRIGHT
  325. END_OF_FILE
  326.   if test 20 -ne `wc -c <'lib/skel.lisp'`; then
  327.     echo shar: \"'lib/skel.lisp'\" unpacked with wrong size!
  328.   fi
  329.   # end of 'lib/skel.lisp'
  330. fi
  331. if test -f 'lib/skel.make' -a "${1}" != "-c" ; then 
  332.   echo shar: Will not clobber existing file \"'lib/skel.make'\"
  333. else
  334.   echo shar: Extracting \"'lib/skel.make'\" \(5955 characters\)
  335.   sed "s/^X//" >'lib/skel.make' <<'END_OF_FILE'
  336. X@@INCLUDE COPYRIGHT
  337. X
  338. XMAKEFILE    := $$MAKEFILE
  339. XTARGET        := $$TARGET
  340. XROOTDIR        := $$HOME
  341. XOWNER        := $$USER
  342. XGROUP        := $$GROUP
  343. X
  344. X# Where executables and man pages go
  345. XBINDIR        := $(ROOTDIR)/bin
  346. XLIBDIR        := $(ROOTDIR)/lib
  347. XETCDIR        := $(ROOTDIR)/etc
  348. XMANDIR        := $(ROOTDIR)/man
  349. X@@IF LIB
  350. XDESTDIR        := $(LIBDIR)
  351. X@@ELSE
  352. XDESTDIR        := $(BINDIR)
  353. X@@FI
  354. X
  355. X@@IF A.OUT|LIB
  356. XCPREFIX        := 
  357. XCC        := $(CPREFIX)cc
  358. XINCLUDE        := /usr/local/include
  359. XCPPFLAGS    := $(addprefix -I, $(INCLUDE))
  360. XCFLAGS        := -O
  361. X@@IF YACCFILES
  362. XYFLAGS        := -d
  363. X@@FI
  364. X@@IF FFILES
  365. XFFLAGS        := -onetrip -w66 -O
  366. X@@FI
  367. XLDFLAGS        := -n
  368. XLIBS        := -lm
  369. XLINT        := $(CPREFIX)lint $(CPPFLAGS) $(CFLAGS) -habx
  370. XAR        := $(CPREFIX)ar
  371. XLORDER        := $(CPREFIX)lorder
  372. XRANLIB        := $(CPREFIX)ranlib
  373. X
  374. X@@IF INCLUDES
  375. XINCLUDES    :=  $$INCLUDES
  376. X@@FI
  377. X@@IF CFILES
  378. XCFILES        :=  $$CFILES
  379. X@@FI
  380. X@@IF CCFILES
  381. XCCFILES        :=  $$CCFILES
  382. X@@FI
  383. X@@IF FFILES
  384. XFFILES        :=  $$FFILES
  385. X@@FI
  386. X@@IF ASFILES
  387. XASFILES        :=  $$ASFILES
  388. X@@FI
  389. X@@IF YACCFILES
  390. XYACCFILES    :=  $$YACCFILES
  391. X@@FI
  392. X@@IF LEXFILES
  393. XLEXFILES    :=  $$LEXFILES
  394. X@@FI
  395. X@@FI
  396. X@@IF SHFILES
  397. XSHFILES        :=  $$SHFILES
  398. X@@FI
  399. XTAPE        := /dev/rmt0h
  400. X@@IF MANFILES1
  401. XMANFILES1    :=  $$MANFILES1
  402. X@@FI
  403. X@@IF MANFILES2
  404. XMANFILES2    :=  $$MANFILES2
  405. X@@FI
  406. X@@IF MANFILES3
  407. XMANFILES3    :=  $$MANFILES3
  408. X@@FI
  409. X@@IF MANFILES4
  410. XMANFILES4    :=  $$MANFILES4
  411. X@@FI
  412. X@@IF MANFILES5
  413. XMANFILES5    :=  $$MANFILES5
  414. X@@FI
  415. X@@IF MANFILES6
  416. XMANFILES6    :=  $$MANFILES6
  417. X@@FI
  418. X@@IF MANFILES7
  419. XMANFILES7    :=  $$MANFILES7
  420. X@@FI
  421. X@@IF MANFILES8
  422. XMANFILES8    :=  $$MANFILES8
  423. X@@FI
  424. X@@IF MANFILES1|MANFILES2|MANFILES3|MANFILES4|MANFILES5|MANFILES6|MANFILES7|MANFILES8
  425. XMANFILES    :=  $${MANFILES1?$(MANFILES1)} $${MANFILES2?$(MANFILES2)} $${MANFILES3?$(MANFILES3)} $${MANFILES4?$(MANFILES4)} $${MANFILES5?$(MANFILES5)} $${MANFILES6?$(MANFILES6)} $${MANFILES6?$(MANFILES7)} $${MANFILES8?$(MANFILES8)}
  426. XINSTMANFILES    := $${MANFILES1?$(addprefix $(MANDIR)/man1/, $(MANFILES1))} $${MANFILES2?$(addprefix $(MANDIR)/man2/, $(MANFILES2))} $${MANFILES3?$(addprefix $(MANDIR)/man3/, $(MANFILES3))} $${MANFILES4?$(addprefix $(MANDIR)/man4/, $(MANFILES4))} $${MANFILES5?$(addprefix $(MANDIR)/man5/, $(MANFILES5))} $${MANFILES6?$(addprefix $(MANDIR)/man6/, $(MANFILES6))} $${MANFILES7?$(addprefix $(MANDIR)/man7/, $(MANFILES7))} $${MANFILES8?$(addprefix $(MANDIR)/man8/, $(MANFILES8))}
  427. X@@FI
  428. XINSTTARGET    := $(addprefix $(DESTDIR)/, $(TARGET))
  429. X
  430. X@@IF DOCFILES
  431. XDOCFILES    :=  $$DOCFILES
  432. X@@FI
  433. X@@IF A.OUT|LIB
  434. XOBJECTS        := $${CFILES?$(subst .c,.o,$(CFILES))} $${CCFILES?$(subst .cc,.o,$(CCFILES))} $${CCFILES?$(subst .c++,.o,$(CCFILES))} $${FFILES?$(subst .f,.o,$(FFILES))} $${YACCFILES?$(subst .y,.o,$(YACCFILES))} $${LEXFILES?$(subst .l,.o,$(LEXFILES))} $${ASFILES?$(subst .s,.o,$(ASFILES))}
  435. X@@FI
  436. XSOURCE        := $(MAKEFILE) $(MANFILES) $(DOCFILES) $(SHFILES) \
  437. X           $(INCLUDES) $(YACCFILES) $(LEXFILES) \
  438. X           $(CFILES) $(FFILES) $(ASFILES)
  439. X
  440. X.PHONY: all install uninstall clean depend
  441. Xall:     $(TARGET)
  442. X
  443. Xinstall: $(INSTTARGET) $(INSTMANFILES)
  444. X
  445. Xuninstall:
  446. X    rm -f $(INSTTARGET) $(INSTMANFILES)
  447. X
  448. X@@IF A.OUT|LIB
  449. Xdepend: Mkfile.depend
  450. X
  451. XMkfile.depend: $(YACCFILES) $(LEXFILES) $(CFILES) $(FFILES) $(INCLUDES)
  452. X    @echo "# Automatically generated dependencies" > Mkfile.depend
  453. X@@IF MKDEPEND
  454. X    $$MKDEPEND $(CPPFLAGS) $(YACCFILES) $(LEXFILES) $(CCFILES) \
  455. X        $(CFILES) $(FFILES) >> Mkfile.depend
  456. X@@ELSE
  457. X    -@for i in $(YACCFILES) $(LEXFILES) $(CFILES) $(FFILES) ; do\
  458. X        base=`expr \$\$i ':' '\(.*\).[cylf]\$\$'`;\
  459. X        suffix=`expr \$\$i ':' '.*\.\([cylf]\)\$\$'`;\
  460. X@@IF LEXFILES
  461. X        if /bin/test \$\$suffix = l ; then\
  462. X            lex \$\$i;\
  463. X            mv lex.yy.c \$\$base.c;\
  464. X            suffix=c;\
  465. X            echo "\$\$base.c:    \$\$base.l" >> Mkfile.depend;\
  466. X@@IFN YACCFILES
  467. X        fi;\
  468. X@@FI
  469. X@@FI
  470. X@@IF YACCFILES
  471. X        $${LEXFILES?el}if /bin/test \$\$suffix = y ; then\
  472. X            yacc $(YFLAGS) \$\$i;\
  473. X            mv y.tab.c \$\$base.c;\
  474. X            suffix=c;\
  475. X            echo "\$\$base.c:    \$\$base.y" >> Mkfile.depend;\
  476. X            echo "y.tab.h:    \$\$base.y" >> Mkfile.depend;\
  477. X        fi;\
  478. X@@FI
  479. X        $(CC) $(CPPFLAGS) -E \$\$base.\$\$suffix |\
  480. X        grep '^# [0-9][0-9]* ".*"\$\$' > /tmp/grep\$\$\$\$;\
  481. X        sed -e 's/.*"\(.*\)"\$\$/\1/' -e 's/^.\///' < /tmp/grep\$\$\$\$ |\
  482. X        sort -u |\
  483. X        awk\
  484. X            "BEGIN { line=\"\$\$base.o:    \"}\
  485. X            {\
  486. X                if(length(line \\$\$0)>63)\
  487. X                {\
  488. X                    print line,\"\\\\\";\
  489. X                    line=\"        \"\\$\$0\
  490. X                }\
  491. X                else\
  492. X                    line=line\" \"\\$\$0\
  493. X            }\
  494. X            END { print line}"\
  495. X        >> Mkfile.depend;\
  496. X    done;\
  497. X    rm /tmp/grep\$\$\$\$
  498. X@@FI
  499. X@@ELSE
  500. Xdepend:
  501. X@@FI
  502. X
  503. X@@IF SH
  504. X$(TARGET):      $(TARGET).sh
  505. X@@FI
  506. X@@IF PERL
  507. X$(TARGET):      $(TARGET).pl
  508. X    cat $< > $@
  509. X    chmod a+x $@
  510. X@@FI
  511. X@@IF CSH
  512. X$(TARGET):      $(TARGET).csh
  513. X    cat $< > $@
  514. X    chmod a+x $@
  515. X@@FI
  516. X@@IF A.OUT
  517. X$(TARGET):      $(OBJECTS)
  518. X    $(CC) $(LDFLAGS) $(OBJECTS) -o $(TARGET) $(LIBS)
  519. X    size $(TARGET)
  520. X@@FI
  521. X@@IF LIB
  522. X$(TARGET):    $(OBJECTS)
  523. X    -rm $(TARGET)
  524. X    $(AR) rcv $(TARGET) `$(LORDER) $(OBJECTS) | tsort`
  525. X    -$(RANLIB) $(TARGET)
  526. X@@FI
  527. X
  528. X$(DESTDIR)/%: %
  529. X@@IF A.OUT|CSH|SH|PERL
  530. X    install -c -o $(OWNER) -g $(GROUP) -m 0755 $< $@
  531. X@@ELSE
  532. X    install -c -o $(OWNER) -g $(GROUP) -m 0644 $< $@
  533. X@@FI
  534. X@@IF LIB
  535. X    -$(RANLIB) $@
  536. X@@FI
  537. X
  538. X@@IF MANFILES1
  539. X$(MANDIR)/man1/% : %
  540. X    install -c -o $(OWNER) -g $(GROUP) -m 0644 $< $@
  541. X@@FI
  542. X@@IF MANFILES2
  543. X$(MANDIR)/man2/% : %
  544. X    install -c -o $(OWNER) -g $(GROUP) -m 0644 $< $@
  545. X@@FI
  546. X@@IF MANFILES3
  547. X$(MANDIR)/man3/% : %
  548. X    install -c -o $(OWNER) -g $(GROUP) -m 0644 $< $@
  549. X@@FI
  550. X@@IF MANFILES4
  551. X$(MANDIR)/man4/% : %
  552. X    install -c -o $(OWNER) -g $(GROUP) -m 0644 $< $@
  553. X@@FI
  554. X@@IF MANFILES5
  555. X$(MANDIR)/man5/% : %
  556. X    install -c -o $(OWNER) -g $(GROUP) -m 0644 $< $@
  557. X@@FI
  558. X@@IF MANFILES6
  559. X$(MANDIR)/man6/% : %
  560. X    install -c -o $(OWNER) -g $(GROUP) -m 0644 $< $@
  561. X@@FI
  562. X@@IF MANFILES7
  563. X$(MANDIR)/man7/% : %
  564. X    install -c -o $(OWNER) -g $(GROUP) -m 0644 $< $@
  565. X@@FI
  566. X@@IF MANFILES8
  567. X$(MANDIR)/man8/% : %
  568. X    install -c -o $(OWNER) -g $(GROUP) -m 0644 $< $@
  569. X@@FI
  570. X
  571. Xtar:
  572. X    tar rfcb $(TAPE) 20 $(SOURCE)
  573. X
  574. Xshar:    $(TARGET).shar
  575. X
  576. X$(TARGET).shar: $(SOURCE)
  577. X    shar $^ > $@
  578. X
  579. Xclean:
  580. X    -rm -f $(OBJECTS)
  581. X@@IF SCCS
  582. X    sccs clean
  583. X@@ELSE
  584. X    rcsclean
  585. X@@FI
  586. X
  587. X@@IF A.OUT|LIB
  588. XMkfile.depend:
  589. X    if [ ! -f Mkfile.depend ] ; then echo > Mkfile.depend ; fi
  590. Xinclude Mkfile.depend
  591. X@@MESSAGE Don't forget to make depend to finish the job.
  592. X@@FI
  593. X@@MESSAGE Done.
  594. END_OF_FILE
  595.   if test 5955 -ne `wc -c <'lib/skel.make'`; then
  596.     echo shar: \"'lib/skel.make'\" unpacked with wrong size!
  597.   fi
  598.   # end of 'lib/skel.make'
  599. fi
  600. if test -f 'lib/skel.man' -a "${1}" != "-c" ; then 
  601.   echo shar: Will not clobber existing file \"'lib/skel.man'\"
  602. else
  603.   echo shar: Extracting \"'lib/skel.man'\" \(392 characters\)
  604.   sed "s/^X//" >'lib/skel.man' <<'END_OF_FILE'
  605. X.TH $$NAME $$SECTION "$$IDSTRING"
  606. X@@INCLUDE COPYRIGHT
  607. X.SH $$NAME
  608. X$$name - description
  609. X.SH SYNOPSIS
  610. X.B $$name
  611. X[
  612. X.B \-keyword
  613. X]
  614. X[
  615. X.I parameter
  616. X]
  617. X.I parameter
  618. X.SH DESCRIPTION
  619. X.PP
  620. X.B $$Name
  621. Xdescription
  622. X.SH OPTIONS
  623. X.TP
  624. X\fB\-keyword \fIoption\fP
  625. Xaction
  626. X.TP
  627. X\fIparameter\fP
  628. Xaction
  629. X.SH FILES
  630. X.nf
  631. X.ta \w'longestfilename    'u
  632. X\fIfilename\fR    description
  633. X.fi
  634. X.SH "SEE ALSO"
  635. X.SH BUGS
  636. X.SH AUTHOR
  637. X$$AUTHOR
  638. END_OF_FILE
  639.   if test 392 -ne `wc -c <'lib/skel.man'`; then
  640.     echo shar: \"'lib/skel.man'\" unpacked with wrong size!
  641.   fi
  642.   # end of 'lib/skel.man'
  643. fi
  644. if test -f 'lib/skel.perl' -a "${1}" != "-c" ; then 
  645.   echo shar: Will not clobber existing file \"'lib/skel.perl'\"
  646. else
  647.   echo shar: Extracting \"'lib/skel.perl'\" \(730 characters\)
  648.   sed "s/^X//" >'lib/skel.perl' <<'END_OF_FILE'
  649. X#!$$INTERPRETER
  650. X@@INCLUDE COPYRIGHT
  651. X$[ = 1;                     # set array base to 1
  652. X$, = ' ';                   # set output field separator
  653. X$\ = "\n";                  # set output record separator
  654. X
  655. X($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$dst) = localtime(time);
  656. X%month= ( 1, 'Jan', 2, 'Feb', 3, 'Mar', 4, 'Apr', 5, 'May', 6, 'Jun',
  657. X       7, 'Jul', 8, 'Aug', 9, 'Sep', 10, 'Oct', 11, 'Nov', 12, 'Dec');
  658. X
  659. X$date= sprintf("%2d-%s-%d", $mday, $month{$mon+1}, $year);
  660. X
  661. X$options = ':v';        # for getopts
  662. X$usage   = "Usage: $0 [-v]\n";  # if failed
  663. X
  664. X# parse arguments
  665. Xrequire 'getopts.pl';
  666. X&Getopts($options) || die $usage  ;     # parse the arguments
  667. X
  668. X# -v: print version and exit
  669. Xif (defined $opt_v) {
  670. X    print '$$IDSTRING';
  671. X    exit;
  672. X}
  673. END_OF_FILE
  674.   if test 730 -ne `wc -c <'lib/skel.perl'`; then
  675.     echo shar: \"'lib/skel.perl'\" unpacked with wrong size!
  676.   fi
  677.   # end of 'lib/skel.perl'
  678. fi
  679. if test -f 'lib/skel.sh' -a "${1}" != "-c" ; then 
  680.   echo shar: Will not clobber existing file \"'lib/skel.sh'\"
  681. else
  682.   echo shar: Extracting \"'lib/skel.sh'\" \(36 characters\)
  683.   sed "s/^X//" >'lib/skel.sh' <<'END_OF_FILE'
  684. X#!$$INTERPRETER
  685. X@@INCLUDE COPYRIGHT
  686. END_OF_FILE
  687.   if test 36 -ne `wc -c <'lib/skel.sh'`; then
  688.     echo shar: \"'lib/skel.sh'\" unpacked with wrong size!
  689.   fi
  690.   # end of 'lib/skel.sh'
  691. fi
  692. if test -f 'mkskel.1' -a "${1}" != "-c" ; then 
  693.   echo shar: Will not clobber existing file \"'mkskel.1'\"
  694. else
  695.   echo shar: Extracting \"'mkskel.1'\" \(7484 characters\)
  696.   sed "s/^X//" >'mkskel.1' <<'END_OF_FILE'
  697. X.TH MKSKEL 1 "IRCAM 2.6 8/25/92"
  698. X.SH NAME
  699. Xmkskel - create standard skeleton files for man pages, shell scripts, C programs, etc...
  700. X.SH SYNOPSIS
  701. X.B mkskel
  702. X[
  703. X.B \-v
  704. X]
  705. X[
  706. X.B \-r
  707. X]
  708. X[
  709. X.BI \-t
  710. X.I skeleton-file-type
  711. X]
  712. X[
  713. X.B \-s
  714. X.I target-type
  715. X]
  716. X[
  717. X.B \-l
  718. X.I dir
  719. X]
  720. X[
  721. X.I skeleton-file
  722. X[
  723. X.I target 
  724. X[
  725. X.I files, ...
  726. X]
  727. X]
  728. X]
  729. X.SH DESCRIPTION
  730. X.PP
  731. X.B Mkskel
  732. Xcreates a file named
  733. X.B file
  734. X(or on standard output, if not specified)
  735. Xwhich is a standard skeleton for C, C++, lisp programs, man
  736. Xpages, shell and perl scripts, README and Makefiles.
  737. XIt comprizes some copyright and version control information,
  738. Xas well as a standard beginning for some type of programs (e.g., perl).
  739. XIt can be used for multiple targets (see below MULTIPLE TARGETS
  740. Xsection).
  741. X.SH EXAMPLES
  742. XCreate a main.c prototype file for a C program:
  743. X.EX 5
  744. Xmkskel main.c
  745. X.EE
  746. X
  747. XCreate a prototype lisp program on stdout and redirect it somewhere
  748. X.EX 5
  749. Xmkskel -t lisp > setf.lsp
  750. X.EE
  751. X
  752. XCreate a prototype man page for a section 7 documentation:
  753. X.EX 5
  754. Xmkskel mydoc.7
  755. X.EE
  756. X
  757. XCreate a prototype Makefile for a target executable called ``myprog''
  758. Xfrom all sources, includes, docs in the current directory:
  759. X.EX 5
  760. Xmkskel Makefile myprog *.c *.h *.[1-8]
  761. X.EE
  762. X
  763. XSame, for a library:
  764. X.EX 5
  765. Xmkskel Makefile mylib.a *.c *.h *.[1-8]
  766. X.EE
  767. X
  768. XCreate a README file:
  769. X.EX 5
  770. Xmkskel README
  771. X.EE
  772. X.SH OPTIONS
  773. X.TP
  774. X.B \-v
  775. Xprint version of this program and exit.
  776. X.B \-r
  777. Xinsert RCS version control keywords (default is SCCS).
  778. X.TP
  779. X.BI \-t\  file-type
  780. XDetermine the type of the prototype to be created
  781. Xfrom this flag.  It can currently be
  782. X.B c, cc,
  783. X.B lisp, perl,
  784. X.B sh, csh, h, man
  785. Xfor C, C++, lisp programs, perl, sh and csh scripts, include files
  786. Xand man pages.  It not present, it is infered from the name
  787. Xof the file.
  788. X.TP
  789. X.BI \-s\  target-type
  790. X(Only for Makefiles) determine the type of the target to be created
  791. X.B a.out
  792. Xif the target is an executable compiled from sources,
  793. X.B lib
  794. Xif the target is a library
  795. X.B sh, csh, perl
  796. Xif the target is an executable script in sh, csh or perl.
  797. XIf not specified, it tries to infer it
  798. Xfrom the target name.
  799. X.I Makefile
  800. Xis the name of the makefile to be generated,
  801. X.I target
  802. Xthe target name, and
  803. X.I files
  804. Xare the names of the files from which the target is
  805. Xto be generated.  Examples:
  806. X.sp 1
  807. Xcreate a library from sources:
  808. X.EX 5
  809. Xmkskel Makefile mylib.a *.c *.h    *.[1-8]
  810. X.EE
  811. X.sp 1
  812. Xcreate an executable a.out called myprog:
  813. X.EX 5
  814. Xmkskel -s a.out Makefile myprog *.c *.h
  815. X.EE
  816. X.sp 1
  817. Xcreate an executable shell script:
  818. X.EX 5
  819. Xmkskel -s sh Makefile myscript *.sh *.1
  820. X.EE
  821. X.EE
  822. X.TP
  823. X.BI \-l\  dir
  824. XIs the name of a directory containing prototypical skeletons.  If not
  825. Xmentioned, it defaults to the variable
  826. X.B $LIBSKEL
  827. Xif it is defined in the program, and if not, to
  828. X.B \./lib.
  829. X.TP
  830. X.I file
  831. XIs the name of the output file.  If no type has been specified through
  832. Xthe
  833. X.B \-l
  834. Xflag, the program tries to determine it from the extension of the file name.
  835. XThe most common extensions are recognized (.c, .cc, .pl, .sh, .csh, .h, and
  836. X\.1 through \.8).
  837. X.SH MULTIPLE TARGETS
  838. XIn order to create a file for multiple targets, proceed as above, by specifying
  839. Xjust one of the targets.  Then modify the Makefile accordingly:
  840. X.TP
  841. XAll targets go to the same destination directory
  842. X(E.g., all executables, or all libraries, etc...)
  843. XPut all their names in the
  844. X.B TARGET :=
  845. Xline, e.g.,
  846. X.EX 5
  847. XTARGET := prog1 prog2 prog3 ...
  848. X.EE
  849. X.TP
  850. XTargets for different destinations
  851. X(E.g., libraries, executables, etc...) Modify the
  852. X.B INSTTARGET
  853. Xrule according to the various destinations.  Make sure there are
  854. Xappropriate creation and install
  855. Xrules for each type of target.
  856. X.SH PROTOTYPE FILES
  857. XThe prototype files contain text, directives and variables which get
  858. Xexecuted and substituted when read.  The recognized directive are:
  859. X.TP
  860. X.B @@ELSE
  861. Xdenotes the starting alternative branch of an
  862. X.B @@IF.
  863. X.TP
  864. X.B @@FI
  865. Xdenotes the end of the
  866. X.B @@IF ... ( @@ELSE )
  867. Xor
  868. X.B @@IFN ... ( @@ELSE )
  869. Xscope.
  870. X.TP
  871. X.BI @@IF\  condition
  872. XThe following lines until the next
  873. X.B @@ELSE
  874. Xor
  875. X.B @@FI
  876. Xare included if the
  877. X.I condition
  878. Xevaluates to true.  Conditions are of the form
  879. X.I var
  880. Xor
  881. X.I var|var...
  882. Xor
  883. X.I var&var...
  884. Xwhere
  885. X.I var
  886. Xare variables in
  887. X.B mkskel (see further down).  The
  888. X.B @@ELSE
  889. Xbranch is not mandatory, and the constructs can be nested.
  890. X.TP
  891. X.BI @@IFN\  condition
  892. XAs above, but if the condition evaluates to false
  893. X.TP
  894. X.BI @@INCLUDE\  file
  895. Xwhich includes at this point a file named
  896. X.I file
  897. Xfrom the lib directory.
  898. X.TP
  899. X.BI @@MESSAGE\  text
  900. Xprints the
  901. X.I text
  902. Xon stderr (e.g., operator message, error, etc...).
  903. X
  904. XThe following variables are recognized and substituted:
  905. X.TP
  906. X.B $$AUTHOR
  907. XFull name and email address of author of the program.
  908. X.TP
  909. X.B $$COB, $$COM, $$COE
  910. XDenote the strings identifying the beginning of a comment (e.g., /* for C),
  911. Xthe "middle" of a comment (no real meaning other than cosmetic -- set to
  912. X" *" for C, see skel.c for a use) and the end of a comment.  For most
  913. Xcases, all three are identical.
  914. X.TP
  915. X.B $$DATE
  916. XToday's date in dd-mmm-yy format.
  917. X.TP
  918. X.B $$FILENAME
  919. XName of the file (default: blank).  See also
  920. X.B $$NAME.
  921. X.TP $$GROUP
  922. XName of the group to which the user belongs.
  923. X.TP
  924. X.B $$HOME
  925. XHome directory of the user.
  926. X.TP
  927. X.B $$IDSTRING
  928. XVersion control string, typically RCS or SCCS (defaults to an SCCS-type
  929. Xstring if not defined).  Care must be taken in defining this string in
  930. Xthe program, so as to prevent the version control of the program to
  931. Xmuck with this string!
  932. X.TP
  933. X.B $$INTERPRETER
  934. XPath to interpreter for interpreted languages.
  935. X.TP
  936. X.B $$LOGSTRING
  937. XVersion history log (e.g.,
  938. X.B $Log$
  939. Xfor RCS).  Same care as for
  940. X.B $$IDSTRING
  941. X(default is "Modification history").
  942. X.TP
  943. X.B $$MAILHOST
  944. XFully qualified name of the machine on which author of program can be found
  945. X(default: local machine).
  946. X.TP
  947. X.B $$MANAGER
  948. XEmail address of the person to whom to send enquiries about the program
  949. X(default: root on local machine).
  950. X.TP
  951. X.B $$NAME, $$Name, $$Name
  952. XName of file stripped of its extension in uppercase, in initial uppercase
  953. Xand in lower case taken from file name (default is "NAME").
  954. X.TP
  955. X.B $$ORG
  956. XThe name of the organization, if defined in the program, or else the one
  957. Xbut last component of the fully qualified name of the machine on which
  958. Xthe program is executed.
  959. X.TP
  960. X.B $$RCS
  961. XDefined if RCS is the version control system used, as required
  962. Xwith the
  963. X.B \-r
  964. Xflag (default is SCCS).
  965. X.TP
  966. X.B $$SCCS
  967. XDefined if SCCS is the version control system used (default).
  968. X.TP
  969. X.B $$SECTION
  970. XSection number for man pages (default: 1).
  971. X.TP
  972. X.B $$USER
  973. XUser name (login) of the user running the program.
  974. X.TP
  975. X.B $$YEAR
  976. XCurrent year (4 digit number).
  977. X.TP
  978. X.BI $${ condition\fB:\fPtext }
  979. XIf
  980. X.I condition
  981. Xevaluates to true, then subsitute
  982. X.I text
  983. Xat this point, else nothing.
  984. X
  985. XIn the special case of Makefiles, an additional set of variables is
  986. Xdefined:
  987. X.B $$INCLUDES, $$CFILES, $$CCFILES, $$FFILES
  988. X.B $$ASFILES, $$YACCFILES, $$LIBFILES
  989. X.B $$LEXFILES, $$SHFILES,
  990. X.B $$MANFILES1 - $$MANFILES8
  991. Xand
  992. X.B $$DOCFILES
  993. Xwhich will contain the list of files of each type among the arguments to the
  994. Xcommand.  Those variables can later be used in conditionals.
  995. X.SH CONFIGURATION
  996. XThe program is configured by setting several (optional) variables in
  997. Xits beginning, as well as by changing the location of the language
  998. Xinterpreters as specified in the associative array
  999. X.B %types.
  1000. X.SH FILES
  1001. X.TP
  1002. X.B /usr/local/lib/mkskel/*
  1003. X(or the directory specified with the
  1004. X.B \-l
  1005. Xflag) contains the prototypical files for each type.  Their name is of
  1006. Xthe form
  1007. X.BI skel. type .
  1008. X.SH "SEE ALSO"
  1009. Xmakemake(1)
  1010. X.SH AUTHOR
  1011. XMichel Fingerhut (fingerhu@ircam.fr)
  1012. END_OF_FILE
  1013.   if test 7484 -ne `wc -c <'mkskel.1'`; then
  1014.     echo shar: \"'mkskel.1'\" unpacked with wrong size!
  1015.   fi
  1016.   # end of 'mkskel.1'
  1017. fi
  1018. if test -f 'mkskel.pl' -a "${1}" != "-c" ; then 
  1019.   echo shar: Will not clobber existing file \"'mkskel.pl'\"
  1020. else
  1021.   echo shar: Extracting \"'mkskel.pl'\" \(10104 characters\)
  1022.   sed "s/^X//" >'mkskel.pl' <<'END_OF_FILE'
  1023. X#!/usr/local/bin/perl
  1024. X#            Copyright (c) 1992 by IRCAM
  1025. X#                All rights reserved.
  1026. X#
  1027. X#  For any information regarding this and other IRCAM software, please 
  1028. X#  send email to:
  1029. X#                              manager@ircam.fr
  1030. X
  1031. X#
  1032. X# mkskel    2.8 IRCAM 8/24/92
  1033. X#
  1034. X# Create a skeleton file for a program in C, perl or sh.
  1035. X#
  1036. X# Modification history
  1037. X#
  1038. X# 28-Jul-92 - Michel Fingerhut (fingerhu@ircam.fr)
  1039. X#
  1040. X
  1041. X#------------------------------------------------------------------------------
  1042. X# site-dependent configurable part (optional)
  1043. X#------------------------------------------------------------------------------
  1044. X
  1045. X$ORG      = "IRCAM";            # no blanks
  1046. X$MAILHOST = "ircam.fr";            # fully qualified name (where author is)
  1047. X$MANAGER  = "manager@ircam.fr";        # full address whom to send questions to
  1048. X$IDSTRING = "%I\045 $ORG \045G%";    # for SCCS, e.g.. (\045=%...)
  1049. X$LOGSTRING= "Modification history";    # for RCS, might be $Log$, e.g.
  1050. X$LIBSKEL  = "/usr/local/lib/mkskel";    # where the skeletons are
  1051. X$NAME      = "NAME";            # default if not specified
  1052. X$MKDEPEND = "cc -Em";            # or "gcc -M"; if none, default code
  1053. X
  1054. X#------------------------------------------------------------------------------
  1055. X# end of configuration
  1056. X#------------------------------------------------------------------------------
  1057. X
  1058. X$[ = 1;                     # set array base to 1
  1059. X$, = ' ';                   # set output field separator
  1060. X$\ = "\n";                  # set output record separator
  1061. X
  1062. X($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$dst) = localtime(time);
  1063. X%month= ( 1, 'Jan', 2, 'Feb', 3, 'Mar', 4, 'Apr', 5, 'May', 6, 'Jun',
  1064. X       7, 'Jul', 8, 'Aug', 9, 'Sep', 10, 'Oct', 11, 'Nov', 12, 'Dec');
  1065. Xchop($hostname= `hostname`);
  1066. X$options = "s:l:t:rv";
  1067. X$usage   = "Usage: $0 [-v] [-r] [-l dir] [-t type] [-s source] [file]\n";
  1068. Xrequire 'getopts.pl';
  1069. X
  1070. X# check arguments and exit (before all the rest) if wrong
  1071. X
  1072. X&Getopts($options) || die $usage  ;     # parse the arguments
  1073. X
  1074. Xif ($opt_v) {
  1075. X    print "2.8 IRCAM 8/24/92";
  1076. X    exit;
  1077. X}
  1078. X
  1079. Xif ($opt_r) {
  1080. X    ($IDSTRING, $LOGSTRING, $RCS) =('$Revision$ '."$ORG".' $Date$', '$Log$', 1);
  1081. X} else {
  1082. X    $SCCS= 1;
  1083. X}
  1084. X
  1085. X#------------------------------------------------------------------------------
  1086. X# File types:         pattern:INTERPRETER:COB:COM:COE
  1087. X#------------------------------------------------------------------------------
  1088. X%types   = ("c",     ".+\.c::/*: *: */",
  1089. X            "cc",    ".+\.cc:://://://",
  1090. X        "csh",     ".+\.csh:/bin/csh:\043:\043:\043",
  1091. X        "h",     ".+\.h::/*: *: */",
  1092. X        "lisp",    ".+\.l::;:;:;",
  1093. X        "man",     ".+.\[1-8]::.\\\":.\\\":.\\\"",
  1094. X        "perl",     ".+\.pl|perl:/usr/local/bin/perl:#:#:#",
  1095. X        "sh",     ".+\.sh:/bin/sh:#:#:#",
  1096. X        "make",    "[Mm]akefile:/usr/local/bin/make:#:#:#",
  1097. X        "README",    "[Rr][Ee][Aa][Dd][Mm][Ee]::::"
  1098. X       );
  1099. X
  1100. X#------------------------------------------------------------------------------
  1101. X# File types for Makefiles: pattern for name, name of variable
  1102. X#------------------------------------------------------------------------------
  1103. X
  1104. X%subtypes= (".*\\.h",            "INCLUDES",
  1105. X        ".*\\.c",            "CFILES",
  1106. X        ".*\\.(cc|c\\+\\+)",    "CCFILES",
  1107. X        ".*\\.f",            "FFILES",
  1108. X        ".*\\.s",            "ASFILES",
  1109. X        ".*\\.y",            "YACCFILES",
  1110. X        ".*\\.a",            "LIBFILES",
  1111. X        ".*\\.l",            "LEXFILES",
  1112. X        ".*\\.(sh|csh|pl)",        "SHFILES",
  1113. X        ".*\\.1",            "MANFILES1",
  1114. X        ".*\\.2",            "MANFILES2",
  1115. X        ".*\\.3",            "MANFILES3",
  1116. X        ".*\\.4",            "MANFILES4",
  1117. X        ".*\\.5",            "MANFILES5",
  1118. X        ".*\\.6",            "MANFILES6",
  1119. X        ".*\\.7",            "MANFILES7",
  1120. X        ".*\\.8",            "MANFILES8",
  1121. X        ".*\\.(mm|me|doc|tex)",      "DOCFILES",
  1122. X        "README|INSTALL",          "DOCFILES",
  1123. X        );
  1124. X
  1125. X%subtype  =("lib", 1, "sh", 1, "a.out", 1, "perl", 1, "csh", 1);
  1126. X
  1127. X#-----------------------------------------------------------------------------
  1128. X# Check arguments
  1129. X#------------------------------------------------------------------------------
  1130. X
  1131. X$LIBDIR= $opt_l || $LIBSKEL || "./lib";    # where the skeletons are
  1132. X
  1133. Xdie "Unknown file type\n" if defined $opt_t && ! defined $types{$opt_t};
  1134. X
  1135. Xif ($#ARGV) {
  1136. X    $file= $ARGV[1];
  1137. X    ($suffix= $file) =~ s/.*\.//;
  1138. X}
  1139. X
  1140. X#-----------------------------------------------------------------------------
  1141. X# Variables likely to be substituted
  1142. X#------------------------------------------------------------------------------
  1143. X
  1144. X$MAILHOST = (gethostbyname($hostname))[1]     unless defined $MAILHOST;
  1145. X$MANAGER  = "root@$MAILHOST"             unless defined $MANAGER;
  1146. X$ORG      = "\U$1\E" if !defined $ORG && $MAILHOST =~ /\.([^\.]+)\.[^\.]*/;
  1147. X$IDSTRING = "%I\045 $ORG \045G%"         unless defined $IDSTRING;
  1148. X$LOGSTRING= $IDSTRING                unless defined $LOGSTRING;
  1149. X$DATE     = sprintf("%2d-%s-%d", $mday, $month{$mon+1}, $year);
  1150. X$LOGIN      = getlogin || (getpwuid($<))[1];
  1151. X$AUTHOR   = sprintf ("%s (%s@%s)", (getpwuid($<))[7], $LOGIN, $MAILHOST);
  1152. X$USER      = $ENV{'USER'};
  1153. X$HOME      = $ENV{'HOME'};
  1154. X$GROUP    = (getgrgid((getpwuid($<))[4]))[1];
  1155. X$YEAR      = "19$year";                # soon to modify...
  1156. X$FILENAME = $file                if defined $file; # else stdout
  1157. X$NAME     = (split(/\./, "\U$file\E"))[1]    if defined $file; # else default
  1158. X$Name     = "\U$1\E\L$2\E"             if $NAME=~ /(.)(.*)/;
  1159. X$name     = "\L$NAME\E";
  1160. X#-----------------------------------------------------------------------------
  1161. X# Determine type and execute
  1162. X#------------------------------------------------------------------------------
  1163. X
  1164. Xif (defined $opt_t) {
  1165. X    $type= $opt_t;
  1166. X} else {
  1167. X    foreach $t (keys %types) {
  1168. X    $pattern= (split(/:/, $types{$t}))[1];
  1169. X    $type= $t, last if defined $file && $file =~ /^$pattern$/;
  1170. X    }
  1171. X}
  1172. Xdie "Can't tell which type!\n" if ! defined $type;
  1173. X($pattern, $INTERPRETER, $COB, $COM, $COE)= split(/:/, $types{$type});
  1174. X$SECTION= $suffix =~ /^[1-8]$/ ? $suffix : 1    if $type eq "man";
  1175. X
  1176. X# special treatment for Makefiles
  1177. X
  1178. Xif ($type eq "make") {
  1179. X
  1180. X    # Target name comes right next, no default
  1181. X
  1182. X    $MAKEFILE= $ARGV[1] || "Makefile" ;
  1183. X    $TARGET  = $ARGV[2] || "a.out";
  1184. X
  1185. X    # Type of processing (a.out, sh, lib, perl, csh)
  1186. X
  1187. X    if (defined $opt_s) {
  1188. X    die "Unknown source type\n" if ! defined $subtype{$opt_s};
  1189. X    $subtype = $opt_s;
  1190. X    } elsif ($TARGET =~ /.a$/) {
  1191. X        $subtype = "lib";
  1192. X    } else {
  1193. X    $subtype = "a.out";
  1194. X    }
  1195. X    $subtype=~ s/\./_/g;
  1196. X    eval "\$\U$subtype\E= 1";
  1197. X
  1198. X    # Define all variables according to the rest of the files
  1199. X
  1200. X    foreach $file (@ARGV[3..$#ARGV]) {
  1201. X    foreach $s (keys %subtypes) {
  1202. X        eval "\$$subtypes{$s} .= \"$file \"", last if $file =~ /^$s$/;
  1203. X    }
  1204. X    }
  1205. X}
  1206. X
  1207. X# now open the output and perform
  1208. X
  1209. X&openfile($file)         if defined $file;
  1210. X&dofile("$LIBDIR/skel.$type");
  1211. X
  1212. X#------------------------------------------------------------------------------
  1213. X# Open output file with backup
  1214. X#------------------------------------------------------------------------------
  1215. X
  1216. Xsub openfile {{
  1217. X    local($file)= $_[1];
  1218. X    if (-e $file) {
  1219. X    die "Files $file and $file.bak exist, not overwritten\n"
  1220. X        if -e "$file.bak";
  1221. X    print STDERR "renaming existing $file to $file.bak";
  1222. X    rename($file, "$file.bak");
  1223. X    }
  1224. X    open (STDOUT, ">$file") || die "Can't open $file for output: $!\n";
  1225. X    print STDERR "output file is $file";
  1226. X}}
  1227. X
  1228. X#------------------------------------------------------------------------------
  1229. X# Read a file with substitutions and possible inclusions (recurse then)
  1230. X#------------------------------------------------------------------------------
  1231. X
  1232. Xsub dofile {{
  1233. X    local($file)= $_[1];
  1234. X    local($d)= 0;
  1235. X    open (FILE, $file) || die "Can't find $file: $!\n";
  1236. X
  1237. X    push(cond, 1) if ! $#cond;            # initialize the stack
  1238. X    while (<FILE>) {
  1239. X    chop;
  1240. X
  1241. X    # perform action if keyword and not nested in a skipped conditional
  1242. X
  1243. X    $d++, $cond[$#cond]   && push(cond, $d, &docondition($1)),
  1244. X                    next    if /^@@IF (.*)$/;
  1245. X
  1246. X    $d++, $cond[$#cond]   && push(cond, $d, ! &docondition($1)),
  1247. X                    next    if /^@@IFN (.*)$/;
  1248. X
  1249. X    $d == $cond[$#cond-1] && push(cond, ! pop(cond)),
  1250. X                    next    if /^@@ELSE$/;
  1251. X
  1252. X    $d == $cond[$#cond-1] && (pop(cond), pop(cond)), $d--,
  1253. X                    next    if /^@@FI$/;
  1254. X
  1255. X                    next    if ! $cond[$#cond];
  1256. X
  1257. X    &doinclude($1),         next    if /^@@INCLUDE (.*)$/;
  1258. X
  1259. X    (print STDERR $1),        next    if /^@@MESSAGE (.*)$/;
  1260. X
  1261. X    # if not keyword, substitute variable and print (conditionals first)
  1262. X
  1263. X    while (/\$\${([^\?}]*)\?([^}]*)/) {    # find all conditionals
  1264. X        $cond= $1;
  1265. X        $value= $2;
  1266. X        &docondition($cond)? s/\$\${[^}]*}/$value/ : s/\$\${[^}]*}//;
  1267. X    }
  1268. X
  1269. X    while (/.*\$\$(\w+).*/) {        # find all variables occurrences
  1270. X        $value= eval "\$$1";        # compute the value
  1271. X        s/\$\$$1/$value/;            # and do the replacement
  1272. X    }
  1273. X
  1274. X    s/\\\$\\\$/\$\$/g;            # restore all escaped $$
  1275. X
  1276. X        &printlongline($_);
  1277. X    }
  1278. X    close (FILE);
  1279. X}}
  1280. X
  1281. X#------------------------------------------------------------------------------
  1282. X# doinclude - execute the INCLUDE directive
  1283. X#------------------------------------------------------------------------------
  1284. X
  1285. Xsub doinclude {{
  1286. X    local($file)= $_[1];
  1287. X
  1288. X    $n++;                                                # for recursion
  1289. X    open("SAVE$n", "<&FILE") || die "dup: $!\n";    # save handle on "stack"
  1290. X    $where=tell(FILE);                                  # and place
  1291. X    &dofile("$LIBDIR/$file");                           # recurse on dofile
  1292. X    open(FILE, "<&SAVE$n") || die "dup: $!\n";      # restore handle
  1293. X    seek(FILE, $where, 0);                              # and place
  1294. X}}
  1295. X
  1296. X
  1297. X#------------------------------------------------------------------------------
  1298. X# docondition - evaluate a condition
  1299. X#------------------------------------------------------------------------------
  1300. X
  1301. Xsub docondition {{
  1302. X    local($condition)= "$".$_[1];
  1303. X
  1304. X    $condition=~ s/\./_/g;
  1305. X    $condition=~ s/\|/\|\|\$/g;
  1306. X    $condition=~ s/\&/\&\&\$/g;
  1307. X
  1308. X    "" ne eval $condition;
  1309. X}}
  1310. X
  1311. X#------------------------------------------------------------------------------
  1312. X# printlongline - fold lines with continuation characters
  1313. X#------------------------------------------------------------------------------
  1314. X
  1315. Xsub printlongline {{
  1316. X    local($line)= $_[1];
  1317. X    local($max)= 80;    # for 1st line - 80, then less ('cause of tab)
  1318. X
  1319. X    while (length($line) > $max) {
  1320. X
  1321. X    # split at last white space before $max-2
  1322. X    ($l1, $l2)= ($1, $2)     if substr($line, 1, $max-2) =~/(.*)\s([^\s]*)/;
  1323. X
  1324. X    # print segment and repeat
  1325. X    printf "$l1 \\\n\t";
  1326. X    $line= $l2.substr($line, $max-1);
  1327. X    $max= 72;
  1328. X    }
  1329. X
  1330. X    # print last stuff
  1331. X    print $line;
  1332. X}}
  1333. END_OF_FILE
  1334.   if test 10104 -ne `wc -c <'mkskel.pl'`; then
  1335.     echo shar: \"'mkskel.pl'\" unpacked with wrong size!
  1336.   fi
  1337.   # end of 'mkskel.pl'
  1338. fi
  1339. echo shar: End of archive 1 \(of 1\).
  1340. cp /dev/null ark1isdone
  1341. MISSING=""
  1342. for I in 1 ; do
  1343.     if test ! -f ark${I}isdone ; then
  1344.     MISSING="${MISSING} ${I}"
  1345.     fi
  1346. done
  1347. if test "${MISSING}" = "" ; then
  1348.     echo You have the archive.
  1349.     rm -f ark[1-9]isdone
  1350. else
  1351.     echo You still must unpack the following archives:
  1352.     echo "        " ${MISSING}
  1353. fi
  1354. exit 0
  1355. exit 0 # Just in case...
  1356.