1*b1cdbd2cSJim Jagielski#************************************************************** 2*b1cdbd2cSJim Jagielski# 3*b1cdbd2cSJim Jagielski# Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski# or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski# distributed with this work for additional information 6*b1cdbd2cSJim Jagielski# regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski# to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski# "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski# with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski# 11*b1cdbd2cSJim Jagielski# http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski# 13*b1cdbd2cSJim Jagielski# Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski# software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski# KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski# specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski# under the License. 19*b1cdbd2cSJim Jagielski# 20*b1cdbd2cSJim Jagielski#************************************************************** 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski# this awk script mangles makedepend output for a single object file 23*b1cdbd2cSJim Jagielski# usage: 24*b1cdbd2cSJim Jagielski# awk -f .../processdeps.awk \ 25*b1cdbd2cSJim Jagielski# -v OUTDIR=outdir \ 26*b1cdbd2cSJim Jagielski# -v SRCDIR=srcdir \ 27*b1cdbd2cSJim Jagielski# -v WORKDIR=workdir \ 28*b1cdbd2cSJim Jagielski# -v REPODIR=repodir \ 29*b1cdbd2cSJim Jagielski# -v OBJECTFILE=objectfile 30*b1cdbd2cSJim Jagielski# called like this the script will read from stdin 31*b1cdbd2cSJim Jagielski# and write to stdout. It will: 32*b1cdbd2cSJim Jagielski# - replace the objectfile with the one given on the commandline 33*b1cdbd2cSJim Jagielski# - normalize paths to mixed paths (replacing all \ with /) 34*b1cdbd2cSJim Jagielski# - replace the string given as WORKDIR with $(WORKDIR)/ 35*b1cdbd2cSJim Jagielski# - replace the string given as OUTDIR with $(OUTDIR)/ 36*b1cdbd2cSJim Jagielski# - replace the string given as SRCDIR with $(SRCDIR)/ 37*b1cdbd2cSJim Jagielski# - replace the string given as REPODIR with $(REPODIR)/ 38*b1cdbd2cSJim Jagielski# - translates absolute mixed windows paths to cygwin paths by 39*b1cdbd2cSJim Jagielski# substituting a path starting with X:... to /cygdrive/X/... 40*b1cdbd2cSJim Jagielski 41*b1cdbd2cSJim Jagielskifunction mangle_path(path) { 42*b1cdbd2cSJim Jagielski gsub("\\\\", "/", path); 43*b1cdbd2cSJim Jagielski if( path ~ /^[a-zA-Z]:/ ) 44*b1cdbd2cSJim Jagielski path = tolower(substr(path,0,1)) substr(path,2); 45*b1cdbd2cSJim Jagielski gsub(WORKDIR, "$(WORKDIR)/", path); 46*b1cdbd2cSJim Jagielski gsub(OUTDIR, "$(OUTDIR)/", path); 47*b1cdbd2cSJim Jagielski gsub(SRCDIR, "$(SRCDIR)/", path); 48*b1cdbd2cSJim Jagielski gsub(REPODIR, "$(REPODIR)/", path); 49*b1cdbd2cSJim Jagielski if( path ~ /^[a-zA-Z]:/ ) 50*b1cdbd2cSJim Jagielski path = "/cygdrive/" tolower(substr(path,0,1)) substr(path,3); 51*b1cdbd2cSJim Jagielski return path; 52*b1cdbd2cSJim Jagielski} 53*b1cdbd2cSJim Jagielski 54*b1cdbd2cSJim JagielskiBEGIN { 55*b1cdbd2cSJim Jagielski WORKDIR = tolower(substr(WORKDIR,0,1)) substr(WORKDIR,2); 56*b1cdbd2cSJim Jagielski OUTDIR = tolower(substr(OUTDIR,0,1)) substr(OUTDIR,2); 57*b1cdbd2cSJim Jagielski SRCDIR = tolower(substr(SRCDIR,0,1)) substr(SRCDIR,2); 58*b1cdbd2cSJim Jagielski REPODIR = tolower(substr(REPODIR,0,1)) substr(REPODIR,2); 59*b1cdbd2cSJim Jagielski# print "# WORKDIR=" WORKDIR; 60*b1cdbd2cSJim Jagielski# print "# OUTDIR=" OUTDIR; 61*b1cdbd2cSJim Jagielski# print "# SRCDIR=" SRCDIR; 62*b1cdbd2cSJim Jagielski# print "# REPODIR=" REPODIR; 63*b1cdbd2cSJim Jagielski print mangle_path(OBJECTFILE) ": \\"; 64*b1cdbd2cSJim Jagielski} 65*b1cdbd2cSJim Jagielski 66*b1cdbd2cSJim Jagielski/^[^#]/ { 67*b1cdbd2cSJim Jagielski print "\t" mangle_path($2) " \\"; 68*b1cdbd2cSJim Jagielski} 69*b1cdbd2cSJim Jagielski 70*b1cdbd2cSJim JagielskiEND { 71*b1cdbd2cSJim Jagielski print "\n"; 72*b1cdbd2cSJim Jagielski} 73