Added option --MMD= to gpp_inc.py for automated dependencies.
This commit is contained in:
@@ -29,7 +29,7 @@ src/compress_nrv*
|
||||
src/*.rc
|
||||
|
||||
stub/MMakefile
|
||||
stub/tmp
|
||||
stub/tmp*
|
||||
stub/.*stamp
|
||||
|
||||
stub/tools/armpe/armpe_tester
|
||||
|
||||
+16
-12
@@ -234,7 +234,7 @@ arm.v4t-wince.pe.h : $(srcdir)/src/$$T.S
|
||||
i086-dos16.com% : tc_list = i086 default
|
||||
|
||||
i086-dos16.com.h : $(srcdir)/src/$$T.asm
|
||||
$(call tc,pp-nasm) $< -o tmp/$T.tmp1
|
||||
$(call tc,pp-nasm) --MMD=$@ $< -o tmp/$T.tmp1
|
||||
$(call tc,app-nasm) tmp/$T.tmp1 tmp/$T.tmp2
|
||||
$(call tc,nasm) -f bin tmp/$T.tmp2 -o tmp/$T.bin
|
||||
$(call tc,bin2h) --ident=nrv2b_loader tmp/$T.bin $@
|
||||
@@ -247,7 +247,7 @@ i086-dos16.com.h : $(srcdir)/src/$$T.asm
|
||||
i086-dos16.exe% : tc_list = i086 default
|
||||
|
||||
i086-dos16.exe.h : $(srcdir)/src/$$T.asm
|
||||
$(call tc,pp-nasm) $< -o tmp/$T.tmp1
|
||||
$(call tc,pp-nasm) --MMD=$@ $< -o tmp/$T.tmp1
|
||||
$(call tc,app-nasm) tmp/$T.tmp1 tmp/$T.tmp2
|
||||
$(call tc,nasm) -f bin tmp/$T.tmp2 -o tmp/$T.bin
|
||||
$(call tc,bin2h) --ident=nrv_loader tmp/$T.bin $@
|
||||
@@ -260,7 +260,7 @@ i086-dos16.exe.h : $(srcdir)/src/$$T.asm
|
||||
i086-dos16.sys% : tc_list = i086 default
|
||||
|
||||
i086-dos16.sys.h : $(srcdir)/src/$$T.asm
|
||||
$(call tc,pp-nasm) $< -o tmp/$T.tmp1
|
||||
$(call tc,pp-nasm) --MMD=$@ $< -o tmp/$T.tmp1
|
||||
$(call tc,app-nasm) tmp/$T.tmp1 tmp/$T.tmp2
|
||||
$(call tc,nasm) -f bin tmp/$T.tmp2 -o tmp/$T.bin
|
||||
$(call tc,bin2h) --ident=nrv2b_loader tmp/$T.bin $@
|
||||
@@ -273,7 +273,7 @@ i086-dos16.sys.h : $(srcdir)/src/$$T.asm
|
||||
i386-dos32.djgpp2% : tc_list = i386 default
|
||||
|
||||
i386-dos32.djgpp2.h : $(srcdir)/src/$$T.asm
|
||||
$(call tc,pp-nasm) $< -o tmp/$T.tmp1
|
||||
$(call tc,pp-nasm) --MMD=$@ $< -o tmp/$T.tmp1
|
||||
$(call tc,app-nasm) tmp/$T.tmp1 tmp/$T.tmp2
|
||||
$(call tc,nasm) -f bin tmp/$T.tmp2 -o tmp/$T.bin
|
||||
$(call tc,bin2h) --ident=nrv_loader tmp/$T.bin $@
|
||||
@@ -290,7 +290,7 @@ i386-dos32.djgpp2-stubify.h : $(srcdir)/src/$$T.asm
|
||||
i386-dos32.tmt% : tc_list = i386 default
|
||||
|
||||
i386-dos32.tmt.h : $(srcdir)/src/$$T.asm
|
||||
$(call tc,pp-nasm) $< -o tmp/$T.tmp1
|
||||
$(call tc,pp-nasm) --MMD=$@ $< -o tmp/$T.tmp1
|
||||
$(call tc,app-nasm) tmp/$T.tmp1 tmp/$T.tmp2
|
||||
$(call tc,nasm) -f bin tmp/$T.tmp2 -o tmp/$T.bin
|
||||
$(call tc,bin2h) --ident=nrv_loader tmp/$T.bin $@
|
||||
@@ -303,7 +303,7 @@ i386-dos32.tmt.h : $(srcdir)/src/$$T.asm
|
||||
i386-dos32.watcom.le% : tc_list = i386 default
|
||||
|
||||
i386-dos32.watcom.le.h : $(srcdir)/src/$$T.asm
|
||||
$(call tc,pp-nasm) $< -o tmp/$T.tmp1
|
||||
$(call tc,pp-nasm) --MMD=$@ $< -o tmp/$T.tmp1
|
||||
$(call tc,app-nasm) tmp/$T.tmp1 tmp/$T.tmp2
|
||||
$(call tc,nasm) -f bin tmp/$T.tmp2 -o tmp/$T.bin
|
||||
$(call tc,bin2h) --ident=nrv_loader tmp/$T.bin $@
|
||||
@@ -356,7 +356,7 @@ tmp/i386-linux.elf-main.o : $(srcdir)/src/$$T.c
|
||||
# tc settings are shared with i386-linux.elf
|
||||
|
||||
i386-linux.elf.execve-entry.h : $(srcdir)/src/$$T.asm
|
||||
$(call tc,pp-nasm) $< -o tmp/$T.tmp1
|
||||
$(call tc,pp-nasm) --MMD=$@ $< -o tmp/$T.tmp1
|
||||
$(call tc,app-nasm) tmp/$T.tmp1 tmp/$T.tmp2
|
||||
$(call tc,nasm) -f bin tmp/$T.tmp2 -o tmp/$T.bin
|
||||
$(call tc,bin2h) --ident=linux_i386exec_loader tmp/$T.bin $@
|
||||
@@ -388,7 +388,7 @@ tmp/i386-linux.elf.execve-upx_itoa.o: $(srcdir)/src/$$T.asm
|
||||
# tc settings are shared with i386-linux.elf
|
||||
|
||||
i386-linux.elf.interp-entry.h : $(srcdir)/src/$$T.asm
|
||||
$(call tc,pp-nasm) $< -o tmp/$T.tmp1
|
||||
$(call tc,pp-nasm) --MMD=$@ $< -o tmp/$T.tmp1
|
||||
$(call tc,app-nasm) tmp/$T.tmp1 tmp/$T.tmp2
|
||||
$(call tc,nasm) -f bin tmp/$T.tmp2 -o tmp/$T.bin
|
||||
$(call tc,bin2h) --ident=linux_i386pti_loader tmp/$T.bin $@
|
||||
@@ -416,7 +416,7 @@ tmp/i386-linux.elf.interp-main.o : $(srcdir)/src/$$T.c
|
||||
# tc settings are shared with i386-linux.elf
|
||||
|
||||
i386-linux.elf.shell-entry.h : $(srcdir)/src/$$T.asm
|
||||
$(call tc,pp-nasm) $< -o tmp/$T.tmp1
|
||||
$(call tc,pp-nasm) --MMD=$@ $< -o tmp/$T.tmp1
|
||||
$(call tc,app-nasm) tmp/$T.tmp1 tmp/$T.tmp2
|
||||
$(call tc,nasm) -f bin tmp/$T.tmp2 -o tmp/$T.bin
|
||||
$(call tc,bin2h) --ident=linux_i386sh_loader tmp/$T.bin $@
|
||||
@@ -445,7 +445,7 @@ tmp/i386-linux.elf.shell-main.o : $(srcdir)/src/$$T.c
|
||||
i386-linux.kernel.vmlin% : tc_list = i386 default
|
||||
|
||||
i386-linux.kernel%.h : $(srcdir)/src/$$T.asm
|
||||
$(call tc,pp-nasm) $< -o tmp/$T.tmp1
|
||||
$(call tc,pp-nasm) --MMD=$@ $< -o tmp/$T.tmp1
|
||||
$(call tc,app-nasm) tmp/$T.tmp1 tmp/$T.tmp2
|
||||
$(call tc,nasm) -f bin tmp/$T.tmp2 -o tmp/$T.bin
|
||||
$(call tc,bin2h) --ident=nrv_loader tmp/$T.bin $@
|
||||
@@ -458,7 +458,7 @@ i386-linux.kernel%.h : $(srcdir)/src/$$T.asm
|
||||
i386-win32.pe% : tc_list = i386 default
|
||||
|
||||
i386-win32.pe.h : $(srcdir)/src/$$T.asm
|
||||
$(call tc,pp-nasm) $< -o tmp/$T.tmp1
|
||||
$(call tc,pp-nasm) --MMD=$@ $< -o tmp/$T.tmp1
|
||||
$(call tc,app-nasm) tmp/$T.tmp1 tmp/$T.tmp2
|
||||
$(call tc,nasm) -f bin tmp/$T.tmp2 -o tmp/$T.bin
|
||||
$(call tc,bin2h) --ident=nrv_loader tmp/$T.bin $@
|
||||
@@ -474,6 +474,8 @@ tc.m68k-atari.tos.app-a68k = perl -w $(srcdir)/src/arch/m68k/app-a68k.pl
|
||||
tc.m68k-atari.tos.asm-a68k = a68k
|
||||
|
||||
m68k-atari.tos-nrv%.h : $(srcdir)/src/m68k-atari.tos.asm
|
||||
# call gpp_inc to generate .d file
|
||||
$(call tc,gpp_inc) --MMD=$@ --MF=tmp/$T.i.d $< -o /dev/null
|
||||
$(call tc,pp-asm) -D__A68K__ $(PP_FLAGS) $< -o tmp/$T.i
|
||||
$(call tc,asm-a68k) -q -ltmp/$T.o.lst tmp/$T.i -otmp/$T.o
|
||||
$(call tc,o2bin) tmp/$T.o tmp/$T.bin 'UPX1' 'UPX9'
|
||||
@@ -500,6 +502,8 @@ tc.mipsel.r3000-ps1.app-asm5900 = perl -w $(srcdir)/src/arch/mips/mipsel.r3000/a
|
||||
tc.mipsel.r3000-ps1.asm5900 = asm5900
|
||||
|
||||
mipsel.r3000-ps1-%.h : $(srcdir)/src/mipsel.r3000-ps1.asm
|
||||
# call gpp_inc to generate .d file
|
||||
$(call tc,gpp_inc) --MMD=$@ --MF=tmp/$T.tmp1.d $< -o /dev/null
|
||||
$(call tc,pp-asm) $(PP_FLAGS) $< -o tmp/$T.tmp1
|
||||
$(call tc,app-asm5900) tmp/$T.tmp1 tmp/$T.tmp2
|
||||
$(call tc,asm5900) --nologo -q -ltmp/$T.bin.lst tmp/$T.tmp2 -otmp/$T.bin
|
||||
@@ -574,7 +578,7 @@ tmp/powerpc-darwin.macho-main.o : $(srcdir)/src/$$T.c
|
||||
|
||||
##$(STUBS): tmp/.tmp-stamp
|
||||
##$(STUBS): $(MAKEFILE_LIST)
|
||||
-include *.d tmp/*.d
|
||||
-include tmp/*.d
|
||||
|
||||
|
||||
# /***********************************************************************
|
||||
|
||||
@@ -37,9 +37,26 @@ class opts:
|
||||
fatal = 1
|
||||
includes = []
|
||||
mode = "c"
|
||||
target_mf = None
|
||||
target_mmd = None
|
||||
|
||||
|
||||
included_files = {}
|
||||
files_md = []
|
||||
files_mmd = []
|
||||
files_st = {}
|
||||
|
||||
def add_dep(state, fn, mode):
|
||||
if mode:
|
||||
files = files_md
|
||||
else:
|
||||
files = files_mmd
|
||||
fn = os.path.normpath(fn)
|
||||
fn = os.path.normcase(fn)
|
||||
if fn in files:
|
||||
return
|
||||
# FIXME: could use samestat() etc.
|
||||
files.append(fn)
|
||||
files_st[fn] = os.stat(fn)
|
||||
|
||||
|
||||
def not_found(l, s, state):
|
||||
@@ -53,18 +70,20 @@ def handle_inc_c(l, state, ofp):
|
||||
if not m:
|
||||
return l
|
||||
s = m.group(1).strip()
|
||||
if len(s) < 3 or s[0] != s[-1]:
|
||||
# FIXME: strip comments ?
|
||||
if len(s) < 3:
|
||||
return not_found(l, s, state)
|
||||
if s[0] == '<':
|
||||
if s[0] == '<' and s[-1] == '>':
|
||||
dirs = opts.includes
|
||||
elif s[0] == '"':
|
||||
elif s[0] == '"' and s[-1] == '"':
|
||||
dirs = [state[1]] + opts.includes
|
||||
else:
|
||||
assert 0
|
||||
raise Exception, "syntax error: include line " + l
|
||||
inc = s[1:-1]
|
||||
for dir in dirs:
|
||||
fn = os.path.join(dir, inc)
|
||||
if os.path.isfile(fn):
|
||||
add_dep(state, fn, s[0] == '<')
|
||||
handle_file(fn, ofp, state)
|
||||
return None
|
||||
return not_found(l, s, state)
|
||||
@@ -75,13 +94,21 @@ def handle_inc_nasm(l, state, ofp):
|
||||
if not m:
|
||||
return l
|
||||
s = m.group(1).strip()
|
||||
if len(s) < 3 or s[0] != s[-1]:
|
||||
# FIXME: strip comments ?
|
||||
if len(s) < 3:
|
||||
return not_found(l, s, state)
|
||||
if s[0] == '<' and s[-1] == '>':
|
||||
pass
|
||||
elif s[0] == '"' and s[-1] == '"':
|
||||
pass
|
||||
else:
|
||||
raise Exception, "syntax error: include line " + l
|
||||
inc = s[1:-1]
|
||||
# info: nasm simply does concat the includes
|
||||
for prefix in opts.includes + [""]:
|
||||
fn = prefix + inc
|
||||
if os.path.isfile(fn):
|
||||
add_dep(state, fn, False)
|
||||
handle_file(fn, ofp, state)
|
||||
return None
|
||||
return not_found(l, s, state)
|
||||
@@ -103,7 +130,7 @@ def handle_file(ifn, ofp, parent_state=None):
|
||||
|
||||
def main(argv):
|
||||
ofile = None
|
||||
shortopts, longopts = "qvI::o::", ["dry-run", "mode=", "quiet", "verbose"]
|
||||
shortopts, longopts = "qvI:o:", ["dry-run", "MF=", "MMD=", "mode=", "quiet", "verbose"]
|
||||
xopts, args = getopt.gnu_getopt(argv[1:], shortopts, longopts)
|
||||
for opt, optarg in xopts:
|
||||
if 0: pass
|
||||
@@ -113,6 +140,8 @@ def main(argv):
|
||||
elif opt in ["-I"]: opts.includes.append(optarg)
|
||||
elif opt in ["-o"]: ofile = optarg
|
||||
elif opt in ["--mode"]: opts.mode = optarg.lower()
|
||||
elif opt in ["--MF"]: opts.target_mf = optarg
|
||||
elif opt in ["--MMD"]: opts.target_mmd = optarg
|
||||
else: assert 0, ("getopt problem:", opt, optarg, xopts, args)
|
||||
|
||||
if ofile is None:
|
||||
@@ -126,6 +155,23 @@ def main(argv):
|
||||
assert os.path.isfile(ifile)
|
||||
ofp = open(ofile, "wb")
|
||||
handle_file(ifile, ofp)
|
||||
ofp.close()
|
||||
|
||||
if opts.target_mmd:
|
||||
fn = ofile + ".d"
|
||||
if opts.target_mf:
|
||||
fn = opts.target_mf
|
||||
if os.path.isfile(fn):
|
||||
os.unlink(fn)
|
||||
if files_mmd:
|
||||
fp = open(fn, "wb")
|
||||
fp.write("%s : \\\n" % opts.target_mmd)
|
||||
for i, f in enumerate(files_mmd):
|
||||
if i < len(files_mmd) - 1:
|
||||
fp.write(" %s \\\n" % f)
|
||||
else:
|
||||
fp.write(" %s\n" % f)
|
||||
fp.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user