HW_MACHINE_ARCH?= ${MACHINE_GNU_ARCH}
LDSCRIPT:= $(abspath arch/${ARCHDIR}/kern.ldscript)
-OBJS_BMK+= intr.o clock_subr.o kernel.o multiboot.o undefs.o
+SRCS+= intr.c clock_subr.c kernel.c multiboot.c undefs.c
include ../Makefile.inc
include arch/${ARCHDIR}/Makefile.inc
+OBJS:= $(patsubst %.c,${RROBJ}/platform/%.o,${SRCS}) \
+ $(patsubst %.S,${RROBJ}/platform/%.o,${ASMS})
+
.PHONY: clean cleandir test all
-all: include/hw/machine ${MAINOBJ} ${TARGETS}
+all: include/hw/machine archdirs ${MAINOBJ} ${TARGETS}
include/hw/machine:
@ln -sf ../arch/${HW_MACHINE_ARCH} include/hw/machine
links: include/hw/machine ../../include/bmk-pcpu
-${MAINOBJ}: ${OBJS_BMK} platformlibs
- ${CC} -nostdlib ${CFLAGS} -Wl,-r ${OBJS_BMK} -o $@ \
+${RROBJ}/platform/%.o: %.c
+ ${CC} ${CPPFLAGS} ${CFLAGS} -c $< -o $@
+
+${RROBJ}/platform/%.o: %.S
+ ${CC} -D_LOCORE ${CPPFLAGS} ${CFLAGS} -c $< -o $@
+
+${MAINOBJ}: ${OBJS} platformlibs
+ ${CC} -nostdlib ${CFLAGS} -Wl,-r ${OBJS} -o $@ \
-L${RROBJLIB}/libbmk_core -L${RROBJLIB}/libbmk_rumpuser \
-Wl,--whole-archive -lbmk_rumpuser -lbmk_core -Wl,--no-whole-archive
${OBJCOPY} -w -G bmk_* -G rumpuser_* -G jsmn_* \
-OBJS_BMK+= arch/amd64/locore.o arch/amd64/intr.o
-OBJS_BMK+= arch/amd64/machdep.o
+ASMS= arch/amd64/locore.S arch/amd64/intr.S
+SRCS+= arch/amd64/machdep.c
-OBJS_BMK+= arch/x86/boot.o
-OBJS_BMK+= arch/x86/cons.o arch/x86/vgacons.o arch/x86/serialcons.o
-OBJS_BMK+= arch/x86/cpu_subr.o
-OBJS_BMK+= arch/x86/x86_subr.o
-OBJS_BMK+= arch/x86/clock.o
-OBJS_BMK+= arch/x86/hypervisor.o
+SRCS+= arch/x86/boot.c
+SRCS+= arch/x86/cons.c arch/x86/vgacons.c arch/x86/serialcons.c
+SRCS+= arch/x86/cpu_subr.c
+SRCS+= arch/x86/x86_subr.c
+SRCS+= arch/x86/clock.c
+SRCS+= arch/x86/hypervisor.c
CFLAGS+= -mno-sse -mno-mmx
# avoid having to figure out routing
CFLAGS+= -DBMK_SCREW_INTERRUPT_ROUTING
-arch/amd64/locore.o: arch/amd64/locore.S
- ${CC} ${CFLAGS} ${CPPFLAGS} -D_LOCORE -c -o arch/amd64/locore.o $<
-
-arch/amd64/intr.o: arch/amd64/intr.S
- ${CC} ${CFLAGS} ${CPPFLAGS} -D_LOCORE -c -o arch/amd64/intr.o $<
+.PHONY: archdirs
+archdirs:
+ mkdir -p ${RROBJ}/platform/arch/amd64
+ mkdir -p ${RROBJ}/platform/arch/x86
-OBJS_BMK+= arch/arm/integrator/locore.o
-OBJS_BMK+= arch/arm/integrator/machdep.o
-OBJS_BMK+= arch/arm/integrator/serialcons.o
+ASMS= arch/arm/integrator/locore.o
+
+SRCS+= arch/arm/integrator/machdep.o
+SRCS+= arch/arm/integrator/serialcons.o
CPPFLAGS+= -Iarch/arm
-arch/arm/integrator/locore.o: arch/arm/integrator/locore.S
- ${CC} ${CFLAGS} ${CPPFLAGS} -D_LOCORE -c -o $@ $<
+.PHONY: archdirs
+archdirs:
+ mkdir -p ${RROBJ}/platform/arch/arm/integrator
-OBJS_BMK+= arch/i386/locore.o arch/i386/machdep.o
+ASMS= arch/i386/locore.o
-OBJS_BMK+= arch/x86/boot.o
-OBJS_BMK+= arch/x86/cons.o arch/x86/vgacons.o arch/x86/serialcons.o
-OBJS_BMK+= arch/x86/cpu_subr.o
-OBJS_BMK+= arch/x86/x86_subr.o
-OBJS_BMK+= arch/x86/clock.o
-OBJS_BMK+= arch/x86/hypervisor.o
+SRCS+= arch/i386/machdep.o
+
+SRCS+= arch/x86/boot.o
+SRCS+= arch/x86/cons.o arch/x86/vgacons.o arch/x86/serialcons.o
+SRCS+= arch/x86/cpu_subr.o
+SRCS+= arch/x86/x86_subr.o
+SRCS+= arch/x86/clock.o
+SRCS+= arch/x86/hypervisor.o
CFLAGS+= -mno-sse -mno-mmx -march=i686
-arch/i386/locore.o: arch/i386/locore.S
- ${CC} ${CFLAGS} ${CPPFLAGS} -D_LOCORE -c -o arch/i386/locore.o $<
+.PHONY: archdirs
+archdirs:
+ mkdir -p ${RROBJ}/platform/arch/i386
+ mkdir -p ${RROBJ}/platform/arch/x86