Fix libgloss/newlib build to conditionally use top include dir

- conditionally use -idirafter option for arm
This commit is contained in:
Jeff Johnston 2023-02-09 16:59:31 -05:00
parent 97d483c2f8
commit 17ac400c11
8 changed files with 67 additions and 3 deletions

View File

@ -24,7 +24,11 @@ includetool_DATA =
includesystooldir = $(tooldir)/include/sys
includesystool_DATA =
if NEED_TOP_INCLUDE_DIR
AM_CPPFLAGS = -idirafter $(srcroot)/include
else
AM_CPPFLAGS =
endif
# A fake library so automake will generate rules for plain objects that we want
# to install (e.g. our crt0.o objects).

View File

@ -807,7 +807,8 @@ includetooldir = $(tooldir)/include
includetool_DATA = $(am__append_16)
includesystooldir = $(tooldir)/include/sys
includesystool_DATA = $(am__append_17)
AM_CPPFLAGS = -idirafter $(srcroot)/include
@NEED_TOP_INCLUDE_DIR_FALSE@AM_CPPFLAGS =
@NEED_TOP_INCLUDE_DIR_TRUE@AM_CPPFLAGS = -idirafter $(srcroot)/include
# A fake library so automake will generate rules for plain objects that we want
# to install (e.g. our crt0.o objects).

34
libgloss/config/arm.mh Normal file
View File

@ -0,0 +1,34 @@
NEWLIB_CFLAGS = `if [ -d ${objroot}/newlib ]; then echo -I${objroot}/newlib/targ-include -I${srcroot}/newlib/libc/include; fi`
NEWLIB_LDFLAGS = `if [ -d ${objroot}/newlib ]; then echo -B${objroot}/newlib/ -L${objroot}/newlib/; fi`
INCLUDES = -I. -I$(srcdir)/.. -I$(objdir)/.. -idirafter $(srcroot)/include
# Note that when building the library, ${MULTILIB} is not the way multilib
# options are passed; they're passed in $(CFLAGS).
CFLAGS_FOR_TARGET = -O2 -g ${MULTILIB} ${INCLUDES} ${NEWLIB_CFLAGS}
LDFLAGS_FOR_TARGET = ${MULTILIB} ${NEWLIB_LDFLAGS}
AR_FLAGS = rc
.c.o:
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $<
.C.o:
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $<
.s.o:
$(AS) $(ASFLAGS_FOR_TARGET) $(INCLUDES) $(ASFLAGS) -o $*.o $<
#
# GCC knows to run the preprocessor on .S files before it assembles them.
#
.S.o:
$(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) $(CFLAGS) -c $<
#
# this is a bogus target that'll produce an assembler from the
# C source with the right compiler options. this is so we can
# track down code generation or debug symbol bugs.
#
.c.s:
$(CC) $(CFLAGS_FOR_TARGET) -S $(INCLUDES) $(CFLAGS) $<
# We don't build docs in subdirs, so stub out the rules.
.PHONY: doc docs dvi html install-html info install-info clean-info pdf install-pdf

View File

@ -1,7 +1,7 @@
NEWLIB_CFLAGS = `if [ -d ${objroot}/newlib ]; then echo -I${objroot}/newlib/targ-include -I${srcroot}/newlib/libc/include; fi`
NEWLIB_LDFLAGS = `if [ -d ${objroot}/newlib ]; then echo -B${objroot}/newlib/ -L${objroot}/newlib/; fi`
INCLUDES = -I. -I$(srcdir)/.. -I$(objdir)/.. -idirafter $(srcroot)/include
INCLUDES = -I. -I$(srcdir)/.. -I$(objdir)/..
# Note that when building the library, ${MULTILIB} is not the way multilib
# options are passed; they're passed in $(CFLAGS).
CFLAGS_FOR_TARGET = -O2 -g ${MULTILIB} ${INCLUDES} ${NEWLIB_CFLAGS}

16
libgloss/configure vendored
View File

