/contrib/bind9/make/mkdep.in

https://bitbucket.org/freebsd/freebsd-head/ · Autoconf · 187 lines · 90 code · 20 blank · 77 comment · 18 complexity · efdf4ff0388ed5a24999950a9dc7c254 MD5 · raw file

  1. #!/bin/sh -
  2. ##
  3. ## Modified to handle -vpath <path> option by Michael Graff, ISC.
  4. ## The purpose of this is to allow this script to run outside of the
  5. ## source directory, for instance when running configure with
  6. ## ../bind9-mainline/configure
  7. ## and still have "make depend" work.
  8. ##
  9. ## ++Copyright++ 1987
  10. ## -
  11. ## Copyright (c) 1987 Regents of the University of California.
  12. ## All rights reserved.
  13. ##
  14. ## Redistribution and use in source and binary forms, with or without
  15. ## modification, are permitted provided that the following conditions
  16. ## are met:
  17. ## 1. Redistributions of source code must retain the above copyright
  18. ## notice, this list of conditions and the following disclaimer.
  19. ## 2. Redistributions in binary form must reproduce the above copyright
  20. ## notice, this list of conditions and the following disclaimer in the
  21. ## documentation and/or other materials provided with the distribution.
  22. ## 3. All advertising materials mentioning features or use of this software
  23. ## must display the following acknowledgement:
  24. ## This product includes software developed by the University of
  25. ## California, Berkeley and its contributors.
  26. ## 4. Neither the name of the University nor the names of its contributors
  27. ## may be used to endorse or promote products derived from this software
  28. ## without specific prior written permission.
  29. ## THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  30. ## ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  31. ## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  32. ## ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  33. ## FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  34. ## DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  35. ## OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  36. ## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  37. ## LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  38. ## OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  39. ## SUCH DAMAGE.
  40. ## -
  41. ## Portions Copyright (c) 1993 by Digital Equipment Corporation.
  42. ##
  43. ## Permission to use, copy, modify, and distribute this software for any
  44. ## purpose with or without fee is hereby granted, provided that the above
  45. ## copyright notice and this permission notice appear in all copies, and that
  46. ## the name of Digital Equipment Corporation not be used in advertising or
  47. ## publicity pertaining to distribution of the document or software without
  48. ## specific, written prior permission.
  49. ##
  50. ## THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
  51. ## WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
  52. ## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
  53. ## CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  54. ## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  55. ## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
  56. ## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  57. ## SOFTWARE.
  58. ## -
  59. ## --Copyright--
  60. #
  61. # @(#)mkdep.sh 5.12 (Berkeley) 6/30/88
  62. #
  63. MAKE=Makefile # default makefile name is "Makefile"
  64. while :
  65. do case "$1" in
  66. # -vpath allows one to select a virtual path for .c files
  67. -vpath)
  68. VPATH=$2;
  69. shift; shift ;;
  70. # -f allows you to select a makefile name
  71. -f)
  72. MAKE=$2
  73. shift; shift ;;
  74. # the -p flag produces "program: program.c" style dependencies
  75. # so .o's don't get produced
  76. -p)
  77. SED='s;\.o;;'
  78. shift ;;
  79. *)
  80. break ;;
  81. esac
  82. done
  83. if [ $# = 0 ] ; then
  84. echo 'usage: mkdep [-vpath path] [-p] [-f makefile] [flags] file ...'
  85. exit 1
  86. fi
  87. if [ ! -w $MAKE ]; then
  88. echo "mkdep: no writeable file \"$MAKE\""
  89. exit 1
  90. fi
  91. TMP=mkdep$$
  92. trap 'rm -f $TMP ; exit 1' 1 2 3 13 15
  93. cp $MAKE ${MAKE}.bak
  94. sed -e '/DO NOT DELETE THIS LINE/,$d' < $MAKE > $TMP
  95. cat << _EOF_ >> $TMP
  96. # DO NOT DELETE THIS LINE -- mkdep uses it.
  97. # DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
  98. _EOF_
  99. # If your compiler doesn't have -M, add it. If you can't, the next two
  100. # lines will try and replace the "cc -M". The real problem is that this
  101. # hack can't deal with anything that requires a search path, and doesn't
  102. # even try for anything using bracket (<>) syntax.
  103. #
  104. # egrep '^#include[ ]*".*"' /dev/null $* |
  105. # sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' -e 's/\.c/.o/' |
  106. if [ X"${VPATH}" != X ] ; then
  107. for arg in $* ; do
  108. case "$arg" in
  109. -*)
  110. newargs="$newargs $arg"
  111. ;;
  112. *)
  113. newargs="$newargs $VPATH/$arg"
  114. ;;
  115. esac
  116. done
  117. else
  118. newargs="$*";
  119. fi
  120. MKDEPPROG="@MKDEPPROG@"
  121. if [ X"${MKDEPPROG}" != X ]; then
  122. @SHELL@ -c "${MKDEPPROG} ${newargs}"
  123. else
  124. @MKDEPCC@ @MKDEPCFLAGS@ ${newargs} |
  125. sed "
  126. s; \\./; ;g
  127. s; \\\\; ;g
  128. @LIBTOOL_MKDEP_SED@
  129. $SED" |
  130. awk '$1 ~ /:$/ {
  131. if (rec != "")
  132. print rec;
  133. if (NF == 1)
  134. rec = $1;
  135. else
  136. rec = $1 " " $2;
  137. for (i = 3; i <= NF; i++) {
  138. if (length(rec $i) > 76) {
  139. print rec " \\";
  140. rec = " " $i;
  141. } else {
  142. rec = rec " " $i;
  143. }
  144. }
  145. next;
  146. }
  147. {
  148. for (i = 1; i <= NF; i++) {
  149. if (length(rec $i) > 76) {
  150. print rec, "\\";
  151. rec = " " $i;
  152. } else {
  153. rec = rec " " $i;
  154. }
  155. }
  156. }
  157. END {
  158. print rec
  159. }' >> $TMP
  160. fi
  161. cat << _EOF_ >> $TMP
  162. # IF YOU PUT ANYTHING HERE IT WILL GO AWAY
  163. _EOF_
  164. # copy to preserve permissions
  165. cp $TMP $MAKE
  166. rm -f ${MAKE}.bak $TMP
  167. exit 0