X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/1fe5f5eb5378a47bf0f3451762743c162e40faad..92f7ad8ed12975c672869242959c55896d224183:/lunaix-os/kernel.mk?ds=inline diff --git a/lunaix-os/kernel.mk b/lunaix-os/kernel.mk index c844703..189e970 100644 --- a/lunaix-os/kernel.mk +++ b/lunaix-os/kernel.mk @@ -1,6 +1,8 @@ include os.mkinc include toolchain.mkinc +kexclusion = $(shell cat ksrc.excludes) + define ksrc_dirs kernel hal @@ -19,30 +21,45 @@ kbin_dir := $(BUILD_DIR) kbin := $(BUILD_NAME) ksrc_files := $(foreach f, $(ksrc_dirs), $(shell find $(f) -name "*.[cS]")) +ksrc_files := $(filter-out $(kexclusion),$(ksrc_files)) ksrc_objs := $(addsuffix .o,$(ksrc_files)) +ksrc_deps := $(addsuffix .d,$(ksrc_files)) kinc_opts := $(addprefix -I,$(kinc_dirs)) +tmp_kbin := $(BUILD_DIR)/tmpk.bin +ksymtable := lunaix_ksyms.o CFLAGS += -include flags.h +CFLAGS += -include config.h %.S.o: %.S $(call status_,AS,$<) - @$(CC) $(kinc_opts) -c $< -o $@ + @$(CC) $(CFLAGS) $(kinc_opts) -c $< -o $@ %.c.o: %.c $(call status_,CC,$<) @$(CC) $(CFLAGS) $(kinc_opts) -c $< -o $@ -$(kbin): $(ksrc_objs) $(kbin_dir) +$(tmp_kbin): $(ksrc_objs) $(call status_,LD,$@) - @$(CC) -T link/linker.ld -o $(kbin) $(ksrc_objs) $(LDFLAGS) + @$(CC) -T link/linker.ld $(LDFLAGS) -o $@ $^ + +$(ksymtable): $(tmp_kbin) + $(call status_,KSYM,$@) + @scripts/gen_ksymtable.sh DdRrTtAGg $< > .lunaix_ksymtable.S + @$(CC) $(CFLAGS) -c .lunaix_ksymtable.S -o $@ -$(kbin_dir)/modksyms: $(kbin) - $(call status_,GEN,$@) - @$(PY) scripts/syms_export.py --bits=32 --order=little -o "$@" "$<" +.PHONY: __do_relink +__do_relink: $(ksrc_objs) $(ksymtable) + $(call status_,LD,$(kbin)) + @$(CC) -T link/linker.ld $(LDFLAGS) -o $(kbin) $^ + @rm $(tmp_kbin) -all: $(kbin) $(kbin_dir)/modksyms +.PHONY: all +all: __do_relink clean: - @rm -f $(ksrc_objs) \ No newline at end of file + @rm -f $(ksrc_objs) + @rm -f $(ksrc_deps) + @rm -f .lunaix_ksymtable.S $(ksymtable) \ No newline at end of file