strreplace: clean up and simplify
[profile/ivi/syslinux.git] / core / Makefile
index d35390f..112fe3a 100644 (file)
@@ -1,7 +1,7 @@
 ## -----------------------------------------------------------------------
 ##
 ##   Copyright 1998-2009 H. Peter Anvin - All Rights Reserved
-##   Copyright 2009 Intel Corporation; author: H. Peter Anvin
+##   Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin
 ##
 ##   This program is free software; you can redistribute it and/or modify
 ##   it under the terms of the GNU General Public License as published by
@@ -20,7 +20,8 @@ MAKEFLAGS += -r
 MAKE      += -r
 
 topdir = ..
-include $(topdir)/MCONFIG.embedded
+MAKEDIR = $(topdir)/mk
+include $(MAKEDIR)/embedded.mk
 -include $(topdir)/version.mk
 
 OPTFLAGS =
@@ -33,7 +34,6 @@ CODEPAGE = cp865
 
 # The targets to build in this directory...
 BTARGET  = kwdhash.gen \
-          extlinux.bin extlinux.bss extlinux.sys \
           ldlinux.bss ldlinux.sys ldlinux.bin \
           isolinux.bin isolinux-debug.bin pxelinux.0
 
@@ -50,7 +50,7 @@ COBJ   := $(patsubst %.c,%.o,$(CSRC))
 SOBJ    := $(patsubst %.S,%.o,$(SSRC))
 
 LIB     = libcore.a
-LIBS    = $(LIB) $(com32)/lib/libcom32.a $(LIBGCC)
+LIBS    = $(LIB) $(com32)/lib/libcomcore.a $(LIBGCC)
 LIBOBJS         = $(COBJ) $(SOBJ)
 
 NASMDEBUG = -g -F dwarf
@@ -58,6 +58,8 @@ NASMOPT  += $(NASMDEBUG)
 
 PREPCORE = ../lzo/prepcore
 
+# CFLAGS       += -DDEBUG=1
+
 # The DATE is set on the make command line when building binaries for
 # official release.  Otherwise, substitute a hex string that is pretty much
 # guaranteed to be unique to be unique from build to build.
@@ -78,6 +80,9 @@ kwdhash.gen: keywords genhash.pl
 %.raw: %.elf
        $(OBJCOPY) -O binary $< $(@:.bin=.raw)
 
+# GNU make 3.82 gets confused by the first form
+.PRECIOUS: %.raw
+
 %.bin: %.raw $(PREPCORE)
        $(PREPCORE) $< $@
 
@@ -87,7 +92,8 @@ kwdhash.gen: keywords genhash.pl
                -l $(@:.o=.lsr) -o $@ -MP -MD .$@.d $<
 
 %.elf: %.o $(LIBS) syslinux.ld
-       $(LD) $(LDFLAGS) -T syslinux.ld -M -o $@ $< $(LIBS) \
+       $(LD) $(LDFLAGS) -T syslinux.ld -M -o $@ $< \
+               --start-group $(LIBS) --end-group \
                > $(@:.elf=.map)
        $(OBJDUMP) -h $@ > $(@:.elf=.sec)
        $(PERL) lstadjust.pl $(@:.elf=.lsr) $(@:.elf=.sec) $(@:.elf=.lst)
@@ -104,20 +110,13 @@ ldlinux.bss: ldlinux.bin
        dd if=$< of=$@ bs=512 count=1
 
 ldlinux.sys: ldlinux.bin
-       dd if=$< of=$@ bs=512 skip=1
-
-extlinux.bss: extlinux.bin
-       dd if=$< of=$@ bs=512 count=1
-
-extlinux.sys: extlinux.bin
-       dd if=$< of=$@ bs=512 skip=1
-
-# NASM prior to 2.03 wouldn't auto-generate this dependency...
-ldlinux.o: codepage.cp
+       dd if=$< of=$@ bs=512 skip=2
 
 codepage.cp: ../codepage/$(CODEPAGE).cp
        cp -f $< $@
 
+codepage.o: codepage.S codepage.cp
+
 install: installer
 
 install-lib: installer
@@ -131,7 +130,7 @@ tidy dist:
        rm -f *.elf.tmp *.sym
        rm -f *.lsr *.lst *.map *.sec *.raw
        rm -f */*.o */*/*.o */*.lst */*/*.lst */.*.d */*/.*.d
-       rm -f $(OBSOLETE)
+       rm -f $(OBSOLETE) $(LIB)
 
 clean: tidy
 
@@ -139,4 +138,4 @@ spotless: clean
        rm -f $(BTARGET) *.bin *_bin.c
 
 # Include dependencies file
--include .*.d */.*.d
+-include .*.d */.*.d */*/.*.d