walnux/libs/libbuiltin/Makefile
wangmingrong1 f59edf8645 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 <wangmingrong1@xiaomi.com>
2024-11-10 10:19:58 +08:00

87 lines
2.3 KiB
Makefile

############################################################################
# libs/libbuiltin/Makefile
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
###########################################################################
include $(TOPDIR)/Make.defs
BIN ?= libbuiltin$(LIBEXT)
BINDIR ?= bin
KBIN = libkbuiltin$(LIBEXT)
KBINDIR = kbin
ifeq ($(CONFIG_BUILTIN_COMPILER_RT),y)
include compiler-rt/Make.defs
endif
AOBJS = $(addprefix $(BINDIR)$(DELIM), $(ASRCS:.S=$(OBJEXT)))
COBJS = $(addprefix $(BINDIR)$(DELIM), $(CSRCS:.c=$(OBJEXT)))
CXXOBJS = $(addprefix $(BINDIR)$(DELIM), $(CXXSRCS:.cxx=$(OBJEXT)))
CPPOBJS = $(addprefix $(BINDIR)$(DELIM), $(CPPSRCS:.cpp=$(OBJEXT)))
SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS) $(CPPSRCS)
OBJS = $(AOBJS) $(COBJS) $(CXXOBJS) $(CPPOBJS)
all: $(BIN)
.PHONY: depend clean distclean context
$(AOBJS): $(BINDIR)$(DELIM)%$(OBJEXT): %.S
$(call ASSEMBLE, $<, $@)
$(COBJS): $(BINDIR)$(DELIM)%$(OBJEXT): %.c
$(call COMPILE, $<, $@)
$(CXXOBJS): $(BINDIR)$(DELIM)%$(OBJEXT): %.cxx
$(call COMPILEXX, $<, $@)
$(CPPOBJS): $(BINDIR)$(DELIM)%$(OBJEXT): %.cpp
$(call COMPILEXX, $<, $@)
bin:
$(Q) mkdir $@
kbin:
$(Q) mkdir $@
context:: bin kbin
.depend: Makefile $(SRCS) $(TOPDIR)$(DELIM).config
$(Q) touch $@
depend:: .depend
$(BIN): $(OBJS)
$(call ARCHIVE, $@, $(OBJS))
# C library for the kernel phase of the two-pass kernel build
ifneq ($(BIN),$(KBIN))
$(KBIN): $(OBJS)
$(Q) $(MAKE) $(KBIN) BIN=$(KBIN) BINDIR=$(KBINDIR) EXTRAFLAGS="$(EXTRAFLAGS)"
endif
clean:
$(call CLEAN)
$(call DELFILE, $(BIN))
$(call DELFILE, $(KBIN))
distclean:: clean
$(call DELDIR, bin)
$(call DELDIR, kbin)
$(call DELDIR, .depend)