OSDN Git Service

test to make sure the buffers used by the gethost*_r functions handle misaligned...
[uclinux-h8/uClibc.git] / Makerules
index a35bca6..409a8de 100644 (file)
--- a/Makerules
+++ b/Makerules
@@ -2,7 +2,7 @@
 # Licensed under LGPL v2.1, see the file COPYING.LIB in this tarball for details.
 #
 
-.SUFFIXES: .c .S .o .os .oS .so .a .s .i .E
+.SUFFIXES: .c .S .o .os .oS .so .a .s .i
 
 # order is important, the stripping uses STRIP_FLAGS for lib-so, but not for lib-a
 ifeq ($(HAVE_SHARED),y)
@@ -11,12 +11,15 @@ libs: $(lib-so-y) $(lib-a-y)
 $(lib-so-y): $(interp)
 else
 .LIBPATTERNS: "lib%.a"
+ifeq ($(UCLIBC_FORMAT_SHARED_FLAT),y)
+libs: $(lib-gdb-y)
+endif
 libs: $(lib-a-y)
 endif
 objs: all_objs
 
 shared_objs =  $(ldso-y) $(libc-y:.o=.os) $(libc-shared-y) $(libc-nonshared-y) $(libdl-so-y)
-shared_objs += $(libcrypt-so-y) $(libintl-so-y) $(libm-so-y) $(libnsl-so-y) $(libpthread-so-y)
+shared_objs += $(libcrypt-so-y) $(libintl-so-y) $(libm-so-y) $(libnsl-so-y) $(libpthread-so-y) $(libpthread-nonshared-y)
 shared_objs += $(libthread_db-so-y) $(libresolv-so-y) $(librt-so-y) $(libutil-so-y)
 ar_objs =  $(libc-y) $(libc-static-y) $(libdl-a-y) $(libcrypt-a-y) $(libintl-a-y) $(libm-a-y) $(libnsl-a-y)
 ar_objs += $(libpthread-a-y) $(libthread_db-a-y) $(libresolv-a-y) $(librt-a-y) $(libutil-a-y)
@@ -92,17 +95,16 @@ disp_t_strip   = $($(DISP)_disp_t_strip)
 disp_ar        = $($(DISP)_disp_ar)
 disp_ld        = $($(DISP)_disp_ld)
 
-cmd_compile.c = $(CC) -c $< -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $(^D))) $(CFLAGS-$(subst $(top_srcdir),,$(dir $<))) $(CFLAGS-$(notdir $<)) $(CFLAGS-$(notdir $@))
-cmd_compile.S = $(cmd_compile.c) $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS-$(suffix $@)) $(ASFLAGS-$(notdir $<)) $(ASFLAGS-$(notdir $@))
+cmd_compile.c = $(CC) -c $< -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(filter-out $(CFLAGS-OMIT-$(notdir $<)),$(CFLAGS-$(notdir $(^D)))) $(CFLAGS-$(subst $(top_srcdir),,$(dir $<))) $(CFLAGS-$(notdir $<)) $(CFLAGS-$(notdir $@))
+cmd_compile.S = $(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-m = $(CC) $^ -c -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $(@D))) $(CFLAGS-$(notdir $@))
-#cmd_compile-m = $(CC) $^ -c -o $@ $(CFLAGS) $(ARCH_CFLAGS) $(CFLAGS-$(suffix $@)) $(CFLAGS-$(notdir $(@D))) $(CFLAGS-$(notdir $@)) $(CFLAGS-multi-y)
 cmd_strip     = $(STRIPTOOL) $(STRIP_FLAGS) $^
 cmd_t_strip   = $(STRIPTOOL) $(STRIP_FLAGS) $@
 cmd_ar        = $(AR) $(ARFLAGS) $@ $^
 
 compile.c = @$(disp_compile.c) ; $(cmd_compile.c)
-compile.E = $(cmd_compile.c:-c=-E)
+compile.i = $(cmd_compile.c:-c=-E -dD)
 compile.s = $(cmd_compile.c:-c=-S)
 compile.S = @$(disp_compile.S) ; $(cmd_compile.S)
 compile.m = @$(disp_compile.m) ; $(cmd_compile.m)
