1#!/bin/sh 2########################################################################### 3# LPRng - An Extended Print Spooler System 4# 5# Copyright 1988-1995 Patrick Powell, San Diego State University 6# papowell@sdsu.edu 7# See LICENSE for conditions of use. 8# 9########################################################################### 10# MODULE: UTILS/makeinc 11# PURPOSE: find dependencies for files 12# NOTE: uses GCC to expand the files 13# Usage: cd source_directory; makeinc *.o 14# Note: you have to modify the -I. -I./include line 15# if you change structure 16# makeinc,v 3.1 1996/12/28 21:40:52 papowell Exp 17########################################################################## 18for i in $* ; do 19 lo=`echo $i | sed -e 's/\.o/.lo/g'` 20 o=`echo $i | sed -e 's/\.lo/.o/g'` 21 I=`echo $i | sed -e 's/\.lo/.c/' -e 's/\.o/.c/' ` 22 #echo "# doing '$i' LO '$lo' O '$o' C '$I'" 23 II=`ls ./*/$I 2>/dev/null` 24 if [ ! -n "$II" ]; then II=`ls ./$I 2>/dev/null`; fi; 25 #echo "# II $II" 26 gcc ${CFLAGS} -E \ 27 -I. -I./include -I.. \ 28 $II >/tmp/s 29 awk ' 30/^# [0-9]/ { 31if( $3 ~ /usr/ ) next; 32l = substr( $3, 2); l = substr( l, 1, length(l)-1); 33if( l ~ /\.c$/ ) next; 34print l; } 35 36{ next; }' </tmp/s >/tmp/t 37 sort /tmp/t |uniq | sed -e 's,.*/,,' >/tmp/w 38 echo -n $o $lo ":" 39 awk 'BEGIN { printf "\t" } 40 {printf "%s ", $0} 41 END { print }' < /tmp/w 42done 43