feat: serial device interfacing
[lunaix-os.git] / lunaix-os / kernel.mk
index 81e8921201c9aae5770b2a7aab1f5644752c8587..c5596f893ab13b9d7929583b201b15b66a693c48 100644 (file)
@@ -1,10 +1,11 @@
 include os.mkinc
 include toolchain.mkinc
 
 include os.mkinc
 include toolchain.mkinc
 
+kexclusion = $(shell cat ksrc.excludes)
+
 define ksrc_dirs
        kernel
        hal
 define ksrc_dirs
        kernel
        hal
-       debug
        libs
        arch/$(ARCH)
 endef
        libs
        arch/$(ARCH)
 endef
@@ -12,6 +13,7 @@ endef
 define kinc_dirs
        includes
        includes/usr
 define kinc_dirs
        includes
        includes/usr
+       arch/$(ARCH)/includes
 endef
 
 
 endef
 
 
@@ -19,7 +21,9 @@ kbin_dir := $(BUILD_DIR)
 kbin := $(BUILD_NAME)
 
 ksrc_files := $(foreach f, $(ksrc_dirs), $(shell find $(f) -name "*.[cS]"))
 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_objs := $(addsuffix .o,$(ksrc_files))
+ksrc_deps := $(addsuffix .d,$(ksrc_files))
 
 kinc_opts := $(addprefix -I,$(kinc_dirs))
 
 
 kinc_opts := $(addprefix -I,$(kinc_dirs))
 
@@ -34,11 +38,18 @@ CFLAGS += -include flags.h
        $(call status_,CC,$<)
        @$(CC) $(CFLAGS) $(kinc_opts) -c $< -o $@
 
        $(call status_,CC,$<)
        @$(CC) $(CFLAGS) $(kinc_opts) -c $< -o $@
 
-$(kbin): $(ksrc_objs) $(kbin_dir)
-       $(call status_,LD,$@)
+$(kbin_dir)/modksyms: $(kbin)
+       $(call status_,MOD,$@)
+       @$(PY) scripts/syms_export.py --bits=32 --order=little -o "$@"  "$<" 
+
+.PHONY: __do_relink
+__do_relink: $(ksrc_objs)
+       $(call status_,LD,$(kbin))
        @$(CC) -T link/linker.ld -o $(kbin) $(ksrc_objs) $(LDFLAGS)
 
        @$(CC) -T link/linker.ld -o $(kbin) $(ksrc_objs) $(LDFLAGS)
 
-all: $(kbin)
+.PHONY: all
+all: __do_relink $(kbin_dir)/modksyms
 
 clean:
 
 clean:
-       @rm -f $(ksrc_objs)
\ No newline at end of file
+       @rm -f $(ksrc_objs)
+       @rm -f $(ksrc_deps)
\ No newline at end of file