/[grub]/grub2/genmk.rb
ViewVC logotype

Diff of /grub2/genmk.rb

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by okuji, Sun Apr 4 13:45:59 2004 UTC revision 1.9 by marco_g, Mon Dec 27 13:46:19 2004 UTC
# Line 1  Line 1 
1  #! /usr/bin/ruby -w  #! /usr/bin/ruby -w
2  #  #
3  # Copyright (C) 2002,2003  Free Software Foundation, Inc.  # Copyright (C) 2002,2003,2004  Free Software Foundation, Inc.
4  #  #
5  # This genmk.rb is free software; the author  # This genmk.rb is free software; the author
6  # gives unlimited permission to copy and/or distribute it,  # gives unlimited permission to copy and/or distribute it,
# Line 205  MOSTLYCLEANFILES += #{deps_str} Line 205  MOSTLYCLEANFILES += #{deps_str}
205    end    end
206  end  end
207    
208    class Program
209      def initialize(dir, name)
210        @dir = dir
211        @name = name
212      end
213      attr_reader :dir, :name
214    
215      def rule(sources)
216        prefix = @name.to_var
217        objs = sources.collect do |src|
218          raise "unknown source file `#{src}'" if /\.[cS]$/ !~ src
219          prefix + '-' + src.to_obj
220        end
221        objs_str = objs.join(' ');
222        deps = objs.collect {|obj| obj.suffix('d')}
223        deps_str = deps.join(' ');
224    
225        "CLEANFILES += #{@name} #{objs_str}
226    MOSTLYCLEANFILES += #{deps_str}
227    
228    #{@name}: #{objs_str}
229            $(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(#{prefix}_LDFLAGS)
230    
231    " + objs.collect_with_index do |obj, i|
232          src = sources[i]
233          fake_obj = File.basename(src).suffix('o')
234          dep = deps[i]
235          dir = File.dirname(src)
236    
237          "#{obj}: #{src}
238            $(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(#{prefix}_CFLAGS) -c -o $@ $<
239    
240    #{dep}: #{src}
241            set -e; \
242              $(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(#{prefix}_CFLAGS) -M $< \
243              | sed 's,#{Regexp.quote(fake_obj)}[ :]*,#{obj} $@ : ,g' > $@; \
244              [ -s $@ ] || rm -f $@
245    
246    -include #{dep}
247    
248    "
249        end.join('')
250      end
251    end
252    
253  images = []  images = []
254  utils = []  utils = []
255  pmodules = []  pmodules = []
256    programs = []
257    
258  cont = false  cont = false
259  s = nil  s = nil
# Line 245  while l = gets Line 291  while l = gets
291              Utility.new(prefix, util)              Utility.new(prefix, util)
292            end            end
293    
294            when 'PROGRAMS'
295              programs += args.split(/\s+/).collect do |util|
296                Program.new(prefix, util)
297              end
298    
299          when 'SOURCES'          when 'SOURCES'
300            if img = images.detect() {|i| i.name.to_var == prefix}            if img = images.detect() {|i| i.name.to_var == prefix}
301              print img.rule(args.split(/\s+/))              print img.rule(args.split(/\s+/))
# Line 252  while l = gets Line 303  while l = gets
303              print pmod.rule(args.split(/\s+/))              print pmod.rule(args.split(/\s+/))
304            elsif util = utils.detect() {|u| u.name.to_var == prefix}            elsif util = utils.detect() {|u| u.name.to_var == prefix}
305              print util.rule(args.split(/\s+/))              print util.rule(args.split(/\s+/))
306              elsif program = programs.detect() {|u| u.name.to_var == prefix}
307                print program.rule(args.split(/\s+/))
308            end            end
309          end          end
310        end        end

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26