11590Srgrimes#!/bin/sh - 21590Srgrimes# 31590Srgrimes# Copyright (c) 1991, 1993 41590Srgrimes# The Regents of the University of California. All rights reserved. 51590Srgrimes# 61590Srgrimes# Redistribution and use in source and binary forms, with or without 71590Srgrimes# modification, are permitted provided that the following conditions 81590Srgrimes# are met: 91590Srgrimes# 1. Redistributions of source code must retain the above copyright 101590Srgrimes# notice, this list of conditions and the following disclaimer. 111590Srgrimes# 2. Redistributions in binary form must reproduce the above copyright 121590Srgrimes# notice, this list of conditions and the following disclaimer in the 131590Srgrimes# documentation and/or other materials provided with the distribution. 141590Srgrimes# 4. Neither the name of the University nor the names of its contributors 151590Srgrimes# may be used to endorse or promote products derived from this software 161590Srgrimes# without specific prior written permission. 171590Srgrimes# 181590Srgrimes# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 191590Srgrimes# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 201590Srgrimes# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 211590Srgrimes# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 221590Srgrimes# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 231590Srgrimes# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 241590Srgrimes# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 251590Srgrimes# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 261590Srgrimes# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 271590Srgrimes# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 281590Srgrimes# SUCH DAMAGE. 291590Srgrimes# 30216370Sjoel# $FreeBSD$ 31216370Sjoel# 321590Srgrimes# @(#)mkdep.sh 8.1 (Berkeley) 6/6/93 331590Srgrimes# 341590Srgrimes 351590SrgrimesPATH=/bin:/usr/bin:/usr/ucb:/usr/old/bin 361590Srgrimesexport PATH 371590Srgrimes 381590SrgrimesD=.depend # default dependency file is .depend 391590Srgrimesappend=0 401590Srgrimes 411590Srgrimeswhile : 421590Srgrimes do case "$1" in 431590Srgrimes # -a appends to the depend file 441590Srgrimes -a) 451590Srgrimes append=1 461590Srgrimes shift ;; 471590Srgrimes 481590Srgrimes # -f allows you to select a makefile name 491590Srgrimes -f) 501590Srgrimes D=$2 511590Srgrimes shift; shift ;; 521590Srgrimes 531590Srgrimes # the -p flag produces "program: program.c" style dependencies 541590Srgrimes # so .o's don't get produced 551590Srgrimes -p) 561590Srgrimes SED='s;\.o ; ;' 571590Srgrimes shift ;; 581590Srgrimes *) 591590Srgrimes break ;; 601590Srgrimes esac 611590Srgrimesdone 621590Srgrimes 631590Srgrimesif [ $# = 0 ] ; then 641590Srgrimes echo 'usage: mkdep [-p] [-f depend_file] [cc_flags] file ...' 651590Srgrimes exit 1 661590Srgrimesfi 671590Srgrimes 681590SrgrimesTMP=/tmp/mkdep$$ 691590Srgrimes 7038520Scracauertrap 'rm -f $TMP ; trap 2 ; kill -2 $$' 1 2 3 13 15 711590Srgrimes 721590Srgrimescc -M $* | 731590Srgrimessed " 741590Srgrimes s; \./; ;g 751590Srgrimes /\.c:$/d 761590Srgrimes $SED" | 771590Srgrimesawk '{ 781590Srgrimes if ($1 != prev) { 791590Srgrimes if (rec != "") 801590Srgrimes print rec; 811590Srgrimes rec = $0; 821590Srgrimes prev = $1; 831590Srgrimes } 841590Srgrimes else { 851590Srgrimes if (length(rec $2) > 78) { 861590Srgrimes print rec; 871590Srgrimes rec = $0; 881590Srgrimes } 891590Srgrimes else 901590Srgrimes rec = rec " " $2 911590Srgrimes } 921590Srgrimes} 931590SrgrimesEND { 941590Srgrimes print rec 951590Srgrimes}' > $TMP 961590Srgrimes 971590Srgrimesif [ $? != 0 ]; then 981590Srgrimes echo 'mkdep: compile failed.' 991590Srgrimes rm -f $TMP 1001590Srgrimes exit 1 1011590Srgrimesfi 1021590Srgrimes 1031590Srgrimesif [ $append = 1 ]; then 1041590Srgrimes cat $TMP >> $D 1051590Srgrimes rm -f $TMP 1061590Srgrimeselse 1071590Srgrimes mv $TMP $D 1081590Srgrimesfi 1091590Srgrimesexit 0 110