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