optimize the menuconfig redrawing
[lunaix-os.git] / lunaix-os / usr / libc / makefile
1 include lunabuild.mkinc
2
3 include $(lbuild_mkinc)
4
5 libc_include := $(CURDIR)/includes
6
7 BUILD_DIR ?= bin
8 BUILD_NAME ?= liblunac
9
10 src_dirs := src
11 src_dirs += arch/$(ARCH)
12
13 obj_files := $(addsuffix .o, $(_LBUILD_SRCS))
14
15 build_lib := $(BUILD_DIR)/lib
16 build_include := $(BUILD_DIR)/includes
17
18 libc_include_opt = $(addprefix -I, $(libc_include))
19 global_include_opt = $(addprefix -I, $(INCLUDES) $(_LBUILD_INCS))
20
21 check_folders := $(src_dirs)
22 check_folders += $(build_lib) $(build_include)
23
24 $(BUILD_DIR):
25         @mkdir -p bin
26
27 %.check:
28         @if [ ! -d "$*" ]; then \
29                 echo "'$*' is not exists" && exit 1;\
30         fi
31
32 %.c.o: %.c
33         @$(call status_,CC,$@)
34         @$(CC) $(CFLAGS) $(libc_include_opt) $(global_include_opt) -c $< -o $@
35
36 %.S.o: %.S
37         @$(call status_,AS,$@)
38         @$(CC) $(CFLAGS) $(libc_include_opt) $(global_include_opt) -c $< -o $@
39
40 $(build_lib)/$(BUILD_NAME): $(obj_files)
41         @$(call status_,AR,$(*F))
42         @$(AR) rcs $@ $^
43
44 clean:
45         @rm -rf $(lbuild_dir)
46         @rm -f $(obj_files)
47
48 headers: $(libc_include)
49         @$(call status_,INSTALL,$(<F))
50         @cp -r $(libc_include)/* $(build_include)/
51
52 all: $(addsuffix .check, $(check_folders)) $(build_lib)/$(BUILD_NAME) headers
53         @cp arch/$(ARCH)/crt0.S.o $(build_lib)/crt0.o