Skip to content

Commit f59edf8

Browse files
W-M-Rxiaoxiang781216
authored andcommitted
libbuiltin/Makefile: Modify the libbuiltin makefile to standard
1. bin and kbin folders are dynamically generated 2. Context comes before depend, so the bin and kbin folders are created in the context construction phase. When the depend process comes, each library is downloaded, and a relative bin/xxx and kbin/xxx directory is created for each library to place files. This is to prevent duplicate file names. Signed-off-by: wangmingrong1 <[email protected]>
1 parent dbeaec4 commit f59edf8

File tree

5 files changed

+38
-97
lines changed

5 files changed

+38
-97
lines changed

libs/libbuiltin/Makefile

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,8 @@ CPPOBJS = $(addprefix $(BINDIR)$(DELIM), $(CPPSRCS:.cpp=$(OBJEXT)))
3838
SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS) $(CPPSRCS)
3939
OBJS = $(AOBJS) $(COBJS) $(CXXOBJS) $(CPPOBJS)
4040

41-
BUILTIN_CLEANDIR = $(foreach dir,$(LIBBUILTIN),$(dir)/$(dir))
42-
43-
all: $(OBJS)
44-
$(call ARCHIVE, $(BIN), $(OBJS))
45-
46-
.PHONY: depend clean distclean context $(LIBBUILTIN)
41+
all: $(BIN)
42+
.PHONY: depend clean distclean context
4743

4844
$(AOBJS): $(BINDIR)$(DELIM)%$(OBJEXT): %.S
4945
$(call ASSEMBLE, $<, $@)
@@ -57,15 +53,21 @@ $(CXXOBJS): $(BINDIR)$(DELIM)%$(OBJEXT): %.cxx
5753
$(CPPOBJS): $(BINDIR)$(DELIM)%$(OBJEXT): %.cpp
5854
$(call COMPILEXX, $<, $@)
5955

60-
context::
56+
bin:
57+
$(Q) mkdir $@
58+
59+
kbin:
60+
$(Q) mkdir $@
61+
62+
context:: bin kbin
6163

62-
.depend: $(LIBBUILTIN)
64+
.depend: Makefile $(SRCS) $(TOPDIR)$(DELIM).config
6365
$(Q) touch $@
6466

65-
depend: .depend
67+
depend:: .depend
6668

67-
$(BIN): depend
68-
$(Q) $(MAKE) all EXTRAFLAGS="$(EXTRAFLAGS)"
69+
$(BIN): $(OBJS)
70+
$(call ARCHIVE, $@, $(OBJS))
6971

7072
# C library for the kernel phase of the two-pass kernel build
7173

@@ -75,12 +77,11 @@ $(KBIN): $(OBJS)
7577
endif
7678

7779
clean:
80+
$(call CLEAN)
7881
$(call DELFILE, $(BIN))
79-
$(Q) $(MAKE) -C bin clean
80-
$(Q) $(MAKE) -C kbin clean
82+
$(call DELFILE, $(KBIN))
8183

8284
distclean:: clean
83-
$(Q) $(MAKE) -C bin distclean
84-
$(Q) $(MAKE) -C kbin distclean
85-
$(call DELFILE, .depend)
86-
$(call DELDIR, $(BUILTIN_CLEANDIR))
85+
$(call DELDIR, bin)
86+
$(call DELDIR, kbin)
87+
$(call DELDIR, .depend)

libs/libbuiltin/bin/Makefile

Lines changed: 0 additions & 35 deletions
This file was deleted.

libs/libbuiltin/compiler-rt/Make.defs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020

2121
include $(TOPDIR)/Make.defs
2222

23-
LIBBUILTIN += compiler-rt
24-
2523
COMPILER_RT_VERSION=$(CONFIG_COMPILER_RT_VERSION)
2624

2725
ifeq ($(CONFIG_ARCH_ARM),y)
@@ -34,27 +32,39 @@ else ifeq ($(CONFIG_ARCH_ARM64),y)
3432
ARCH = aarch64
3533
endif
3634

35+
COMPILER_RT_OBJDIR = compiler-rt \
36+
compiler-rt/compiler-rt \
37+
compiler-rt/compiler-rt/lib \
38+
compiler-rt/compiler-rt/lib/builtins \
39+
compiler-rt/compiler-rt/lib/builtins/$(ARCH) \
40+
compiler-rt/compiler-rt/lib/profile
41+
42+
BIN_OBJDIR = $(addprefix $(BINDIR)$(DELIM),$(COMPILER_RT_OBJDIR))
43+
KBIN_OBJDIR = $(addprefix $(KBINDIR)$(DELIM),$(COMPILER_RT_OBJDIR))
44+
3745
ifeq ($(wildcard compiler-rt/compiler-rt/lib),)
46+
3847
compiler-rt-$(COMPILER_RT_VERSION).src.tar.xz:
3948
$(call DOWNLOAD,https://github.com/llvm/llvm-project/releases/download/llvmorg-$(COMPILER_RT_VERSION),$@)
4049

4150
compiler-rt/compiler-rt: compiler-rt-$(COMPILER_RT_VERSION).src.tar.xz
4251
$(Q) tar -xf $<
4352
$(Q) mv compiler-rt-$(COMPILER_RT_VERSION).src $@
4453
$(call DELDIR, $<)
54+
$(Q) mkdir $(BIN_OBJDIR) $(KBIN_OBJDIR)
4555

4656
compiler-rt: compiler-rt/compiler-rt
47-
$(Q) mkdir $(BINDIR)/compiler-rt \
48-
$(BINDIR)/compiler-rt/compiler-rt \
49-
$(BINDIR)/compiler-rt/compiler-rt/lib \
50-
$(BINDIR)/compiler-rt/compiler-rt/lib/builtins \
51-
$(BINDIR)/compiler-rt/compiler-rt/lib/builtins/$(ARCH) \
52-
$(BINDIR)/compiler-rt/compiler-rt/lib/profile
5357

5458
endif
5559

60+
.PHONY: compiler-rt
61+
62+
depend:: compiler-rt
63+
5664
distclean::
57-
$(call DELDIR, $(BINDIR)/compiler-rt)
65+
$(call DELDIR, $(BIN_OBJDIR))
66+
$(call DELDIR, $(KBIN_OBJDIR))
67+
$(call DELDIR, compiler-rt/compiler-rt)
5868

5969
FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/include
6070
FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/lib/builtins

libs/libbuiltin/kbin/Makefile

Lines changed: 0 additions & 35 deletions
This file was deleted.

tools/Directories.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ CLEANDIRS += syscall
122122
endif
123123
endif
124124

125-
CONTEXTDIRS += libs$(DELIM)libc
125+
CONTEXTDIRS += libs$(DELIM)libc libs$(DELIM)libbuiltin
126126

127127
ifeq ($(CONFIG_LIBM_TOOLCHAIN)$(CONFIG_LIBM_NONE),)
128128
CONTEXTDIRS += libs$(DELIM)libm

0 commit comments

Comments
 (0)