@@ -124,20 +126,46 @@ define link.so
        $(Q)$(INSTALL) -d $(dir $@)
        $(Q)$(RM) $@ $@.$(2) $(dir $@)$(1)
        @$(disp_ld)
-       $(Q)$(LD) $(LDFLAGS-$(notdir $@)) -soname=$(notdir $@).$(2) \
-               -o $(dir $@)$(1) $(START_FILE-$(notdir $@)) \
-               --whole-archive $(firstword $^) --no-whole-archive \
+       $(Q)$(CC) $(LDFLAGS-$(notdir $@)) -Wl,-soname=$(notdir $@).$(2) \
+               -nostdlib -o $(dir $@)$(1) $(START_FILE-$(notdir $@)) \
+               -Wl,--whole-archive $(firstword $^) -Wl,--no-whole-archive \
                $(LIBS-$(notdir $@)) $(LIBGCC) $(END_FILE-$(notdir $@))
        $(Q)$(LN) -sf $(1) $@.$(2)
        $(Q)$(LN) -sf $(1) $@
 endef
 
+# CRT files needed by link-flat.so
+LINK_FLAT_CRTS := $(top_builddir)lib/Scrt1.o $(top_builddir)lib/crti.o \
+       $(top_builddir)lib/crtn.o
+
+# Create a shared flat library from the archive named by the first dependency.
+# $@ names the shared library's .gdb file, not the flat file itself.
+# (This is because the .gdb suffix makes the ELF file more distinctive
+# than the suffixless flat file.)
+#
+# Argument 1 is the shared library file -- i.e. $(@:.gdb=) -- and argument 2
+# is the shared library identifier.  If it wasn't for $(disp_ld), we could
+# avoid passing $(@:.gdb=) as an argument and use $(@:.gdb=) instead of $(1).
+#
+# This is so far only used for libc, for which we want to link the entire
+# libgcc into the shared object.
+define link-flat.so
+       $(Q)$(INSTALL) -d $(dir $@)
+       $(Q)$(RM) $(1) $@
+       @$(disp_ld)
+       $(Q)$(CC) $(LDFLAGS-$(notdir $@)) -nostdlib -o $(1) \
+               -Wl,-elf2flt -Wl,-shared-lib-id,$(2) $(top_builddir)lib/Scrt1.o \
+               $(top_builddir)/lib/crti.o -Wl,--whole-archive $(firstword $^) \
+               $(LIBGCC) -Wl,--no-whole-archive $(LIBS-$(notdir $@)) $(LIBGCC) \
+               $(top_builddir)/lib/crtn.o
+endef
+
 define linkm.so
        $(Q)$(INSTALL) -d $(dir $@)
        $(Q)$(RM) $@ $@.$(2) $(dir $@)$(1)
        @$(disp_ld)
-       $(Q)$(LD) $(LDFLAGS-$(notdir $@)) -soname=$(notdir $@).$(2) \
-               -o $(dir $@)$(1) $(START_FILE-$(notdir $@)) $^ \
+       $(Q)$(CC) $(LDFLAGS-$(notdir $@)) -Wl,-soname=$(notdir $@).$(2) \
+               -nostdlib -o $(dir $@)$(1) $(START_FILE-$(notdir $@)) $^ \
                $(LIBS-$(notdir $@)) $(LIBGCC) $(END_FILE-$(notdir $@))
        $(Q)$(LN) -sf $(1) $@.$(2)
        $(Q)$(LN) -sf $(1) $@
@@ -155,10 +183,8 @@ CFLAGS-.oS+=$(PICFLAG) -DSHARED
 %.o:  %.s ; $(compile.S)
 %.os: %.s ; $(compile.S)
 %.oS: %.s ; $(compile.S)
