xref: /aoo41x/main/solenv/gbuild/processdeps.awk (revision cdf0e10c)
1#*************************************************************************
2#
3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4#
5# Copyright 2000, 2010 Oracle and/or its affiliates.
6#
7# OpenOffice.org - a multi-platform office productivity suite
8#
9# This file is part of OpenOffice.org.
10#
11# OpenOffice.org is free software: you can redistribute it and/or modify
12# it under the terms of the GNU Lesser General Public License version 3
13# only, as published by the Free Software Foundation.
14#
15# OpenOffice.org is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18# GNU Lesser General Public License version 3 for more details
19# (a copy is included in the LICENSE file that accompanied this code).
20#
21# You should have received a copy of the GNU Lesser General Public License
22# version 3 along with OpenOffice.org.  If not, see
23# <http://www.openoffice.org/license.html>
24# for a copy of the LGPLv3 License.
25#
26#*************************************************************************
27
28# this awk script mangles makedepend output for a single object file
29# usage:
30# awk -f .../processdeps.awk \
31#     -v OUTDIR=outdir \
32#     -v SRCDIR=srcdir \
33#     -v WORKDIR=workdir \
34#     -v REPODIR=repodir \
35#     -v OBJECTFILE=objectfile
36# called like this the script will read from stdin
37# and write to stdout. It will:
38#  - replace the objectfile with the one given on the commandline
39#  - normalize paths to mixed paths (replacing all \ with /)
40#  - replace the string given as WORKDIR with $(WORKDIR)/
41#  - replace the string given as OUTDIR with $(OUTDIR)/
42#  - replace the string given as SRCDIR with $(SRCDIR)/
43#  - replace the string given as REPODIR with $(REPODIR)/
44#  - translates absolute mixed windows paths to cygwin paths by
45#    substituting a path starting with X:... to /cygdrive/X/...
46
47function mangle_path(path) {
48    gsub("\\\\", "/", path);
49    if( path ~ /^[a-zA-Z]:/ )
50        path = tolower(substr(path,0,1)) substr(path,2);
51    gsub(WORKDIR, "$(WORKDIR)/", path);
52    gsub(OUTDIR, "$(OUTDIR)/", path);
53    gsub(SRCDIR, "$(SRCDIR)/", path);
54    gsub(REPODIR, "$(REPODIR)/", path);
55    if( path ~ /^[a-zA-Z]:/ )
56        path = "/cygdrive/" tolower(substr(path,0,1)) substr(path,3);
57    return path;
58}
59
60BEGIN {
61   WORKDIR = tolower(substr(WORKDIR,0,1)) substr(WORKDIR,2);
62   OUTDIR = tolower(substr(OUTDIR,0,1)) substr(OUTDIR,2);
63   SRCDIR = tolower(substr(SRCDIR,0,1)) substr(SRCDIR,2);
64   REPODIR = tolower(substr(REPODIR,0,1)) substr(REPODIR,2);
65#   print "# WORKDIR=" WORKDIR;
66#   print "# OUTDIR=" OUTDIR;
67#   print "# SRCDIR=" SRCDIR;
68#   print "# REPODIR=" REPODIR;
69   print mangle_path(OBJECTFILE) ": \\";
70}
71
72/^[^#]/ {
73    print "\t" mangle_path($2) " \\";
74}
75
76END {
77    print "\n";
78}
79