@ -630,6 +630,8 @@ CPPFLAGS
LDFLAGS
CFLAGS
CC
NEED_TOP_INCLUDE_DIR_FALSE
NEED_TOP_INCLUDE_DIR_TRUE
CONFIG_WINCE_FALSE
CONFIG_WINCE_TRUE
CONFIG_RISCV_FALSE
@ -2949,6 +2951,7 @@ case "${target}" in
;;
arm*-*-elf | arm*-*-coff | arm*-*-*)
config_arm=true
host_makefile_frag=${srcdir}/config/arm.mh
;;
spu-*-elf)
ac_config_files="$ac_config_files spu/Makefile"
@ -3081,6 +3084,15 @@ fi
if test x$config_arm = xtrue; then
NEED_TOP_INCLUDE_DIR_TRUE=
NEED_TOP_INCLUDE_DIR_FALSE='#'
else
NEED_TOP_INCLUDE_DIR_TRUE='#'
NEED_TOP_INCLUDE_DIR_FALSE=
fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
@ -5347,6 +5359,10 @@ if test -z "${CONFIG_WINCE_TRUE}" && test -z "${CONFIG_WINCE_FALSE}"; then
as_fn_error $? "conditional \"CONFIG_WINCE\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${NEED_TOP_INCLUDE_DIR_TRUE}" && test -z "${NEED_TOP_INCLUDE_DIR_FALSE}"; then
as_fn_error $? "conditional \"NEED_TOP_INCLUDE_DIR\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
as_fn_error $? "conditional \"AMDEP\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5

View File

@ -214,6 +214,7 @@ case "${target}" in
;;
arm*-*-elf | arm*-*-coff | arm*-*-*)
config_arm=true
host_makefile_frag=${srcdir}/config/arm.mh
;;
spu-*-elf)
AC_CONFIG_FILES([spu/Makefile])
@ -252,6 +253,9 @@ m4_foreach_w([SUBDIR], [
AM_CONDITIONAL([CONFIG_]m4_toupper(SUBDIR), [test x$config_]SUBDIR = xtrue)
])
dnl arm platforms have a special header file found in the main include directory
AM_CONDITIONAL([NEED_TOP_INCLUDE_DIR], [[test x$config_arm] = xtrue])
dnl For now, don't bother configuring testsuite
dnl
dnl if test "${config_testsuite}" = "true";

View File

@ -70,7 +70,11 @@ toollibdir = $(tooldir)/lib$(MULTISUBDIR)
# These are useful for standalone object files like crt0.o.
AM_CFLAGS = $(AM_CFLAGS_$(subst /,_,$(@D))) $(AM_CFLAGS_$(subst /,_,$(@D)_$(<F)))
AM_CCASFLAGS = $(AM_CCASFLAGS_$(subst /,_,$(@D))) $(AM_CCASFLAGS_$(subst /,_,$(@D)_$(<F)))
if HAVE_LIBC_MACHINE_ARM
AM_CPPFLAGS = $(NEWLIB_CFLAGS) $(TARGET_CFLAGS) $(AM_CPPFLAGS_$(subst /,_,$(@D))) $(AM_CPPFLAGS_$(subst /,_,$(@D)_$(<F))) -idirafter $(srcroot)/include
else
AM_CPPFLAGS = $(NEWLIB_CFLAGS) $(TARGET_CFLAGS) $(AM_CPPFLAGS_$(subst /,_,$(@D))) $(AM_CPPFLAGS_$(subst /,_,$(@D)_$(<F)))
endif
toollib_LIBRARIES = libm.a \
libc.a

View File

@ -3848,7 +3848,8 @@ toollibdir = $(tooldir)/lib$(MULTISUBDIR)
# These are useful for standalone object files like crt0.o.
AM_CFLAGS = $(AM_CFLAGS_$(subst /,_,$(@D))) $(AM_CFLAGS_$(subst /,_,$(@D)_$(<F)))
AM_CCASFLAGS = $(AM_CCASFLAGS_$(subst /,_,$(@D))) $(AM_CCASFLAGS_$(subst /,_,$(@D)_$(<F)))
AM_CPPFLAGS = $(NEWLIB_CFLAGS) $(TARGET_CFLAGS) $(AM_CPPFLAGS_$(subst /,_,$(@D))) $(AM_CPPFLAGS_$(subst /,_,$(@D)_$(<F))) -idirafter $(srcroot)/include
@HAVE_LIBC_MACHINE_ARM_FALSE@AM_CPPFLAGS = $(NEWLIB_CFLAGS) $(TARGET_CFLAGS) $(AM_CPPFLAGS_$(subst /,_,$(@D))) $(AM_CPPFLAGS_$(subst /,_,$(@D)_$(<F)))
@HAVE_LIBC_MACHINE_ARM_TRUE@AM_CPPFLAGS = $(NEWLIB_CFLAGS) $(TARGET_CFLAGS) $(AM_CPPFLAGS_$(subst /,_,$(@D))) $(AM_CPPFLAGS_$(subst /,_,$(@D)_$(<F))) -idirafter $(srcroot)/include
toollib_LIBRARIES = libm.a libc.a $(am__append_72)
@HAVE_MULTISUBDIR_TRUE@BUILD_MULTISUBDIR = $(builddir)$(MULTISUBDIR)
toollib_DATA = $(CRT0) $(CRT1)