core: Split core console code into separate libs
authorMatt Fleming <matt.fleming@intel.com>
Fri, 4 Nov 2011 15:02:14 +0000 (15:02 +0000)
committerMatt Fleming <matt.fleming@intel.com>
Fri, 2 Dec 2011 12:13:30 +0000 (12:13 +0000)
When the console code was written in asm ldlinux.asm, isolinux.asm and
pxelinux.asm simply included the correct console I/O files (rawcon.inc
and plaincon.inc) but now that these files are implemented in C we
need another way to link against the correct functions.

Create separate libraries for linking ldlinux, isolinux and pxelinux
against.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
core/Makefile

index 95424dc..5288da6 100644 (file)
@@ -49,10 +49,13 @@ ALLSRC    = $(NASMSRC) $(NASMHDR) $(CSRC) $(SSRC) $(CHDR) $(OTHERSRC)
 COBJ    := $(patsubst %.c,%.o,$(CSRC))
 SOBJ    := $(patsubst %.S,%.o,$(SSRC))
 
+# Don't include console objects
+COBJS   = $(filter-out rawcon.o plaincon.o,$(COBJ))
+
 LIB     = libcom32.a
 LIBS    = $(LIB) --whole-archive $(com32)/lib/libcom32min.a
 LIBDEP   = $(filter-out -% %start%,$(LIBS))
-LIBOBJS         = $(COBJ) $(SOBJ)
+LIBOBJS         = $(COBJS) $(SOBJ)
 
 NASMDEBUG = -g -F dwarf
 NASMOPT  += $(NASMDEBUG)
@@ -92,13 +95,31 @@ kwdhash.gen: keywords genhash.pl
                -DHEXDATE="$(HEXDATE)" \
                -l $(@:.o=.lsr) -o $@ -MP -MD .$@.d $<
 
-%.elf: %.o $(LIBDEP) syslinux.ld
-       $(LD) $(LDFLAGS) -s -Bsymbolic -pie -E --hash-style=gnu -T syslinux.ld -M -o $@ $< \
-               --start-group $(LIBS) --end-group \
+AUXLIBS = libisolinux.a libisolinux-debug.a libldlinux.a libpxelinux.a
+
+%.elf: %.o $(LIBDEP) syslinux.ld $(AUXLIBS)
+       $(LD) $(LDFLAGS) -Bsymbolic -pie -E --hash-style=gnu -T syslinux.ld -M -o $@ $< \
+               --start-group $(LIBS) lib$(patsubst %.elf,%.a,$@) --end-group \
                > $(@:.elf=.map)
        $(OBJDUMP) -h $@ > $(@:.elf=.sec)
        $(PERL) lstadjust.pl $(@:.elf=.lsr) $(@:.elf=.sec) $(@:.elf=.lst)
 
+libisolinux.a: rawcon.o
+       rm -f $@
+       $(AR) cq $@ $^
+       $(RANLIB) $@
+
+libisolinux-debug.a: libisolinux.a
+       cp $^ $@
+
+libpxelinux.a: libisolinux.a
+       cp $^ $@
+
+libldlinux.a: plaincon.o
+       rm -f $@
+       $(AR) cq $@ $^
+       $(RANLIB) $@
+
 $(LIB): $(LIBOBJS)
        rm -f $@
        $(AR) cq $@ $^