home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sources / misc / 3877 < prev    next >
Encoding:
Text File  |  1992-08-26  |  37.0 KB  |  1,361 lines

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