diff options
Diffstat (limited to 'libc')
-rw-r--r-- | libc/Makefile | 77 |
1 files changed, 39 insertions, 38 deletions
diff --git a/libc/Makefile b/libc/Makefile index 14b83ef42..c9c9ac315 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -37,9 +37,17 @@ DIRS = misc pwd_grp stdio string termios inet signal stdlib sysdeps unistd VERSION_SCRIPT:=${shell if [ -f sysdeps/linux/$(TARGET_ARCH)/libc.map ] ; then \ echo "--version-script sysdeps/linux/$(TARGET_ARCH)/libc.map"; fi} -LIBNAME_TARGET:=$(TOPDIR)lib/$(LIBNAME) - -all: halfclean $(LIBNAME_TARGET) +# we have SHARED_MAJORNAME=libc.so.$(MAJOR_VERSION) defined in Rules.mak +LIB_NAME=libc +AR_LIB_NAME=$(TOPDIR)lib/$(LIB_NAME).a +SO_LIB_NAME=$(TOPDIR)lib/$(LIB_NAME).so +SO_FULL_NAME=libuClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so + +ifeq ($(strip $(HAVE_SHARED)),y) +all: $(SO_LIB_NAME) +else +all: $(AR_LIB_NAME) +endif # Some functions are duplicated across subdirs, and when you pass $(AR) # the same object file more than once, it'll add it to the archive multiple @@ -52,62 +60,55 @@ all: halfclean $(LIBNAME_TARGET) # the wildcard will be evaluated when `make` is run instead of when the make # target is evaluated. That means if you run `rm obj.* ; make`, the wildcard # will evaluate to no files :(. -$(LIBNAME) shared_$(LIBNAME) ar-target: subdirs - $(RM) $(LIBNAME) shared_$(LIBNAME) +shared_$(LIB_NAME).a: subdirs + $(RM) shared_$(LIB_NAME).a objs=`cat obj.*` ; \ - $(AR) $(ARFLAGS) $(LIBNAME) $$objs && \ - $(AR) dN 2 $(LIBNAME) $$objs && \ - $(AR) dN 2 $(LIBNAME) $$objs + $(AR) $(ARFLAGS) shared_$(LIB_NAME).a $$objs && \ + $(AR) dN 2 shared_$(LIB_NAME).a $$objs && \ + $(AR) dN 2 shared_$(LIB_NAME).a $$objs @for objfile in obj.signal \ obj.string.generic obj.string.$(TARGET_ARCH) obj.string \ obj.sysdeps.common obj.sysdeps.$(TARGET_ARCH) ; do \ if [ -e $$objfile ] ; then \ if [ "$(MAKE_IS_SILENT)" = "n" ] ; then \ - echo $(AR) $(ARFLAGS) $(LIBNAME) $$objfile ; \ + echo $(AR) $(ARFLAGS) shared_$(LIB_NAME).a $$objfile ; \ fi ; \ objs=`cat $$objfile` ; \ fi ; \ - $(AR) $(ARFLAGS) $(LIBNAME) $$objs || exit 1 ; \ + $(AR) $(ARFLAGS) shared_$(LIB_NAME).a $$objs || exit 1 ; \ done - cp $(LIBNAME) shared_$(LIBNAME) - $(AR) $(ARFLAGS) $(LIBNAME) misc/internals/static.o `cat nonshared_obj.*` - $(RANLIB) $(LIBNAME) -$(LIBNAME_TARGET): $(LIBNAME) +$(AR_LIB_NAME): shared_$(LIB_NAME).a $(INSTALL) -d $(TOPDIR)lib - $(RM) $(TOPDIR)lib/$(LIBNAME) - $(INSTALL) -m 644 $(LIBNAME) $(TOPDIR)lib - -shared: shared_$(LIBNAME) - $(LD) $(LDFLAGS) $(VERSION_SCRIPT) -soname=$(SHARED_MAJORNAME) -o $(SHARED_FULLNAME) \ - --whole-archive shared_$(LIBNAME) \ - $(TOPDIR)libc/misc/internals/interp.o --no-whole-archive \ - -init __uClibc_init $(TOPDIR)lib/$(UCLIBC_LDSO) $(LIBGCC) $(LDADD_LIBFLOAT) - $(INSTALL) -d $(TOPDIR)lib - $(RM) $(TOPDIR)lib/$(SHARED_FULLNAME) - $(INSTALL) -m 644 $(SHARED_FULLNAME) $(TOPDIR)lib - $(LN) -sf $(SHARED_FULLNAME) $(TOPDIR)lib/$(SHARED_MAJORNAME) + $(RM) $(AR_LIB_NAME) + cp shared_$(LIB_NAME).a $(AR_LIB_NAME) + $(AR) $(ARFLAGS) $(AR_LIB_NAME) misc/internals/static.o `cat nonshared_obj.*` + +$(SO_LIB_NAME): shared_$(LIB_NAME).a + $(RM) $(TOPDIR)lib/$(SO_FULL_NAME) $(TOPDIR)lib/$(SHARED_MAJORNAME) $(SO_LIB_NAME) + $(LD) $(LDFLAGS) $(VERSION_SCRIPT) -soname=$(SHARED_MAJORNAME) \ + -o $(TOPDIR)lib/$(SO_FULL_NAME) --whole-archive shared_$(LIB_NAME).a \ + --no-whole-archive $(TOPDIR)libc/misc/internals/interp.o \ + -init __uClibc_init $(TOPDIR)lib/$(UCLIBC_LDSO) $(LDADD_LIBFLOAT) $(LIBGCC) + $(LN) -sf $(SO_FULL_NAME) $(TOPDIR)lib/$(SHARED_MAJORNAME) + $(RM) $(TOPDIR)lib/$(NONSHARED_LIBNAME) $(AR) $(ARFLAGS) $(TOPDIR)lib/$(NONSHARED_LIBNAME) `cat nonshared_obj.*` - $(RANLIB) $(TOPDIR)lib/$(NONSHARED_LIBNAME) - echo "/* GNU ld script" > $(TOPDIR)lib/libc.so - echo " * Use the shared library, but some functions are only in" >> $(TOPDIR)lib/libc.so - echo " * the static library, so try that secondarily. */" >> $(TOPDIR)lib/libc.so + echo "/* GNU ld script" > $(SO_LIB_NAME) + echo " * Use the shared library, but some functions are only in" >> $(SO_LIB_NAME) + echo " * the static library, so try that secondarily. */" >> $(SO_LIB_NAME) #OUT_FORMAT:=$(shell $(LD) --verbose | grep OUTPUT_FORMAT | awk -F '"' '{print $2}') - #echo "OUTPUT_FORMAT($(OUT_FORMAT))" >> $(TOPDIR)lib/libc.so + #echo "OUTPUT_FORMAT($(OUT_FORMAT))" >> $(SO_LIB_NAME) ifeq ($(strip $(COMPAT_ATEXIT)),y) - echo "GROUP ( $(TOPDIR)lib/$(NONSHARED_LIBNAME) $(TOPDIR)lib/$(SHARED_MAJORNAME) )" >> $(TOPDIR)lib/libc.so + echo "GROUP ( $(TOPDIR)lib/$(NONSHARED_LIBNAME) $(TOPDIR)lib/$(SHARED_MAJORNAME) )" >> $(SO_LIB_NAME) else - echo "GROUP ( $(TOPDIR)lib/$(SHARED_MAJORNAME) $(TOPDIR)lib/$(NONSHARED_LIBNAME) )" >> $(TOPDIR)lib/libc.so + echo "GROUP ( $(TOPDIR)lib/$(SHARED_MAJORNAME) $(TOPDIR)lib/$(NONSHARED_LIBNAME) )" >> $(SO_LIB_NAME) endif -halfclean: - $(RM) $(LIBNAME) shared_$(LIBNAME) $(SHARED_FULLNAME) - tags: ctags -R -clean: subdirs_clean halfclean - $(RM) obj.* nonshared_obj.* +clean: subdirs_clean + $(RM) *.a obj.* nonshared_obj.* subdirs: $(patsubst %, _dir_%, $(DIRS)) subdirs_clean: $(patsubst %, _dirclean_%, $(DIRS)) |