-%.E:  %.c ; $(compile.E)
-%.E:  %.S ; $(compile.E)
-%.i:  %.c ; $(compile.E)
-%.i:  %.S ; $(compile.E)
+%.i:  %.c ; $(compile.i)
+%.i:  %.S ; $(compile.i)
 %.s:  %.c ; $(compile.s)
 %.s:  %.S ; $(compile.s)
 
@@ -184,7 +210,7 @@ $(headers_dep):
 
 CRT := crt1
 
-ifeq ($(HAVE_SHARED),y)
+ifeq ($(HAVE_SHARED)$(UCLIBC_FORMAT_SHARED_FLAT),y)
 CRTS=$(top_builddir)lib/$(CRT).o $(top_builddir)lib/S$(CRT).o
 else
 CRTS=$(top_builddir)lib/$(CRT).o
@@ -197,16 +223,39 @@ $(CRTS): $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/$(CRT).S
        $(compile.S)
        $(Q)$(STRIPTOOL) -x -R .note -R .comment $@
 
+ifeq ($(UCLIBC_CTOR_DTOR),y)
 CTOR_TARGETS=$(top_builddir)lib/crti.o $(top_builddir)lib/crtn.o
+else
+CTOR_TARGETS:=
+endif
 
-ifeq ($(UCLIBC_CTOR_DTOR),y)
-$(CTOR_TARGETS): $(top_builddir)lib/%.o : $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/%.S
+ifneq ($(wildcard $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/initfini.c),)
+CFLAGS-initfini.s := -S -g0 $(PICFLAG) -fno-inline-functions -finhibit-size-directive
+$(top_builddir)lib/initfini.s: $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/initfini.c
+       $(compile.c)
+
+$(top_builddir)lib/defs.h: $(top_builddir)lib/initfini.s
+       $(Q)sed -n -e '/@TESTS_BEGIN/,/@TESTS_END/p' $< | \
+               gawk -f $(top_srcdir)extra/scripts/defs.awk > $@.tmp
+       $(Q)mv $@.tmp $@
+
+$(top_builddir)lib/crti.S: $(top_builddir)lib/initfini.s $(top_builddir)lib/defs.h
+       $(Q)sed -n -e '1,/@HEADER_ENDS/p' \
+              -e '/@_.*_PROLOG_BEGINS/,/@_.*_PROLOG_ENDS/p' \
+              -e '/@TRAILER_BEGINS/,$$p' $< > $@
+
+$(top_builddir)lib/crtn.S: $(top_builddir)lib/initfini.s
+       $(Q)sed -n -e '1,/@HEADER_ENDS/p' \
+              -e '/@_.*_EPILOG_BEGINS/,/@_.*_EPILOG_ENDS/p' \
+              -e '/@TRAILER_BEGINS/,$$p' $< > $@
+
+$(CTOR_TARGETS): $(top_builddir)lib/%.o : $(top_builddir)lib/%.S
        $(Q)$(INSTALL) -d $(dir $@)
        $(compile.S) $(PICFLAG) $(SSP_DISABLE_FLAGS)
 else
-$(CTOR_TARGETS):
+$(CTOR_TARGETS): $(top_builddir)lib/%.o : $(top_srcdir)libc/sysdeps/linux/$(TARGET_ARCH)/%.S
        $(Q)$(INSTALL) -d $(dir $@)
-       $(do_ar)
+       $(compile.S) $(PICFLAG) $(SSP_DISABLE_FLAGS)
 endif
 
 #ifeq ($(TARGET_ARCH),nios)
@@ -222,6 +271,14 @@ $(CRTS) $(CTOR_TARGETS) $(CRTS_COMPAT): | headers
 
 $(top_builddir)lib/$(NONSHARED_LIBNAME): $(libc-nonshared-y)
        $(Q)$(INSTALL) -d $(dir $@)
+       $(Q)$(RM) $@
+       $(do_strip)
+       $(do_ar)
+
+$(top_builddir)lib/libpthread_nonshared.a: $(libpthread-nonshared-y)
+       $(Q)$(INSTALL) -d $(dir $@)
+       $(Q)$(RM) $@
+       $(do_strip)
        $(do_ar)
 
 .PHONY: dummy create