srcanamdw/codescanner/pyinstaller/source/linux/makemakefile.py
author noe\swadi
Thu, 18 Feb 2010 12:29:02 +0530
changeset 1 22878952f6e2
permissions -rw-r--r--
Committing the CodeScanner Core tool This component has been moved from the StaticAnaApps package. BUG : 5889 (http://developer.symbian.org/webbugs/show_bug.cgi?id=5889).
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
     1
# Write the actual Makefile.
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
     2
# Copyright (C) 2005, Giovanni Bajo
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
     3
# Based on previous work under copyright (c) 2002 McMillan Enterprises, Inc.
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
     4
#
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
     5
# This program is free software; you can redistribute it and/or
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
     6
# modify it under the terms of the GNU General Public License
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
     7
# as published by the Free Software Foundation; either version 2
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
     8
# of the License, or (at your option) any later version.
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
     9
#
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    10
# This program is distributed in the hope that it will be useful,
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    13
# GNU General Public License for more details.
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    14
#
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    15
# You should have received a copy of the GNU General Public License
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    16
# along with this program; if not, write to the Free Software
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    18
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    19
import os
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    20
import string
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    21
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    22
def writevars(outfp, makevars, target):
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    23
    outfp.write("# Makefile generated by freeze.py script\n\n")
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    24
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    25
    keys = makevars.keys()
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    26
    keys.sort()
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    27
    for key in keys:
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    28
        outfp.write("%s=%s\n" % (key, makevars[key]))
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    29
    outfp.write("\nall: %s\n\n" % target)
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    30
    outfp.write("\nclean:\n\t-rm -f *.o %s\n" % target)
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    31
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    32
def writerules(outfp, files, suffix, dflag, target):
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    33
    deps = []
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    34
    for i in range(len(files)):
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    35
        file = files[i]
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    36
        if file[-2:] == '.c':
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    37
            base = os.path.basename(file)
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    38
            dest = base[:-2] + suffix + '.o'
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    39
            outfp.write("%s: %s\n" % (dest, file))
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    40
            outfp.write("\t$(CC) %s $(CFLAGS) -c %s -o %s\n" % (dflag, file, dest))
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    41
            files[i] = dest
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    42
            deps.append(dest)
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    43
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    44
    outfp.write("\n%s: %s\n" % (target, string.join(deps)))
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    45
    outfp.write("\t$(CC) %s -o %s $(LDLAST)\n" %
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    46
                (string.join(files), target))
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    47
22878952f6e2 Committing the CodeScanner Core tool
noe\swadi
parents:
diff changeset
    48