#here clear EXTRA_CFLAGS to permit it expand multitimes by submake
EXTRA_CFLAGS :=
TOPDIR?=$(CURDIR)/../../../bin/
src=$(TOPDIR)
export obj?=$(CURDIR)/build
export ISLA=1

export LOADADDR=0x9000000000200000
export COMBASE=0x8000000016100000
export COMBASE=0x800000001fe001e0

EXTRA_CFLAGS := $(CFLAGS_EXTRA) -DCOM1_BASE_ADDR=$(COMBASE) -D_KERNEL -DLOADADDR=$(LOADADDR) -I$(CURDIR) -I$(CURDIR)/include  -I$(TOPDIR)/include/loongarch -I$(TOPDIR)/include  -DCONFIG_BAUDRATE=115200 -DCPU_COUNT_PER_US=400  -save-temps=obj
export ARCH_FLAGS=-mabi=lp64 -Wa,-mla-global-with-pcrel
export CROSS_COMPILE=/loongson/ls3a5000/loongson-gnu-toolchain-8.3.2k2100-x86_64-loongarch64-linux-gnu-rc1.1a/bin/loongarch64-linux-gnu-
#export CROSS_COMPILE?=/opt/loongarch_toolchain/bin/loongarch64-linux-gnu-

all:
	make caclfreq.elf64
asm-offsets.c:
	touch asm-offsets.c

clean:
	rm -rf asm-offsets.c *.lds *.s *.s64 *.o *.o64 *.i *.a *.elf *.elf64 map.txt build libtiny64
	cd $(obj) && rm -f *.o *.a *.s *.o64 *.O *.O64 *.elf *.elf64 *.ELF64 *.lds *.bin *.bin64 *.i *.i64 *.a *.s *.s64 map.txt $(src)/include/asm/asm-offsets64.h $(src)/include/asm/asm-offsets32.h
	cd $(obj) && rm -rf lib*
caclfreq-objs = startla.o caclfreq.o
caclfreq-libs = tinyc


include $(TOPDIR)/elfrules.make
