Tweak some makefiles to prepare for bmake
[dragonfly.git] / sys / boot / pc32 / boot2 / Makefile
index 97fd6b1..9e4e47a 100644 (file)
@@ -41,11 +41,11 @@ ORG1D = `${.OBJDIR}/bootasmdef.nx -d MEM_BIOS_LADDR`
 #
 ORG2=  `${.OBJDIR}/bootasmdef.nx BOOT2_VORIGIN`
 
-# gcc3.x
-#      -fno-guess-branch-probability
-#      -mno-align-long-strings
-CFLAGS=        -elf -ffreestanding -Os -fno-builtin \
+CFLAGS=        -Os \
+       -fno-guess-branch-probability \
        -fomit-frame-pointer \
+       -fno-unwind-tables \
+       -fno-asynchronous-unwind-tables \
        -DBOOT2 \
        -I${.CURDIR}/../../common \
        -I${.CURDIR}/../../../../lib/libstand \
@@ -76,7 +76,8 @@ CFLAGS+= -fno-unit-at-a-time
 #
 NSECT_32?=     16
 NSECT_64?=     30
-LDFLAGS=-nostdlib -static -N --gc-sections
+LDFLAGS=       -nostdlib -static -N --gc-sections
+LINKSCRIPT=    --script ${.CURDIR}/boot2.ldscript
 
 all: boot
 
@@ -108,11 +109,13 @@ boot1$s.o: boot1.S
        ${CC} ${CFLAGS} ${_ADDCFLAGS$s} -DFLAGS=${B1FLAGS} \
                ${.ALLSRC} -o ${.TARGET} -c
 
-boot2$s.o: boot2.c ${.CURDIR}/../../common/ufsread.c ${.CURDIR}/../../../../lib/libstand/hammerread.c
+boot2$s.s: boot2.c boot2$s.h ${.CURDIR}/../../common/ufsread.c ${.CURDIR}/../../../../lib/libstand/hammerread.c
        ${CC} ${CFLAGS} ${_ADDCFLAGS$s} -S -o boot2$s.s.tmp ${.CURDIR}/boot2.c
-       sed -e '/align/d' -e '/nop/d' < boot2$s.s.tmp > boot2$s.s
-       rm -f boot2$s.s.tmp
-       ${AS} ${AFLAGS} -o boot2$s.o boot2$s.s
+       sed -e '/align/d' -e '/nop/d' < ${.TARGET}.tmp > ${.TARGET}
+       rm -f ${.TARGET}.tmp
+
+boot2$s.o: boot2$s.s
+       ${AS} ${AFLAGS} -o ${.TARGET} boot2$s.s
 
 boot2$s.h: boot1$s.out bootasmdef.nx
        @echo "NOTE: boot2 using xread from boot1 at ${REL1}"
@@ -135,11 +138,9 @@ boot2$s.bin: boot2$s.out
        objcopy -S -O binary boot2$s.out ${.TARGET}
 
 boot2$s.out: boot2$s.o sio.o ${_ADDOBJS$s}
-       ${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} \
+       ${LD} ${LDFLAGS} -Ttext ${ORG2} ${LINKSCRIPT} -o ${.TARGET} \
                ${BTX}/lib/crt0.o ${.ALLSRC}
 
-boot2$s.o: boot2$s.h
-
 CLEANFILES+=   boot1$s boot1$s.out boot1$s.o \
                boot2$s boot2$s.ldr boot2$s.bin \
                boot2$s.ld boot2$s.out boot2$s.o boot2$s.h boot2$s.s \