1478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project#!/bin/sh - 2478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project# 3478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project# Copyright (c) 1994, 1996 4478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project# The Regents of the University of California. All rights reserved. 5478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project# 6478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project# Redistribution and use in source and binary forms are permitted 7478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project# provided that this notice is preserved and that due credit is given 8478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project# to the University of California at Berkeley. The name of the University 9478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project# may not be used to endorse or promote products derived from this 10478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project# software without specific prior written permission. This software 11478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project# is provided ``as is'' without express or implied warranty. 12478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project# 13478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project# @(#)mkdep.sh 5.11 (Berkeley) 5/5/88 14478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project# 15478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project 16511eca30a483e912c274e1d8ba3a0f8f081e2227JP AbgrallPATH=/bin:/usr/bin:/usr/ucb:/usr/local:/usr/local/bin:/usr/sfw/bin 17478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Projectexport PATH 18478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project 19478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source ProjectMAKE=Makefile # default makefile name is "Makefile" 20478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source ProjectCC=cc # default C compiler is "cc" 21511eca30a483e912c274e1d8ba3a0f8f081e2227JP AbgrallDEPENDENCY_CFLAG=-M # default dependency-generation flag is -M 22478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project 23478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Projectwhile : 24478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project do case "$1" in 25478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project # -c allows you to specify the C compiler 26478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project -c) 27478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project CC=$2 28478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project shift; shift ;; 29478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project 30478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project # -f allows you to select a makefile name 31478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project -f) 32478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project MAKE=$2 33478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project shift; shift ;; 34478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project 35511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall # -m allows you to specify the dependency-generation flag 36511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall -m) 37511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall DEPENDENCY_CFLAG=$2 38511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall shift; shift ;; 39511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall 40478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project # the -p flag produces "program: program.c" style dependencies 41478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project # so .o's don't get produced 42478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project -p) 43478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project SED='s;\.o;;' 44478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project shift ;; 45478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project *) 46478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project break ;; 47478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project esac 48478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Projectdone 49478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project 50478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Projectif [ $# = 0 ] ; then 51511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall echo 'usage: mkdep [-p] [-c cc] [-f makefile] [-m dependency-cflag] [flags] file ...' 52478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project exit 1 53478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Projectfi 54478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project 55478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Projectif [ ! -w $MAKE ]; then 56478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project echo "mkdep: no writeable file \"$MAKE\"" 57478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project exit 1 58478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Projectfi 59478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project 60478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source ProjectTMP=/tmp/mkdep$$ 61478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project 62478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Projecttrap 'rm -f $TMP ; exit 1' 1 2 3 13 15 63478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project 64478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Projectcp $MAKE ${MAKE}.bak 65478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project 66478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Projectsed -e '/DO NOT DELETE THIS LINE/,$d' < $MAKE > $TMP 67478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project 68478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Projectcat << _EOF_ >> $TMP 69478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project# DO NOT DELETE THIS LINE -- mkdep uses it. 70478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. 71478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project 72478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project_EOF_ 73478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project 74478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project# If your compiler doesn't have -M, add it. If you can't, the next two 75478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project# lines will try and replace the "cc -M". The real problem is that this 76478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project# hack can't deal with anything that requires a search path, and doesn't 77478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project# even try for anything using bracket (<>) syntax. 78478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project# 79478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project# egrep '^#include[ ]*".*"' /dev/null $* | 80478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project# sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' -e 's/\.c/.o/' | 81478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project 82478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project# XXX this doesn't work with things like "-DDECLWAITSTATUS=union\ wait" 83511eca30a483e912c274e1d8ba3a0f8f081e2227JP Abgrall$CC $DEPENDENCY_CFLAG $* | 84478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Projectsed " 85478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project s; \./; ;g 86478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project $SED" | 87478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Projectawk '{ 88478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project if ($1 != prev) { 89478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project if (rec != "") 90478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project print rec; 91478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project rec = $0; 92478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project prev = $1; 93478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project } 94478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project else { 95478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project if (length(rec $2) > 78) { 96478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project print rec; 97478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project rec = $0; 98478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project } 99478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project else 100478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project rec = rec " " $2 101478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project } 102478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project} 103478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source ProjectEND { 104478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project print rec 105478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project}' >> $TMP 106478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project 107478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Projectcat << _EOF_ >> $TMP 108478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project 109478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project# IF YOU PUT ANYTHING HERE IT WILL GO AWAY 110478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project_EOF_ 111478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project 112478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Project# copy to preserve permissions 113478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Projectcp $TMP $MAKE 114478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Projectrm -f ${MAKE}.bak $TMP 115478ab6c8b5bc982589be32eae1e5736efe721b58The Android Open Source Projectexit 0 116