git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Introducing LunaBuild to the build flow (#36)
[lunaix-os.git]
/
lunaix-os
/
kernel.mk
diff --git
a/lunaix-os/kernel.mk
b/lunaix-os/kernel.mk
index ba15fa37834e9d35ba2b2460c66b929c8f653233..9399e7154c0e26cf6db7800767f57d3468576a1c 100644
(file)
--- a/
lunaix-os/kernel.mk
+++ b/
lunaix-os/kernel.mk
@@
-1,50
+1,53
@@
include os.mkinc
include toolchain.mkinc
include os.mkinc
include toolchain.mkinc
-define ksrc_dirs
- kernel
- hal
- libs
- arch/$(ARCH)
-endef
-
-define kinc_dirs
- includes
- includes/usr
- arch/$(ARCH)/includes
-endef
-
+ksrc_files = $(shell cat .builder/sources.list)
+kinc_dirs = $(shell cat .builder/includes.list)
+khdr_files = $(shell cat .builder/headers.list)
+khdr_files += .builder/configs.h
kbin_dir := $(BUILD_DIR)
kbin := $(BUILD_NAME)
kbin_dir := $(BUILD_DIR)
kbin := $(BUILD_NAME)
-ksrc_files := $(foreach f, $(ksrc_dirs), $(shell find $(f) -name "*.[cS]"))
ksrc_objs := $(addsuffix .o,$(ksrc_files))
ksrc_deps := $(addsuffix .d,$(ksrc_files))
ksrc_objs := $(addsuffix .o,$(ksrc_files))
ksrc_deps := $(addsuffix .d,$(ksrc_files))
-
+khdr_opts := $(addprefix -include ,$(khdr_files))
kinc_opts := $(addprefix -I,$(kinc_dirs))
kinc_opts := $(addprefix -I,$(kinc_dirs))
+tmp_kbin := $(BUILD_DIR)/tmpk.bin
+ksymtable := lunaix_ksyms.o
-CFLAGS +=
-include flags.h
+CFLAGS +=
$(khdr_opts)
-%.S.o: %.S
+-include $(ksrc_deps)
+
+%.S.o: %.S $(khdr_files) kernel.mk
$(call status_,AS,$<)
$(call status_,AS,$<)
- @$(CC) $(
kinc_opts)
-c $< -o $@
+ @$(CC) $(
CFLAGS) $(kinc_opts) -MMD -MP
-c $< -o $@
-%.c.o: %.c
+%.c.o: %.c
$(khdr_files) kernel.mk
$(call status_,CC,$<)
$(call status_,CC,$<)
- @$(CC) $(CFLAGS) $(kinc_opts) -c $< -o $@
+ @$(CC) $(CFLAGS) $(kinc_opts) -
MMD -MP -
c $< -o $@
-$(
kbin): $(kbin_dir) $(ksrc_files)
$(ksrc_objs)
+$(
tmp_kbin):
$(ksrc_objs)
$(call status_,LD,$@)
$(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)
clean:
@rm -f $(ksrc_objs)
- @rm -f $(ksrc_deps)
\ No newline at end of file
+ @rm -f $(ksrc_deps)
+ @rm -f .lunaix_ksymtable.S $(ksymtable)
\ No newline at end of file