mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-08 03:47:15 -04:00
Review tlib building
This commit is contained in:
parent
7839d6d5b3
commit
a784cb50fa
4
Makefile
4
Makefile
@ -8,7 +8,7 @@ kernel/debug/kernel.bin: force_look
|
|||||||
init/debug/init.bin: force_look
|
init/debug/init.bin: force_look
|
||||||
cd init; $(MAKE)
|
cd init; $(MAKE)
|
||||||
|
|
||||||
tlib/libtlib.a: force_look
|
tlib/debug/libtlib.a: force_look
|
||||||
cd tlib; $(MAKE)
|
cd tlib; $(MAKE)
|
||||||
|
|
||||||
bootloader/stage1.bin: force_look
|
bootloader/stage1.bin: force_look
|
||||||
@ -17,7 +17,7 @@ bootloader/stage1.bin: force_look
|
|||||||
bootloader/stage2.bin: force_look
|
bootloader/stage2.bin: force_look
|
||||||
cd bootloader; $(MAKE) stage2.bin
|
cd bootloader; $(MAKE) stage2.bin
|
||||||
|
|
||||||
programs: force_look tlib/libtlib.a
|
programs: force_look tlib/debug/libtlib.a
|
||||||
cd programs/; ${MAKE} dist
|
cd programs/; ${MAKE} dist
|
||||||
|
|
||||||
compile: bootloader/stage1.bin bootloader/stage2.bin init/debug/init.bin kernel/debug/kernel.bin programs
|
compile: bootloader/stage1.bin bootloader/stage2.bin init/debug/init.bin kernel/debug/kernel.bin programs
|
||||||
|
25
cpp.mk
25
cpp.mk
@ -39,8 +39,8 @@ KERNEL_LINK_FLAGS=$(COMMON_LINK_FLAGS) -T linker.ld
|
|||||||
LIB_FLAGS=$(COMMON_CPP_FLAGS) $(FLAGS_64) $(WARNING_FLAGS) -mcmodel=small -fPIC -ffunction-sections -fdata-sections
|
LIB_FLAGS=$(COMMON_CPP_FLAGS) $(FLAGS_64) $(WARNING_FLAGS) -mcmodel=small -fPIC -ffunction-sections -fdata-sections
|
||||||
LIB_LINK_FLAGS=$(COMMON_CPP_FLAGS) $(FLAGS_64) $(WARNING_FLAGS) -mcmodel=small -fPIC -Wl,-gc-sections
|
LIB_LINK_FLAGS=$(COMMON_CPP_FLAGS) $(FLAGS_64) $(WARNING_FLAGS) -mcmodel=small -fPIC -Wl,-gc-sections
|
||||||
|
|
||||||
PROGRAM_FLAGS=$(COMMON_CPP_FLAGS) $(FLAGS_64) $(WARNING_FLAGS) -I../../tlib/include/ -I../../printf/include/ -static -L../../tlib/ -ltlib -mcmodel=small -fPIC
|
PROGRAM_FLAGS=$(COMMON_CPP_FLAGS) $(FLAGS_64) $(WARNING_FLAGS) -I../../tlib/include/ -I../../printf/include/ -static -L../../tlib/debug/ -ltlib -mcmodel=small -fPIC
|
||||||
PROGRAM_LINK_FLAGS=$(COMMON_CPP_FLAGS) $(FLAGS_64) $(WARNING_FLAGS) $(COMMON_LINK_FLAGS) -static -L../../tlib/ -ltlib -mcmodel=small -fPIC -z max-page-size=0x1000 -T ../linker.ld -Wl,-gc-sections
|
PROGRAM_LINK_FLAGS=$(COMMON_CPP_FLAGS) $(FLAGS_64) $(WARNING_FLAGS) $(COMMON_LINK_FLAGS) -static -L../../tlib/debug/ -ltlib -mcmodel=small -fPIC -z max-page-size=0x1000 -T ../linker.ld -Wl,-gc-sections
|
||||||
|
|
||||||
NO_COLOR=\x1b[0m
|
NO_COLOR=\x1b[0m
|
||||||
MODE_COLOR=\x1b[31;01m
|
MODE_COLOR=\x1b[31;01m
|
||||||
@ -113,3 +113,24 @@ debug/$(1): $(O_FILES)
|
|||||||
link: debug/$(1)
|
link: debug/$(1)
|
||||||
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
# Generate the rules for the CPP files of a directory
|
||||||
|
define tlib_compile_cpp_folder
|
||||||
|
|
||||||
|
debug/$(1)/%.cpp.d: $(1)/%.cpp
|
||||||
|
@ mkdir -p debug/$(1)/
|
||||||
|
@ $(CXX) $(LIB_FLAGS) -MM -MT debug/$(1)/$$*.cpp.o $(1)/$$*.cpp | sed -e 's@^\(.*\)\.o:@\1.d \1.o:@' > $$@
|
||||||
|
|
||||||
|
debug/$(1)/%.cpp.o: $(1)/%.cpp
|
||||||
|
@ mkdir -p debug/$(1)/
|
||||||
|
@ echo -e "$(MODE_COLOR)[debug]$(NO_COLOR) Compile (tlib) $(FILE_COLOR)$(1)/$$*.cpp$(NO_COLOR)"
|
||||||
|
@ $(CXX) $(LIB_FLAGS) -c $$< -o $$@
|
||||||
|
|
||||||
|
folder_cpp_files := $(wildcard $(1)/*.cpp)
|
||||||
|
folder_d_files := $$(folder_cpp_files:%.cpp=debug/%.cpp.d)
|
||||||
|
folder_o_files := $$(folder_cpp_files:%.cpp=debug/%.cpp.o)
|
||||||
|
|
||||||
|
D_FILES := $(D_FILES) $$(folder_d_files)
|
||||||
|
O_FILES := $(O_FILES) $$(folder_o_files)
|
||||||
|
|
||||||
|
endef
|
||||||
|
@ -1,25 +1,16 @@
|
|||||||
default: libtlib.a
|
default: debug/libtlib.a
|
||||||
|
|
||||||
include ../cpp.mk
|
include ../cpp.mk
|
||||||
|
|
||||||
CPP_FILES=$(wildcard src/*.cpp)
|
$(eval $(call tlib_compile_cpp_folder,src))
|
||||||
|
|
||||||
D_FILES=$(CPP_FILES:%.cpp=%.cpp.d)
|
debug/libtlib.a: $(O_FILES)
|
||||||
|
@ mkdir -p debug/
|
||||||
O_FILES=$(CPP_FILES:%.cpp=%.cpp.o)
|
@ echo -e "$(MODE_COLOR)[debug]$(NO_COLOR) Link (tlib) $(FILE_COLOR)$@$(NO_COLOR)"
|
||||||
|
@ ${AR} rcs debug/libtlib.a ${O_FILES}
|
||||||
src/%.cpp.d: $(CPP_FILES)
|
|
||||||
@ $(CXX) $(LIB_FLAGS) -MM -MT src/$*.cpp.o src/$*.cpp | sed -e 's@^\(.*\)\.o:@\1.d \1.o:@' > $@
|
|
||||||
|
|
||||||
src/%.cpp.o:
|
|
||||||
$(CXX) $(LIB_FLAGS) -c $< -o $@
|
|
||||||
|
|
||||||
-include $(D_FILES)
|
-include $(D_FILES)
|
||||||
|
|
||||||
libtlib.a: $(O_FILES)
|
|
||||||
${AR} rcs libtlib.a ${O_FILES}
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f libtlib.a
|
@ echo -e "Remove compiled files (deps/objects)"
|
||||||
rm -f $(O_FILES)
|
@ rm -rf debug
|
||||||
rm -f $(D_FILES)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user