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 # The '[^/][^/]*' appears that way to work around a SunOS sed bug.
16 dotdot=`echo ${with_multisubdir} | sed -e 's:[^/][^/]*:..:g'`
17 # TOP is used by newlib and should not be used elsewhere for this purpose.
18 # MULTITOP is the proper one to use.
19 # FIXME: newlib needs to be updated to use MULTITOP so we can delete TOP.
20 # Newlib may wish to continue to use TOP for its own purposes of course.
21 sed -e "s:^TOP[ ]*=[ ]*\([./]*\)[ ]*$:TOP = ${dotdot}/\1:" \
22 -e "s:^MULTITOP[ ]*=.*$:MULTITOP = ${dotdot}:" \
23 ${Makefile} > Makefile.tem
25 mv Makefile.tem ${Makefile}
28 # MULTIDIRS is non-empty for the cpu top level Makefile (eg: newlib/Makefile)
29 # and lists the subdirectories to recurse into.
30 # MULTISUBDIR is non-empty in each cpu subdirectory's Makefile
31 # (eg: newlib/h8300h/Makefile) and is the installed subdirectory name with
33 # MULTIDO is used for targets like all, install, and check where
34 # $(FLAGS_TO_PASS) augmented with the subdir's compiler option is needed.
35 # MULTICLEAN is used for the *clean targets.
37 # ??? It is possible to merge MULTIDO and MULTICLEAN into one. They are
38 # currently kept separate because we don't want the *clean targets to require
39 # the existence of the compiler (which MULTIDO currently requires) and
40 # therefore we'd have to record the directory options as well as names
41 # (currently we just record the names and use --print-multi-lib to get the
44 sed -e "s:^MULTIDIRS[ ]*=.*$:MULTIDIRS = ${multidirs}:" \
45 -e "s:^MULTISUBDIR[ ]*=.*$:MULTISUBDIR = ${multisubdir}:" \
46 -e 's:^MULTIDO[ ]*=.*$:MULTIDO = $(MAKE):' \
47 -e 's:^MULTICLEAN[ ]*=.*$:MULTICLEAN = $(MAKE):' \
48 ${Makefile} > Makefile.tem
50 mv Makefile.tem ${Makefile}
52 # ??? May wish to add a check to avoid appending this to Makefiles that
53 # don't need it. It's not necessary, but is cleaner.
55 cat > Multi.tem <<\EOF
57 # FIXME: There should be an @-sign in front of the `if'.
58 # Leave out until this is tested a bit more.
60 if [ -z "$(MULTIDIRS)" ]; then \
63 rootpre=`pwd`/; export rootpre; \
64 srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \
66 for i in `$${compiler} --print-multi-lib 2>/dev/null`; do \
67 dir=`echo $$i | sed -e 's/;.*$$//'`; \
68 if [ "$${dir}" = "." ]; then \
71 if [ -d $${dir} ]; then \
72 flags=`echo $$i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`; \
73 if (cd $${dir}; $(MAKE) $(FLAGS_TO_PASS) \
74 CFLAGS="$(CFLAGS) $${flags}" \
75 CXXFLAGS="$(CXXFLAGS) $${flags}" \
76 LIBCFLAGS="$(LIBCFLAGS) $${flags}" \
77 LIBCXXFLAGS="$(LIBCXXFLAGS) $${flags}" \
89 # FIXME: There should be an @-sign in front of the `if'.
90 # Leave out until this is tested a bit more.
92 if [ -z "$(MULTIDIRS)" ]; then \
95 for dir in Makefile $(MULTIDIRS); do \
96 if [ -f ./$$dir/Makefile ]; then \
97 if (cd ./$$dir; $(MAKE) $(FLAGS_TO_PASS) $(DO)); \
107 cat ${Makefile} Multi.tem > Makefile.tem
108 rm -f ${Makefile} Multi.tem
109 mv Makefile.tem ${Makefile}
111 fi # "${enable_multilib}" = yes