diff options
-rw-r--r-- | Makefile.in | 10 | ||||
-rw-r--r-- | Makerules | 4 | ||||
-rw-r--r-- | Rules.mak | 87 | ||||
-rw-r--r-- | libc/misc/wchar/wchar.c | 2 | ||||
-rw-r--r-- | test/Rules.mak | 5 | ||||
-rw-r--r-- | utils/Makefile.in | 86 | ||||
-rw-r--r-- | utils/ldconfig.c | 8 |
7 files changed, 138 insertions, 64 deletions
diff --git a/Makefile.in b/Makefile.in index 3234b050f..7f03e96f8 100644 --- a/Makefile.in +++ b/Makefile.in @@ -178,14 +178,14 @@ include/bits/sysnum.h: $(top_srcdir)extra/scripts/gen_bits_syscall_h.sh fi $(LOCAL_INSTALL_PATH): - $(Q)$(MAKE) PREFIX=$(shell pwd)/ RUNTIME_PREFIX=./ \ - DEVEL_PREFIX=$(LOCAL_INSTALL_PATH)/usr/ \ + $(Q)$(MAKE) PREFIX=$(shell pwd)/$(LOCAL_INSTALL_PATH) RUNTIME_PREFIX=/ \ + DEVEL_PREFIX=/usr/ \ HOSTCC="$(HOSTCC)" \ install_kernel_headers - $(Q)$(MAKE) PREFIX=$(shell pwd)/ RUNTIME_PREFIX=./ \ - DEVEL_PREFIX=$(LOCAL_INSTALL_PATH)/usr/ \ + $(Q)$(MAKE) PREFIX=$(shell pwd)/$(LOCAL_INSTALL_PATH) RUNTIME_PREFIX=/ \ + DEVEL_PREFIX=/usr/ \ HOSTCC="$(HOSTCC)" \ - install_dev + install install: install_runtime install_dev @@ -190,7 +190,9 @@ cmd_compile.c = $(CC) -c $< -o $@ $(CFLAGS) $(ARCH_CFLAGS) \ $(CFLAGS_gen.dep) cmd_compile.i = $(cmd_compile.c:-c=-E -dD $(EXTRA_CPPFLAGS)) cmd_compile.s = $(cmd_compile.c:-c=-S) -cmd_compile.u = $(CC) $^ $(DEPS-$(notdir $@)) -o $@ $(CFLAGS) $(CFLAGS-$(notdir $(^D))) $(CFLAGS-$(notdir $@)) $(CFLAGS_gen.dep) +#vda +###_compile.u = $(CC) $^ $(DEPS-$(notdir $@)) -o $@ $(CFLAGS) $(CFLAGS-$(notdir $(^D))) $(CFLAGS-$(notdir $@)) $(CFLAGS_gen.dep) +cmd_compile.u = $(CC) $^ $(DEPS-$(notdir $@)) -o $@ $(CFLAGS-$(notdir $(^D))) $(CFLAGS-$(notdir $@)) $(CFLAGS_gen.dep) cmd_compile.S = $(filter-out -std=gnu99, $(cmd_compile.c)) -D__ASSEMBLER__ $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS-$(suffix $@)) $(ASFLAGS-$(notdir $<)) $(ASFLAGS-$(notdir $@)) cmd_compile.m = $(cmd_compile.c) -DL_$(patsubst %$(suffix $(notdir $@)),%,$(notdir $@)) cmd_compile.mi= $(cmd_compile.m:-c=-E -dD $(EXTRA_CPPFLAGS)) @@ -5,6 +5,17 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # +# make nano-doc +# FOO = bar -- recursively expanded variable. Value is remebered verbatim. +# If it contains references to other variables, these references +# are expanded whenever this variable is _substituted_. +# FOO := bar -- simply expanded variable. Right hand is expanded when +# the variable is _defined_. Therefore faster than =. +# FOO ?= bar -- set a value only if it is not already set +# (behaves as =, not :=). +# FOO += bar -- append; if FOO is not defined, acts like = (not :=). + + # check for proper make version ifneq ($(findstring x3.7,x$(MAKE_VERSION)),) $(error Your make is too old $(MAKE_VERSION). Go get at least 3.80) @@ -66,6 +77,7 @@ export ARCH := $(shell uname -m | $(SED) -e s/i.86/i386/ \ # mortals. Unless you hang out with the gods, you should # probably leave all this stuff alone. + # Pull in the user's uClibc configuration ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) -include $(top_builddir).config @@ -148,7 +160,9 @@ check_ld=$(shell \ ARFLAGS:=cr + # Flags in OPTIMIZATION are used only for non-debug builds + OPTIMIZATION:= # Use '-Os' optimization if available, else use -O2, allow Config to override OPTIMIZATION+=$(call check_gcc,-Os,-O2) @@ -168,6 +182,37 @@ OPTIMIZATION+=$(call check_gcc,-fno-tree-dominator-opts,) OPTIMIZATION+=$(call check_gcc,-fno-strength-reduce,) endif + +# CPU_CFLAGS-y contain options which are not warnings, +# not include or library paths, and not optimizations. + +# Why -funsigned-char: I hunted a bug related to incorrect +# sign extension of 'char' type for 10 hours straight. Not fun. +CPU_CFLAGS-y := -funsigned-char -fno-builtin + +CPU_CFLAGS-y += $(call check_gcc,-fno-asm,) + +LDADD_LIBFLOAT= +ifeq ($(UCLIBC_HAS_SOFT_FLOAT),y) +# If -msoft-float isn't supported, we want an error anyway. +# Hmm... might need to revisit this for arm since it has 2 different +# soft float encodings. +ifneq ($(TARGET_ARCH),nios) +ifneq ($(TARGET_ARCH),nios2) +ifneq ($(TARGET_ARCH),sh) +CPU_CFLAGS-y += -msoft-float +endif +endif +endif +ifeq ($(TARGET_ARCH),arm) +# No longer needed with current toolchains, but leave it here for now. +# If anyone is actually still using gcc 2.95 (say), they can uncomment it. +# LDADD_LIBFLOAT=-lfloat +endif +endif + +CPU_CFLAGS-y += $(call check_gcc,-std=gnu99,) + CPU_CFLAGS-$(UCLIBC_FORMAT_SHARED_FLAT) += -mid-shared-library CPU_CFLAGS-$(UCLIBC_FORMAT_FLAT_SEP_DATA) += -msep-data @@ -468,9 +513,11 @@ ifeq ($(EXTRA_WARNINGS),y) XWARNINGS+=-Wnested-externs -Wshadow -Wmissing-noreturn -Wmissing-format-attribute -Wformat=2 XWARNINGS+=-Wmissing-prototypes -Wmissing-declarations XWARNINGS+=-Wnonnull -Wundef -# works only w/ gcc-3.4 and up, can't be checked for gcc-3.x w/ check_gcc() +# Works only w/ gcc-3.4 and up, can't be checked for gcc-3.x w/ check_gcc() #XWARNINGS+=-Wdeclaration-after-statement endif +# Seems to be unused (no ARCH_CFLAGS anywhere), delete? +# if yes, remove after 0.9.31 XARCH_CFLAGS=$(subst ",, $(strip $(ARCH_CFLAGS))) CPU_CFLAGS=$(subst ",, $(strip $(CPU_CFLAGS-y))) @@ -484,41 +531,18 @@ SSP_CFLAGS := $(SSP_DISABLE_FLAGS) endif NOSTDLIB_CFLAGS:=$(call check_gcc,-nostdlib,) -# Some nice CFLAGS to work with -# Why -funsigned-char: I hunted a bug related to incorrect -# sign extension of 'char' type for 10 hours straight. Not fun. + +# Collect all CFLAGS components CFLAGS := -include $(top_builddir)include/libc-symbols.h \ $(XWARNINGS) $(CPU_CFLAGS) $(SSP_CFLAGS) \ - -funsigned-char -fno-builtin -nostdinc -I$(top_builddir)include -I. \ + -nostdinc -I$(top_builddir)include -I. \ -I$(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH) - -# Make sure that we can be built with non-C99 compilers, too. -# Use __\1__ instead. -CFLAGS += $(call check_gcc,-fno-asm,) ifneq ($(strip $(UCLIBC_EXTRA_CFLAGS)),"") CFLAGS += $(subst ",, $(UCLIBC_EXTRA_CFLAGS)) endif -LDADD_LIBFLOAT= -ifeq ($(UCLIBC_HAS_SOFT_FLOAT),y) -# If -msoft-float isn't supported, we want an error anyway. -# Hmm... might need to revisit this for arm since it has 2 different -# soft float encodings. -ifneq ($(TARGET_ARCH),nios) -ifneq ($(TARGET_ARCH),nios2) -ifneq ($(TARGET_ARCH),sh) -CFLAGS += -msoft-float -endif -endif -endif -ifeq ($(TARGET_ARCH),arm) -# No longer needed with current toolchains, but leave it here for now. -# If anyone is actually still using gcc 2.95 (say), they can uncomment it. -# LDADD_LIBFLOAT=-lfloat -endif -endif - # Please let us see private headers' parts +# Deprecated: _LIBC serves the same purpose CFLAGS += -DUCLIBC_INTERNAL # We need this to be checked within libc-symbols.h @@ -526,8 +550,6 @@ ifneq ($(HAVE_SHARED),y) CFLAGS += -DSTATIC endif -CFLAGS += $(call check_gcc,-std=gnu99,) - LDFLAGS_NOSTRIP:=$(CPU_LDFLAGS-y) -Wl,-shared \ -Wl,--warn-common -Wl,--warn-once -Wl,-z,combreloc # binutils-2.16.1 warns about ignored sections, 2.16.91.0.3 and newer are ok @@ -638,8 +660,9 @@ endif CFLAGS += -I$(KERNEL_HEADERS) #CFLAGS += -iwithprefix include-fixed -iwithprefix include -CC_IPREFIX:=$(shell $(CC) --print-file-name=include) -CFLAGS += -I$(dir $(CC_IPREFIX))/include-fixed -I$(CC_IPREFIX) +CC_IPREFIX := $(shell $(CC) --print-file-name=include) +CC_INC := -I$(dir $(CC_IPREFIX))include-fixed -I$(CC_IPREFIX) +CFLAGS += $(CC_INC) ifneq ($(DOASSERTS),y) CFLAGS+=-DNDEBUG diff --git a/libc/misc/wchar/wchar.c b/libc/misc/wchar/wchar.c index d921e4363..1ca4600b4 100644 --- a/libc/misc/wchar/wchar.c +++ b/libc/misc/wchar/wchar.c @@ -1660,7 +1660,7 @@ int main(int argc, char **argv) if (opts[5]) { /* -l */ fprintf(stderr, "Recognized codesets:\n"); - for (s = __iconv_codesets ; *s ; s += *s) { + for (s = (char *)__iconv_codesets ; *s ; s += *s) { fprintf(stderr," %s\n", s+2); } s = __LOCALE_DATA_CODESET_LIST; diff --git a/test/Rules.mak b/test/Rules.mak index d188a9175..83d1082df 100644 --- a/test/Rules.mak +++ b/test/Rules.mak @@ -82,8 +82,9 @@ XARCH_CFLAGS := $(subst ",, $(strip $(ARCH_CFLAGS))) $(CPU_CFLAGS) XCOMMON_CFLAGS := -D_GNU_SOURCE -I$(top_builddir)test CFLAGS := $(XWARNINGS) $(OPTIMIZATION) $(XCOMMON_CFLAGS) $(XARCH_CFLAGS) -nostdinc -I$(top_builddir)$(LOCAL_INSTALL_PATH)/usr/include -CC_IPREFIX:=$(shell $(CC) --print-file-name=include) -CFLAGS += -I$(dir $(CC_IPREFIX))/include-fixed -I$(CC_IPREFIX) +CC_IPREFIX := $(shell $(CC) --print-file-name=include) +CC_INC := -I$(dir $(CC_IPREFIX))include-fixed -I$(CC_IPREFIX) +CFLAGS += $(CC_INC) HOST_CFLAGS += $(XWARNINGS) $(OPTIMIZATION) $(XCOMMON_CFLAGS) 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) |