1 # Configure fragment invoked in the post-target section for subdirs
2 # wanting multilib support.
3 # The intent is to keep as much of this in one place as possible (and out
4 # of each subdirectory, eg: newlib, libio, etc.) until the right way to do
5 # this (ha ha) is decided upon.
7 # Only do this if --enable-multilib.
9 if [ "${enable_multilib}" = yes ]; then
11 if [ -z "${with_multisubdir}" ]; then
14 multisubdir="/${with_multisubdir}"
15 dotdot=`echo ${multisubdir} | sed -e 's:/[^/]*:../:g'`
16 # TOP is used by newlib and should not be used elsewhere for this purpose.
17 sed -e "s:^TOP[ ]*=[ ]*\([./]*\)[ ]*$:TOP = ${dotdot}\1:" \
18 -e "s:^MULTITOP[ ]*=[ ]*\([./]*\)[ ]*$:MULTITOP = ${dotdot}\1:" \
19 ${Makefile} > Makefile.tem
21 mv Makefile.tem ${Makefile}
24 # MULTIDIRS is non-empty for the cpu top level Makefile (eg: newlib/Makefile)
25 # and lists the subdirectories to recurse into.
26 # MULTISUBDIR is non-empty in each cpu subdirectory's Makefile
27 # (eg: newlib/h8300h/Makefile) and is the installed subdirectory name with
29 # MULTIDO is used for targets like all, install, and check where
30 # $(FLAGS_TO_PASS) augmented with the subdir's compiler option is needed.
31 # MULTICLEAN is used for the *clean targets.
33 # ??? It is possible to merge MULTIDO and MULTICLEAN into one. They are
34 # currently kept separate because we don't want the *clean targets to require
35 # the existence of the compiler (which MULTIDO currently requires) and
36 # therefore we'd have to record the directory options as well as names
37 # (currently we just record the names and use --print-multi-lib to get the
40 sed -e "s:^MULTIDIRS[ ]*=.*$:MULTIDIRS = ${multidirs}:" \
41 -e "s:^MULTISUBDIR[ ]*=.*$:MULTISUBDIR = ${multisubdir}:" \
42 -e 's:^MULTIDO[ ]*=.*$:MULTIDO = $(MAKE):' \
43 -e 's:^MULTICLEAN[ ]*=.*$:MULTICLEAN = $(MAKE):' \
44 ${Makefile} > Makefile.tem
46 mv Makefile.tem ${Makefile}
48 # ??? May wish to add a check to avoid appending this to Makefiles that
49 # don't need it. It's not necessary, but is cleaner.
51 cat > Multi.tem <<\EOF
53 # FIXME: There should be an @-sign in front of the `if'.
54 # Leave out until this is tested a bit more.
56 if [ -z "$(MULTIDIRS)" ]; then \
59 rootpre=`pwd`/; export rootpre; \
60 srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \
62 for i in `$${compiler} --print-multi-lib 2>/dev/null`; do \
63 dir=`echo $$i | sed -e 's/;.*$$//'`; \
64 if [ "$${dir}" = "." ]; then \
67 if [ -d $${dir} ]; then \
68 flags=`echo $$i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`; \
69 if (cd $${dir}; $(MAKE) $(FLAGS_TO_PASS) \
70 CFLAGS="$(CFLAGS) $${flags}" \
71 CXXFLAGS="$(CXXFLAGS) $${flags}" \
72 LIBCFLAGS="$(LIBCFLAGS) $${flags}" \
73 LIBCXXFLAGS="$(LIBCXXFLAGS) $${flags}" \
85 # FIXME: There should be an @-sign in front of the `if'.
86 # Leave out until this is tested a bit more.
88 if [ -z "$(MULTIDIRS)" ]; then \
91 for dir in Makefile $(MULTIDIRS); do \
92 if [ -f ./$$dir/Makefile ]; then \
93 if (cd ./$$dir; $(MAKE) $(FLAGS_TO_PASS) $(DO)); \
103 cat ${Makefile} Multi.tem > Makefile.tem
104 rm -f ${Makefile} Multi.tem
105 mv Makefile.tem ${Makefile}
107 fi # "${enable_multilib}" = yes