1
|
1 |
# Write the actual Makefile.
|
|
2 |
# Copyright (C) 2005, Giovanni Bajo
|
|
3 |
# Based on previous work under copyright (c) 2002 McMillan Enterprises, Inc.
|
|
4 |
#
|
|
5 |
# This program is free software; you can redistribute it and/or
|
|
6 |
# modify it under the terms of the GNU General Public License
|
|
7 |
# as published by the Free Software Foundation; either version 2
|
|
8 |
# of the License, or (at your option) any later version.
|
|
9 |
#
|
|
10 |
# This program is distributed in the hope that it will be useful,
|
|
11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
# GNU General Public License for more details.
|
|
14 |
#
|
|
15 |
# You should have received a copy of the GNU General Public License
|
|
16 |
# along with this program; if not, write to the Free Software
|
|
17 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
18 |
|
|
19 |
import os
|
|
20 |
import string
|
|
21 |
|
|
22 |
def writevars(outfp, makevars, target):
|
|
23 |
outfp.write("# Makefile generated by freeze.py script\n\n")
|
|
24 |
|
|
25 |
keys = makevars.keys()
|
|
26 |
keys.sort()
|
|
27 |
for key in keys:
|
|
28 |
outfp.write("%s=%s\n" % (key, makevars[key]))
|
|
29 |
outfp.write("\nall: %s\n\n" % target)
|
|
30 |
outfp.write("\nclean:\n\t-rm -f *.o %s\n" % target)
|
|
31 |
|
|
32 |
def writerules(outfp, files, suffix, dflag, target):
|
|
33 |
deps = []
|
|
34 |
for i in range(len(files)):
|
|
35 |
file = files[i]
|
|
36 |
if file[-2:] == '.c':
|
|
37 |
base = os.path.basename(file)
|
|
38 |
dest = base[:-2] + suffix + '.o'
|
|
39 |
outfp.write("%s: %s\n" % (dest, file))
|
|
40 |
outfp.write("\t$(CC) %s $(CFLAGS) -c %s -o %s\n" % (dflag, file, dest))
|
|
41 |
files[i] = dest
|
|
42 |
deps.append(dest)
|
|
43 |
|
|
44 |
outfp.write("\n%s: %s\n" % (target, string.join(deps)))
|
|
45 |
outfp.write("\t$(CC) %s -o %s $(LDLAST)\n" %
|
|
46 |
(string.join(files), target))
|
|
47 |
|
|
48 |
|