view src/old_makefiles/makefile-armclang @ 120:ed85941a7514

mv old-makefiel
author anatofuz
date Mon, 02 Dec 2019 19:12:01 +0900
parents src/makefile-armclang@33c9000056b5
children
line wrap: on
line source

# specify path to QEMU, installed with MacPorts 
QEMU = qemu-system-arm

CPU = armv8
QEMUCPU = cortex-a15
include makefile.inc
CC = /usr/local/cbclang/bin/clang
AS = arm-linux-gnu-as
LD = arm-linux-gnu-ld
OBJCOPY = arm-linux-gnu-objcopy
OBJDUMP = arm-linux-gnu-objdump

# CFLAGS = -march=${CPU} -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -Werror -I. -g -O0
CFLAGS = -target ${CPU}-linux-gnueabihf -march=${CPU} -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -I. -I ../cbclang/arm -g -O0
LDFLAGS = --noinhibit-exec
# ASFLAGS = -march=${CPU}
ASFLAGS = -target ${CPU}-linux-gnueabihf

LIBGCC = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)

# link the libgcc.a for __aeabi_idiv. ARM has no native support for div
LIBS =/net/open/RaspberryPi/rasbian-img/usr/lib/gcc/arm-linux-gnueabihf/6/libgcc.a


OBJS = \
	lib/string.o \
	\
	arm.o\
	asm.o\
	bio.o\
	buddy.o\
	console.o\
	exec.o\
	file.o\
	fs.o\
	log.o\
	main.o\
	memide.o\
	pipe.o\
	proc.o\
	spinlock.o\
	start.o\
	swtch.o\
	syscall.o\
	sysfile.o\
	sysproc.o\
	trap_asm.o\
	trap.o\
	vm.o \
	\
	device/picirq.o \
	device/timer.o \
	device/uart.o

KERN_OBJS = $(OBJS) entry-clang.o
kernel.elf: $(addprefix build/,$(KERN_OBJS)) kernel-clang.ld build/initcode build/fs.img
	cp -f build/initcode initcode
	cp -f build/fs.img fs.img
	$(call LINK_BIN, kernel-clang.ld, kernel.elf, \
		$(addprefix build/,$(KERN_OBJS)), \
		initcode fs.img)
	$(OBJDUMP) -S kernel.elf > kernel.asm
	$(OBJDUMP) -t kernel.elf | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$$/d' > kernel.sym
	rm -f initcode fs.img

qemu: kernel.elf
	@clear
	@echo "Press Ctrl-A and then X to terminate QEMU session\n"
	export QEMU_AUDIO_DRV=none ; $(QEMU) -M versatilepb -m 128 -cpu ${QEMUCPU}  -nographic -soundhw hda -kernel kernel.elf

qemu-debug : kernel.elf
	@clear
	@echo "Press Ctrl-A and then X to terminate QEMU session\n"
	export QEMU_AUDIO_DRV=none ; $(QEMU)  -M versatilepb -m 128 -cpu ${QEMUCPU} -nographic -singlestep -d exec,cpu,guest_errors -D qemu.log -kernel kernel.elf -s -S

INITCODE_OBJ = initcode.o
$(addprefix build/,$(INITCODE_OBJ)): initcode.S
	$(call build-directory)
	$(call AS_WITH, -nostdinc -I.)

#initcode is linked into the kernel, it will be used to craft the first process
build/initcode: $(addprefix build/,$(INITCODE_OBJ))
	$(call LINK_INIT, -N -e start -Ttext 0)
	$(call OBJCOPY_INIT)
	$(OBJDUMP) -S $< > initcode.asm

build/fs.img:
	make -C tools
	make -C usr

clean: 
	rm -rf build
	rm -f *.o *.d *.asm *.sym vectors.S bootblock entryother \
	initcode initcode.out kernel xv6.img fs.img kernel.elf memfs
	make -C tools clean
	make -C usr clean