From fd37d1975a957343a4b9f0c93fb98d6f91ca91cb Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Wed, 28 Jan 2009 01:04:49 +0000 Subject: "make utils" now successfully makes utils for target --- utils/Makefile.in | 86 +++++++++++++++++++++++++++++++++++++++++++------------ utils/ldconfig.c | 8 +++--- 2 files changed, 71 insertions(+), 23 deletions(-) (limited to 'utils') diff --git a/utils/Makefile.in b/utils/Makefile.in index 966821e1f..f9a30af7d 100644 --- a/utils/Makefile.in +++ b/utils/Makefile.in @@ -4,11 +4,12 @@ # # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. - # "make utils" flags -CFLAGS-utils := -DNOT_IN_libc $(SSP_ALL_CFLAGS) \ - -B$(top_builddir)lib -Wl,-rpath-link,$(top_builddir)lib +# ldconfig,ldd,readelf had also: +# -Wl,-rpath,/lib +# -Wl,--dynamic-linker,/lib/ld-uClibc.so.0 +# -Wl,--hash-style=gnu ifeq ($(UCLIBC_BUILD_PIE),y) CFLAGS-utils-shared := $(PIEFLAG) $(LDPIEFLAG) @@ -16,23 +17,60 @@ else CFLAGS-utils-shared := endif -CFLAGS-ldconfig := -I$(top_srcdir)ldso/include \ - -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" -DUCLIBC_LDSO=$(UCLIBC_LDSO) +CFLAGS-ldconfig := \ + -I$(top_srcdir)ldso/include \ + -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \ + -DUCLIBC_LDSO=$(UCLIBC_LDSO) ifeq ($(UCLIBC_STATIC_LDCONFIG),y) CFLAGS-ldconfig += -static else -CFLAGS-ldconfig += $(CFLAGS-utils-shared) +CFLAGS-ldconfig += \ + $(CFLAGS-utils-shared) \ + -Wl,-rpath-link,$(top_builddir)lib endif - -CFLAGS-ldd := -I$(top_srcdir)ldso/include \ +# Can't just pull in $(CFLAGS), there are bad include paths. +# We want to use "sanitized" headers in LOCAL_INSTALL_PATH. +CFLAGS-ldconfig += \ + $(XWARNINGS) $(CPU_CFLAGS) $(SSP_CFLAGS) $(OPTIMIZATION) \ + -nostdinc \ + -I $(top_builddir)/$(LOCAL_INSTALL_PATH)/usr/include \ + $(CC_INC) \ + -B$(top_builddir)lib \ + +CFLAGS-ldd := \ + $(CFLAGS-utils-shared) \ + $(XWARNINGS) $(CPU_CFLAGS) $(SSP_CFLAGS) $(OPTIMIZATION) \ -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" -DUCLIBC_LDSO=$(UCLIBC_LDSO) \ - $(CFLAGS-utils-shared) - -CFLAGS-readelf := $(CFLAGS-utils-shared) - -# Need CFLAGS-utils explicitly, because the source file is not located in utils -CFLAGS-iconv := $(CFLAGS-utils) $(CFLAGS-utils-shared) -DL_iconv_main -CFLAGS-locale := $(CFLAGS-utils) + -nostdinc \ + -I$(top_srcdir)ldso/include \ + -I$(top_builddir)/$(LOCAL_INSTALL_PATH)/usr/include \ + $(CC_INC) \ + -B$(top_builddir)lib \ + -Wl,-rpath-link,$(top_builddir)lib \ + +CFLAGS-readelf := \ + $(CFLAGS-utils-shared) \ + $(XWARNINGS) $(CPU_CFLAGS) $(SSP_CFLAGS) $(OPTIMIZATION) \ + -nostdinc \ + -I $(top_builddir)/$(LOCAL_INSTALL_PATH)/usr/include \ + $(CC_INC) \ + -B$(top_builddir)lib \ + -Wl,-rpath-link,$(top_builddir)lib \ + +# iconv and locale use non-sanitized headers by just pulling in $(CFLAGS) +CFLAGS-iconv := \ + $(CFLAGS) $(CFLAGS-utils-shared) \ + -DNOT_IN_libc \ + -DL_iconv_main \ + -I$(top_srcdir)/$(KERNEL_HEADERS) \ + -B$(top_builddir)lib \ + -Wl,-rpath-link,$(top_builddir)lib \ + +CFLAGS-locale := \ + $(CFLAGS) $(CFLAGS-utils-shared) \ + -DNOT_IN_libc \ + -B$(top_builddir)lib \ + -Wl,-rpath-link,$(top_builddir)lib \ # "make hostutils" flags @@ -44,13 +82,15 @@ endif BUILD_CFLAGS-ldconfig.host := -Wl,-s \ -include $(top_srcdir)include/elf.h \ -I$(top_srcdir)ldso/include \ - -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" -DUCLIBC_LDSO=$(UCLIBC_LDSO) \ + -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \ + -DUCLIBC_LDSO=$(UCLIBC_LDSO) \ $(LDSO_CACHE_SUPPORT) \ BUILD_CFLAGS-ldd.host := -Wl,-s \ -include $(top_srcdir)include/elf.h \ -I$(top_srcdir)ldso/include \ - -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" -DUCLIBC_LDSO=$(UCLIBC_LDSO) \ + -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \ + -DUCLIBC_LDSO=$(UCLIBC_LDSO) \ $(LDSO_CACHE_SUPPORT) \ BUILD_CFLAGS-readelf.host := -Wl,-s \ @@ -70,8 +110,8 @@ ifeq ($(HAVE_SHARED),y) utils_OBJ += ldconfig ldd endif -utils_ICONV_OBJ = -utils_LOCALE_OBJ = +utils_ICONV_OBJ := +utils_LOCALE_OBJ := ifeq ($(UCLIBC_HAS_LOCALE),y) utils_ICONV_OBJ := $(utils_OUT)/iconv utils_LOCALE_OBJ := $(utils_OUT)/locale @@ -94,6 +134,14 @@ $(utils_OUT)/iconv: $(top_srcdir)libc/misc/wchar/wchar.c | $(libc) $(utils_OUT)/locale: $(top_srcdir)extra/locale/programs/locale.c | $(libc) $(compile.u) +# Instruct make to install uclibc locally before buiding target utils +$(utils_OBJ): | $(top_builddir)/$(LOCAL_INSTALL_PATH) +$(utils_OUT)/iconv: | $(top_builddir)/$(LOCAL_INSTALL_PATH) +$(utils_OUT)/locale: | $(top_builddir)/$(LOCAL_INSTALL_PATH) + +$(top_builddir)/$(LOCAL_INSTALL_PATH): + $(Q)$(MAKE) -C $(top_builddir) $(LOCAL_INSTALL_PATH) + hostutils: $(hostutils_OBJ) $(hostutils_OBJ): $(utils_OUT)/%.host : $(utils_DIR)/%.c diff --git a/utils/ldconfig.c b/utils/ldconfig.c index c0857bc40..0c53cabb4 100644 --- a/utils/ldconfig.c +++ b/utils/ldconfig.c @@ -278,12 +278,12 @@ char *is_shlib(const char *dir, const char *name, int *type, if (fread(&exec, sizeof exec, 1, file) < 1) warnx("can't read header from %s, skipping", buff); else if (N_MAGIC(exec) != ZMAGIC - && N_MAGIC(exec) != QMAGIC - && N_MAGIC_SWAP(exec) != ZMAGIC - && N_MAGIC_SWAP(exec) != QMAGIC) { + && N_MAGIC(exec) != QMAGIC + && N_MAGIC_SWAP(exec) != ZMAGIC + && N_MAGIC_SWAP(exec) != QMAGIC) { elf_hdr = (ElfW(Ehdr) *) & exec; if (elf_hdr->e_ident[0] != 0x7f || - strncmp(elf_hdr->e_ident+1, "ELF", 3) != 0) + strncmp((char *)elf_hdr->e_ident + 1, "ELF", 3) != 0) { /* silently ignore linker scripts */ if (strncmp((char *)&exec, "/* GNU ld", 9) != 0) -- cgit v1.2.3