diff --git a/sys/boot/i386/Makefile.inc b/sys/boot/i386/Makefile.inc index fa5ea569e609..6aced1829560 100644 --- a/sys/boot/i386/Makefile.inc +++ b/sys/boot/i386/Makefile.inc @@ -1,6 +1,6 @@ # Common defines for all of /sys/boot/i386/ # # $FreeBSD$ LOADER_ADDRESS?= 0x200000 -CFLAGS+= -mpreferred-stack-boundary=2 +CFLAGS+= -ffreestanding -mpreferred-stack-boundary=2 diff --git a/sys/boot/i386/boot2/Makefile b/sys/boot/i386/boot2/Makefile index 5425c08707fe..be6187319955 100644 --- a/sys/boot/i386/boot2/Makefile +++ b/sys/boot/i386/boot2/Makefile @@ -1,87 +1,87 @@ # $FreeBSD$ PROG= boot2 NOMAN= STRIP= BINDIR?= /boot BINMODE= 444 CLEANFILES+= boot1 boot1.out boot1.o \ boot2.ldr boot2.bin boot2.ld boot2.out boot2.o boot2.h \ sio.o NM?= nm # A value of 0x80 enables LBA support. B1FLAGS= 0x80 BOOT_COMCONSOLE_PORT?= 0x3f8 BOOT_COMCONSOLE_SPEED?= 9600 B2SIOFMT?= 0x3 .if exists(${.OBJDIR}/../btx) BTX= ${.OBJDIR}/../btx .else BTX= ${.CURDIR}/../btx .endif ORG1= 0x7c00 ORG2= 0x1000 -CFLAGS= -elf -I${.CURDIR}/../btx/lib -I. \ - -Os -fno-builtin -fforce-addr -fdata-sections \ - -malign-functions=0 -malign-jumps=0 -malign-loops=0 -mrtd \ - -mpreferred-stack-boundary=2 \ +CFLAGS= -elf -ffreestanding -Os -fno-builtin -fforce-addr -fdata-sections \ + -fno-align-functions -fno-align-jumps -fno-align-loops -fno-align-labels \ + -mrtd -mpreferred-stack-boundary=2 \ + -I${.CURDIR}/../btx/lib -I. \ -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \ -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings LDFLAGS=-nostdlib -static -N all: boot1 boot2 boot1: boot1.out objcopy -S -O binary boot1.out ${.TARGET} boot1.out: boot1.o ${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o boot1.o: boot1.s ${AS} ${AFLAGS} --defsym FLAGS=${B1FLAGS} ${.IMPSRC} -o ${.TARGET} boot2.h: boot1.out ${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \ { x = $$1 - ORG1; printf("#define XREADORG 0x7%x\n", x) }' \ ORG1=`printf "%d" ${ORG1}` > boot2.h boot2: boot2.ldr boot2.bin ${BTX}/btx/btx btxld -v -E ${ORG2} -f bin -b ${BTX}/btx/btx -l boot2.ldr \ -o boot2.ld -P 1 boot2.bin @ls -l boot2.ld | awk '{ x = 7680 - $$5; \ print x " bytes available"; if (x < 0) exit 1 }' dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync 2>/dev/null boot2.ldr: dd if=/dev/zero of=${.TARGET} bs=512 count=1 2>/dev/null boot2.bin: boot2.out objcopy -S -O binary boot2.out ${.TARGET} boot2.out: boot2.o sio.o ${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} \ ${BTX}/lib/crt0.o boot2.o sio.o boot2.o: boot2.h sio.o: sio.s ${AS} ${AFLAGS} --defsym SIOPRT=${BOOT_COMCONSOLE_PORT} \ --defsym SIOFMT=${B2SIOFMT} \ --defsym SIOSPD=${BOOT_COMCONSOLE_SPEED} \ ${.IMPSRC} -o ${.TARGET} install: ${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ boot1 ${DESTDIR}${BINDIR}/boot1 ${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ boot2 ${DESTDIR}${BINDIR}/boot2 .include diff --git a/sys/boot/i386/gptboot/Makefile b/sys/boot/i386/gptboot/Makefile index 5425c08707fe..be6187319955 100644 --- a/sys/boot/i386/gptboot/Makefile +++ b/sys/boot/i386/gptboot/Makefile @@ -1,87 +1,87 @@ # $FreeBSD$ PROG= boot2 NOMAN= STRIP= BINDIR?= /boot BINMODE= 444 CLEANFILES+= boot1 boot1.out boot1.o \ boot2.ldr boot2.bin boot2.ld boot2.out boot2.o boot2.h \ sio.o NM?= nm # A value of 0x80 enables LBA support. B1FLAGS= 0x80 BOOT_COMCONSOLE_PORT?= 0x3f8 BOOT_COMCONSOLE_SPEED?= 9600 B2SIOFMT?= 0x3 .if exists(${.OBJDIR}/../btx) BTX= ${.OBJDIR}/../btx .else BTX= ${.CURDIR}/../btx .endif ORG1= 0x7c00 ORG2= 0x1000 -CFLAGS= -elf -I${.CURDIR}/../btx/lib -I. \ - -Os -fno-builtin -fforce-addr -fdata-sections \ - -malign-functions=0 -malign-jumps=0 -malign-loops=0 -mrtd \ - -mpreferred-stack-boundary=2 \ +CFLAGS= -elf -ffreestanding -Os -fno-builtin -fforce-addr -fdata-sections \ + -fno-align-functions -fno-align-jumps -fno-align-loops -fno-align-labels \ + -mrtd -mpreferred-stack-boundary=2 \ + -I${.CURDIR}/../btx/lib -I. \ -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \ -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings LDFLAGS=-nostdlib -static -N all: boot1 boot2 boot1: boot1.out objcopy -S -O binary boot1.out ${.TARGET} boot1.out: boot1.o ${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o boot1.o: boot1.s ${AS} ${AFLAGS} --defsym FLAGS=${B1FLAGS} ${.IMPSRC} -o ${.TARGET} boot2.h: boot1.out ${NM} -t d ${.ALLSRC} | awk '/([0-9])+ T xread/ \ { x = $$1 - ORG1; printf("#define XREADORG 0x7%x\n", x) }' \ ORG1=`printf "%d" ${ORG1}` > boot2.h boot2: boot2.ldr boot2.bin ${BTX}/btx/btx btxld -v -E ${ORG2} -f bin -b ${BTX}/btx/btx -l boot2.ldr \ -o boot2.ld -P 1 boot2.bin @ls -l boot2.ld | awk '{ x = 7680 - $$5; \ print x " bytes available"; if (x < 0) exit 1 }' dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync 2>/dev/null boot2.ldr: dd if=/dev/zero of=${.TARGET} bs=512 count=1 2>/dev/null boot2.bin: boot2.out objcopy -S -O binary boot2.out ${.TARGET} boot2.out: boot2.o sio.o ${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} \ ${BTX}/lib/crt0.o boot2.o sio.o boot2.o: boot2.h sio.o: sio.s ${AS} ${AFLAGS} --defsym SIOPRT=${BOOT_COMCONSOLE_PORT} \ --defsym SIOFMT=${B2SIOFMT} \ --defsym SIOSPD=${BOOT_COMCONSOLE_SPEED} \ ${.IMPSRC} -o ${.TARGET} install: ${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ boot1 ${DESTDIR}${BINDIR}/boot1 ${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ boot2 ${DESTDIR}${BINDIR}/boot2 .include diff --git a/sys/boot/i386/kgzldr/Makefile b/sys/boot/i386/kgzldr/Makefile index 6ba2a35032fd..85f3b67d1045 100644 --- a/sys/boot/i386/kgzldr/Makefile +++ b/sys/boot/i386/kgzldr/Makefile @@ -1,32 +1,32 @@ # $FreeBSD$ FILES= kgzldr.o SRCS= start.s boot.c inflate.c lib.c crt.s sio.s OBJS= ${SRCS:N*.h:R:S/$/.o/g} -CFLAGS= -fno-builtin +CFLAGS= -ffreestanding -fno-builtin .if ${OBJFORMAT} == aout CFLAGS+=-O2 .else CFLAGS+=-Os .endif CFLAGS+=-DKZIP LDFLAGS=-nostdlib -static -r BINDIR= /usr/lib .PATH: ${.CURDIR}/../../../kern CLEANFILES=${FILES} M4?= m4 M4FLAGS=-DOBJFORMAT=${OBJFORMAT} BOOT_COMCONSOLE_PORT?= 0x3f8 M4FLAGS+=-DSIOPRT=${BOOT_COMCONSOLE_PORT} kgzldr.o: ${OBJS} ${CC} ${LDFLAGS} -o ${.TARGET} ${OBJS} .s.o: (cd ${.CURDIR}; ${M4} ${M4FLAGS} kgzldr.m4 ${.IMPSRC}) |\ ${AS} ${AFLAGS} -o ${.TARGET} .include diff --git a/sys/boot/i386/libi386/Makefile b/sys/boot/i386/libi386/Makefile index 7026cd07f12a..2b3e82c2eebd 100644 --- a/sys/boot/i386/libi386/Makefile +++ b/sys/boot/i386/libi386/Makefile @@ -1,50 +1,50 @@ # $FreeBSD$ # LIB= i386 NOPIC= NOPROFILE= INTERNALLIB= true INTERNALSTATICLIB= true SRCS= aout_freebsd.c biosacpi.c bioscd.c biosdisk.c biosmem.c biospnp.c \ biospci.c bootinfo.c comconsole.c devicename.c elf_freebsd.c gatea20.c \ i386_copy.c i386_module.c nullconsole.c pxe.c pxetramp.s \ time.c vidconsole.c -CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../btx/lib \ - -I${.CURDIR}/../../../contrib/dev/acpica \ - -I${.CURDIR}/../../.. -I. - +CFLAGS+= -ffreestanding BOOT_COMCONSOLE_PORT?= 0x3f8 CFLAGS+= -DCOMPORT=${BOOT_COMCONSOLE_PORT} BOOT_COMCONSOLE_SPEED?= 9600 CFLAGS+= -DCOMSPEED=${BOOT_COMCONSOLE_SPEED} -# the location of libstand -CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/ - .ifdef(BOOT_BIOSDISK_DEBUG) # Make the disk code more talkative CFLAGS+= -DDISK_DEBUG .endif # Include simple terminal emulation (cons25-compatible) CFLAGS+= -DTERM_EMU +CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../btx/lib \ + -I${.CURDIR}/../../../contrib/dev/acpica \ + -I${.CURDIR}/../../.. -I. +# the location of libstand +CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/ + # Make "machine" required for all objects # (based on the more complete case in sys/i386/boot/Makefile.inc) ${SRCS:M*.c:R:S/$/.o/g}: machine # If it's not there, don't consider it a target .if exists(${.CURDIR}/../../../i386/include) beforedepend ${OBJS}: machine machine: ln -sf ${.CURDIR}/../../../i386/include machine .endif CLEANFILES+= machine .include diff --git a/sys/boot/i386/loader/Makefile b/sys/boot/i386/loader/Makefile index 33f23f0364e5..0ad12764afe4 100644 --- a/sys/boot/i386/loader/Makefile +++ b/sys/boot/i386/loader/Makefile @@ -1,132 +1,133 @@ # $FreeBSD$ BASE= loader PROG= ${BASE} STRIP= NEWVERSWHAT= "bootstrap loader" i386 BINDIR?= /boot INSTALLFLAGS= -b .if !defined(LOADER_NO_AOUT_SUPPORT) LOADER_AOUT_SUPPORT= yes .endif # architecture-specific loader code SRCS= main.c conf.c +CFLAGS+= -ffreestanding # Enable PXE TFTP or NFS support, not both. .if defined(LOADER_TFTP_SUPPORT) CFLAGS+= -DLOADER_TFTP_SUPPORT .else CFLAGS+= -DLOADER_NFS_SUPPORT .endif # Enable PnP and ISA-PnP code. HAVE_PNP= yes HAVE_ISABUS= yes .if !defined(NOFORTH) # Enable BootForth BOOT_FORTH= yes CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/i386 .if exists(${.OBJDIR}/../../ficl/libficl.a) LIBFICL= ${.OBJDIR}/../../ficl/libficl.a .else LIBFICL= ${.CURDIR}/../../ficl/libficl.a .endif .endif .if defined(LOADER_BZIP2_SUPPORT) CFLAGS+= -DLOADER_BZIP2_SUPPORT .endif .if !defined(LOADER_NO_GZIP_SUPPORT) CFLAGS+= -DLOADER_GZIP_SUPPORT .endif # Always add MI sources .PATH: ${.CURDIR}/../../common .include <${.CURDIR}/../../common/Makefile.inc> CFLAGS+= -I${.CURDIR}/../../common CFLAGS+= -I${.CURDIR}/../../.. -I. CLEANFILES+= vers.c vers.o ${BASE}.list ${BASE}.bin ${BASE}.sym ${BASE}.help CFLAGS+= -Wall LDFLAGS= -nostdlib -static -Ttext 0x0 # i386 standalone support library LIBI386= ${.OBJDIR}/../libi386/libi386.a CFLAGS+= -I${.CURDIR}/.. # where to get libstand from #XXX need a better way to do this LIBSTAND= ${.CURDIR}/../../../../lib/libstand/libstand.a .if !exists(${LIBSTAND}) LIBSTAND= ${.OBJDIR}/../../../../lib/libstand/libstand.a .if !exists(${LIBSTAND}) LIBSTAND= -lstand .endif .endif CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/ # BTX components .if exists(${.OBJDIR}/../btx) BTXDIR= ${.OBJDIR}/../btx .else BTXDIR= ${.CURDIR}/../btx .endif BTXLDR= ${BTXDIR}/btxldr/btxldr BTXKERN= ${BTXDIR}/btx/btx BTXCRT= ${BTXDIR}/lib/crt0.o CFLAGS+= -I${.CURDIR}/../btx/lib # BTX is expecting ELF components CFLAGS+= -elf # Debug me! #CFLAGS+= -g #LDFLAGS+= -g vers.o: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT} ${CC} -c vers.c ${BASE}: ${BASE}.bin ${BTXLDR} ${BTXKERN} ${BTXCRT} btxld -v -f aout -e ${LOADER_ADDRESS} -o ${.TARGET} -l ${BTXLDR} \ -b ${BTXKERN} ${BASE}.bin # /usr/bin/kzip ${.TARGET} # mv ${.TARGET}.kz ${.TARGET} ${BASE}.bin: ${BASE}.sym cp ${.ALLSRC} ${.TARGET} strip -R .comment -R .note ${.TARGET} ${BASE}.help: help.common help.i386 cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET} .PATH: ${.CURDIR}/../../forth FILES= ${BASE}.help loader.4th support.4th loader.conf FILESDIR_loader.conf= /boot/defaults .if !exists(${DESTDIR}/boot/loader.rc) FILES+= loader.rc .endif .include <${.CURDIR}/../Makefile.inc> # Cannot use ${OBJS} above this line .include ${BASE}.sym: ${OBJS} ${LIBI386} ${LIBSTAND} ${LIBFICL} vers.o ${CC} ${LDFLAGS} -o ${.TARGET} ${BTXCRT} ${OBJS} vers.o \ ${LIBFICL} ${LIBI386} ${LIBSTAND} # If it's not there, don't consider it a target .if exists(${.CURDIR}/../../../i386/include) beforedepend ${OBJS}: machine machine: ln -sf ${.CURDIR}/../../../i386/include machine .endif CLEANFILES+= machine