Various fixes to the tree to get coreboot-v2 to build on Solaris
[coreboot.git] / util / newconfig / config.g
index 3bf677dfc11b0af95420c97effd132697a2e74bd..b8b8c16e9cd4bbb782611a0c8e66e1b338168f68 100644 (file)
@@ -323,6 +323,22 @@ class romimage:
                        return
                fatal("No such rule \"%s\" for addmakedepend" % id)
 
+       def addmakeobject(self, file, obj):
+               source = topify(obj[1])
+               type = obj[2]
+               if (type  == 'S'):
+                       # for .S, .o depends on .s
+                       file.write("%s: %s.s\n" % (obj[0], obj[3]))
+                       file.write("\t$(CC) -c $(CPU_OPT) -o $@ $<\n")
+                       # and .s depends on .S
+                       file.write("%s.s: %s\n" % (obj[3], source))
+                       # Note: next 2 lines are ONE output line!
+                       file.write("\t$(CPP) $(CPPFLAGS) $< ")
+                       file.write(">$@.new && mv $@.new $@\n")
+               else:
+                       file.write("%s: %s\n" % (obj[0], source))
+                       file.write("\t$(CC) -c $(CFLAGS) -o $@ $<\n")
+
        # this is called with an an object name. 
        # the easiest thing to do is add this object to the current 
        # component.
@@ -608,8 +624,12 @@ class option_value:
 class partobj:
        """A configuration part"""
        def __init__ (self, image, dir, parent, part, type_name, instance_name, chip_or_device):
-               debug.info(debug.object, "partobj dir %s parent %s part %s" \
-                               % (dir, parent, part))
+               if (parent):
+                       debug.info(debug.object, "partobj dir %s parent %s part %s" \
+                               % (dir, parent.instance_name, part))
+               else:
+                       debug.info(debug.object, "partobj dir %s part %s" \
+                               % (dir, part))
 
                # romimage that is configuring this part
                self.image = image
@@ -2098,7 +2118,7 @@ def writeimagemakefile(image):
        file.write("# Function to create an item like -Di586 or -DCONFIG_MAX_CPUS='1' or -Ui686\n")
        file.write("D_item = $(shell echo '$(if $(subst undefined,,$(origin $1)),\\#define $1$(if $($1), $($1),),\\#undef $1)' >> settings.h)\n\n")
        file.write("# Compute the value of CPUFLAGS here during make's first pass.\n")
-       file.write("CPUFLAGS := $(strip $(shell echo '/* autogenerated */' > settings.h)$(foreach _var_,$(VARIABLES),$(call D_item,$(_var_)))-include $(PWD)/settings.h)\n\n")
+       file.write("CPUFLAGS := $(strip $(shell echo '/* autogenerated */' > settings.h)$(foreach _var_,$(VARIABLES),$(call D_item,$(_var_)))-include $(CURDIR)/settings.h)\n\n")
 
        for i in image.getuserdefines():
                file.write("%s\n" %i)
@@ -2166,38 +2186,15 @@ def writeimagemakefile(image):
 
        file.write("\n# initobjectrules:\n")
        for irule, init in image.getinitobjectrules().items():
-               source = topify(init[1])
-               type = init[2]
-               if (type  == 'S'):
-                       # for .S, .o depends on .s
-                       file.write("%s: %s.s\n" % (init[0], init[3]))
-                       file.write("\t$(CC) -c $(CPU_OPT) -o $@ $<\n")
-                       # and .s depends on .S
-                       file.write("%s.s: %s\n" % (init[3], source))
-                       # Note: next 2 lines are ONE output line!
-                       file.write("\t$(CPP) $(CPPFLAGS) $< ")
-                       file.write(">$@.new && mv $@.new $@\n")
-               else:
-                       file.write("%s: %s\n" % (init[0], source))
-                       file.write("\t$(CC) -c $(CFLAGS) -o $@ $<\n")
+               image.addmakeobject(file, init);
 
-       file.write("\n# objectrules:\n")
+       file.write("\n# objectrules (don't duplicate initobjects):\n")
        for objrule, obj in image.getobjectrules().items():
-               source = topify(obj[1])
-               type = obj[2]
-               if (type  == 'S'):
-                       # for .S, .o depends on .s
-                       file.write("%s: %s.s\n" % (obj[0], obj[3]))
-                       file.write("\t$(CC) -c $(CPU_OPT) -o $@ $<\n")
-                       # and .s depends on .S
-                       file.write("%s.s: %s\n" % (obj[3], source))
-                       # Note: next 2 lines are ONE output line!
-                       file.write("\t$(CPP) $(CPPFLAGS) $< ")
-                       file.write(">$@.new && mv $@.new $@\n")
+
+               if (getdict(image.getinitobjectrules(), obj[3])):
+                       debug.info(debug.object, "skipping %s" % (obj[3]))
                else:
-                       file.write("%s: %s\n" % (obj[0], source))
-                       file.write("\t$(CC) -c $(CFLAGS) -o $@ $<\n")
-               #file.write("%s\n" % objrule[2])
+                       image.addmakeobject(file, obj);
 
        for driverrule, driver in image.getdriverrules().items():
                source = topify(driver[1])
@@ -2207,20 +2204,7 @@ def writeimagemakefile(image):
 
        file.write("\n# smmobjectrules:\n")
        for irule, smm in image.getsmmobjectrules().items():
-               source = topify(smm[1])
-               type = smm[2]
-               if (type  == 'S'):
-                       # for .S, .o depends on .s
-                       file.write("%s: %s.s\n" % (smm[0], smm[3]))
-                       file.write("\t$(CC) -c $(CPU_OPT) -o $@ $<\n")
-                       # and .s depends on .S
-                       file.write("%s.s: %s\n" % (smm[3], source))
-                       # Note: next 2 lines are ONE output line!
-                       file.write("\t$(CPP) $(CPPFLAGS) $< ")
-                       file.write(">$@.new && mv $@.new $@\n")
-               else:
-                       file.write("%s: %s\n" % (smm[0], source))
-                       file.write("\t$(CC) -c $(CFLAGS) -o $@ $<\n")
+               image.addmakeobject(file, smm);
 
        # special rule for chip_target.c
        file.write("static.o: static.c\n")
@@ -2314,7 +2298,7 @@ def writemakefile(path):
                file.write("\t./cbfstool %s create %s %s %s.bootblock\n"
                           %(i.name, romsize, bootblocksize, i.name))
                for j in pciroms:
-                       file.write("\t./cbfstool %s add %s pci%04x,%04x.rom 48\n" % (i.name, j.name, j.pci_vid, j.pci_did))
+                       file.write("\t./cbfstool %s add %s pci%04x,%04x.rom optionrom\n" % (i.name, j.name, j.pci_vid, j.pci_did))
                for j in i.roms:
                        #failover is a hack that will go away soon. 
                        if (j != "failover") and (rommapping[j] != "/dev/null"):