home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume1 / 8712 / 11 < prev    next >
Encoding:
Internet Message Format  |  1990-07-13  |  3.5 KB

  1. Path: uunet!husc6!rutgers!clyde!cbosgd!mandrill!hal!ncoast!allbery
  2. From: dg@wrs.UUCP (David Goodenough)
  3. Newsgroups: comp.sources.misc
  4. Subject: Re: Desperately Seeking Makefile Maker
  5. Message-ID: <6902@ncoast.UUCP>
  6. Date: 26 Dec 87 02:37:27 GMT
  7. Sender: allbery@ncoast.UUCP
  8. Organization: Wind River Systems, Emeryville, CA
  9. Lines: 113
  10. Approved: allbery@ncoast.UUCP
  11. X-Archive: comp.sources.misc/8712/11
  12.  
  13. Apologies for posting to comp.lang.c; I don't know what the original
  14. was in here for, this has been cross posted to comp.sources.misc
  15. I suspect that any followups would be best directed there.
  16. [Moderator's note:  He suspects wrongly.  Followups to comp.sources.d please.
  17. ++bsa]
  18.  
  19. >    Is there a program available that creates makefiles...
  20.  
  21. I use the following shell script to create "self generating" makefiles.
  22.  
  23. Basically you create a directory, put all the .c's into it that will
  24. make up your program, then say
  25.  
  26. % mkmake prog >makefile
  27.  
  28. where prog is the output program name.
  29. Then say
  30.  
  31. % make source
  32.  
  33. to generate the list of .c and .o files that make up the program, and
  34. then say
  35.  
  36. % make depend
  37.  
  38. to make the dependancy list at the bottom. Sadly this is not too clever:
  39. it can't handle special awk / yacc / lex / assembler / etc. etc. etc.
  40. runs, but for starters I find it useful.
  41.  
  42. The things you will be able to make are:
  43.  
  44. prog - full bore program creation;
  45. clean - remove .o files, core images and other junk;
  46. lintout - do a lint job on the source files;
  47. errs - run a normal 'make prog' but put output in makeout;
  48. tags - create a tags file for vi;
  49. source - rebuild the list of .c and .o files that constitute the program;
  50. depend - build dependancies for the source files.
  51. --
  52.         dg@wrs.UUCP - David Goodenough
  53.  
  54.     ..... !rtech!--\            +---+
  55.             >--!wrs!dg        | +-+-+
  56.     ....... !sun!--/            +-+-+ |
  57.                           +---+
  58.  
  59. --- cut here --- cut here --- cut here --- cut here --- cut here ---
  60. #! /bin/sh
  61. # mkmake - create a makefile
  62. echo '# makefile for' $1
  63. echo ''
  64. echo CFLAGS= -O
  65. echo LFLAGS= -hbx
  66. echo SRC=
  67. echo OBJ=
  68. echo ''
  69. echo -n $1
  70. echo ':    ${OBJ}'
  71. echo '    cc ${CFLAGS} -o' $1 '${OBJ}'
  72. echo ''
  73. echo clean:
  74. echo '    rm -f core lintout makeout tags makefile.bak *.o'
  75. echo ''
  76. echo 'lintout: ${SRC}'
  77. echo '    \@rm -f lintout'
  78. echo '    lint ${LFLAGS} ${SRC} >lintout'
  79. echo ''
  80. echo errs:
  81. echo '    \@rm -f makeout'
  82. echo "    make $1 >makeout"
  83. echo ''
  84. echo 'tags:    ${SRC}'
  85. echo '    \@rm -f tags'
  86. echo '    ctags ${SRC}'
  87. echo ''
  88. echo 'source:'
  89. echo '    mv makefile makefile.bak'
  90. echo '    head -4 makefile.bak >makefile'
  91. echo '    echo SRC= `ls *.c` >>makefile'
  92. echo '    echo OBJ= `ls *.c | sed s/c$$/o/` >>makefile'
  93. echo '    tail +7 <makefile.bak >>makefile'
  94. echo ''
  95. echo 'depend: ${SRC}'
  96. echo '    for i in ${SRC}; do\'
  97. echo -n '        cc -M $$i | sed -e '
  98. echo "'s, \./, ,' | \"
  99. echo -n "        awk '"
  100. echo '{ if ($$1 != prev) { if (rec != "") print rec; \'
  101. echo '        rec = $$0; prev = $$1; } \'
  102. echo '        else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \'
  103. echo '        else rec = rec " " $$2 } } \'
  104. echo "        END { print rec }'; done >makedep"
  105. echo -n "    echo '/^# DO NOT DELETE THIS LINE/+2,"
  106. echo -n '$$d'
  107. echo "' >eddep"
  108. echo -n "    echo '"
  109. echo -n '$$r '
  110. echo "makedep' >>eddep"
  111. echo "    echo 'w' >>eddep"
  112. echo '    cp makefile makefile.bak'
  113. echo '    ed - makefile <eddep'
  114. echo '    rm eddep makedep'
  115. echo "    echo '' >>makefile"
  116. echo "    echo '# DEPENDENCIES MUST END AT END OF FILE' >>makefile"
  117. echo "    echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >>makefile"
  118. echo "    echo '# see make depend above' >>makefile"
  119. echo ''
  120. echo '.c.o:'
  121. echo '    cc ${CFLAGS} -c $*.c'
  122. echo ''
  123. echo '# DO NOT DELETE THIS LINE -- make depend uses it'
  124. echo ''
  125. echo ''
  126.