Skip to content

Commit

Permalink
libbuiltin/Makefile: Modify the libbuiltin makefile to standard
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
W-M-R authored and xiaoxiang781216 committed Nov 10, 2024
1 parent dbeaec4 commit f59edf8
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 97 deletions.
35 changes: 18 additions & 17 deletions libs/libbuiltin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,8 @@ CPPOBJS = $(addprefix $(BINDIR)$(DELIM), $(CPPSRCS:.cpp=$(OBJEXT)))
SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS) $(CPPSRCS)
OBJS = $(AOBJS) $(COBJS) $(CXXOBJS) $(CPPOBJS)

BUILTIN_CLEANDIR = $(foreach dir,$(LIBBUILTIN),$(dir)/$(dir))

all: $(OBJS)
$(call ARCHIVE, $(BIN), $(OBJS))

.PHONY: depend clean distclean context $(LIBBUILTIN)
all: $(BIN)
.PHONY: depend clean distclean context

$(AOBJS): $(BINDIR)$(DELIM)%$(OBJEXT): %.S
$(call ASSEMBLE, $<, $@)
Expand All @@ -57,15 +53,21 @@ $(CXXOBJS): $(BINDIR)$(DELIM)%$(OBJEXT): %.cxx
$(CPPOBJS): $(BINDIR)$(DELIM)%$(OBJEXT): %.cpp
$(call COMPILEXX, $<, $@)

context::
bin:
$(Q) mkdir $@

kbin:
$(Q) mkdir $@

context:: bin kbin

.depend: $(LIBBUILTIN)
.depend: Makefile $(SRCS) $(TOPDIR)$(DELIM).config
$(Q) touch $@

depend: .depend
depend:: .depend

$(BIN): depend
$(Q) $(MAKE) all EXTRAFLAGS="$(EXTRAFLAGS)"
$(BIN): $(OBJS)
$(call ARCHIVE, $@, $(OBJS))

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

Expand All @@ -75,12 +77,11 @@ $(KBIN): $(OBJS)
endif

clean:
$(call CLEAN)
$(call DELFILE, $(BIN))
$(Q) $(MAKE) -C bin clean
$(Q) $(MAKE) -C kbin clean
$(call DELFILE, $(KBIN))

distclean:: clean
$(Q) $(MAKE) -C bin distclean
$(Q) $(MAKE) -C kbin distclean
$(call DELFILE, .depend)
$(call DELDIR, $(BUILTIN_CLEANDIR))
$(call DELDIR, bin)
$(call DELDIR, kbin)
$(call DELDIR, .depend)
35 changes: 0 additions & 35 deletions libs/libbuiltin/bin/Makefile

This file was deleted.

28 changes: 19 additions & 9 deletions libs/libbuiltin/compiler-rt/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

include $(TOPDIR)/Make.defs

LIBBUILTIN += compiler-rt

COMPILER_RT_VERSION=$(CONFIG_COMPILER_RT_VERSION)

ifeq ($(CONFIG_ARCH_ARM),y)
Expand All @@ -34,27 +32,39 @@ else ifeq ($(CONFIG_ARCH_ARM64),y)
ARCH = aarch64
endif

COMPILER_RT_OBJDIR = compiler-rt \
compiler-rt/compiler-rt \
compiler-rt/compiler-rt/lib \
compiler-rt/compiler-rt/lib/builtins \
compiler-rt/compiler-rt/lib/builtins/$(ARCH) \
compiler-rt/compiler-rt/lib/profile

BIN_OBJDIR = $(addprefix $(BINDIR)$(DELIM),$(COMPILER_RT_OBJDIR))
KBIN_OBJDIR = $(addprefix $(KBINDIR)$(DELIM),$(COMPILER_RT_OBJDIR))

ifeq ($(wildcard compiler-rt/compiler-rt/lib),)

compiler-rt-$(COMPILER_RT_VERSION).src.tar.xz:
$(call DOWNLOAD,https://github.com/llvm/llvm-project/releases/download/llvmorg-$(COMPILER_RT_VERSION),$@)

compiler-rt/compiler-rt: compiler-rt-$(COMPILER_RT_VERSION).src.tar.xz
$(Q) tar -xf $<
$(Q) mv compiler-rt-$(COMPILER_RT_VERSION).src $@
$(call DELDIR, $<)
$(Q) mkdir $(BIN_OBJDIR) $(KBIN_OBJDIR)

compiler-rt: compiler-rt/compiler-rt
$(Q) mkdir $(BINDIR)/compiler-rt \
$(BINDIR)/compiler-rt/compiler-rt \
$(BINDIR)/compiler-rt/compiler-rt/lib \
$(BINDIR)/compiler-rt/compiler-rt/lib/builtins \
$(BINDIR)/compiler-rt/compiler-rt/lib/builtins/$(ARCH) \
$(BINDIR)/compiler-rt/compiler-rt/lib/profile

endif

.PHONY: compiler-rt

depend:: compiler-rt

distclean::
$(call DELDIR, $(BINDIR)/compiler-rt)
$(call DELDIR, $(BIN_OBJDIR))
$(call DELDIR, $(KBIN_OBJDIR))
$(call DELDIR, compiler-rt/compiler-rt)

FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/include
FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/lib/builtins
Expand Down
35 changes: 0 additions & 35 deletions libs/libbuiltin/kbin/Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion tools/Directories.mk
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ CLEANDIRS += syscall
endif
endif

CONTEXTDIRS += libs$(DELIM)libc
CONTEXTDIRS += libs$(DELIM)libc libs$(DELIM)libbuiltin

ifeq ($(CONFIG_LIBM_TOOLCHAIN)$(CONFIG_LIBM_NONE),)
CONTEXTDIRS += libs$(DELIM)libm
Expand Down

0 comments on commit f59edf8

Please sign in to comment.