| 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. |
| 6 | |
| 7 | # Only do this if --enable-multilib. |
| 8 | |
| 9 | if [ "${enable_multilib}" = yes ]; then |
| 10 | |
| 11 | if [ -z "${with_multisubdir}" ]; then |
| 12 | multisubdir= |
| 13 | else |
| 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 |
| 24 | rm -f ${Makefile} |
| 25 | mv Makefile.tem ${Makefile} |
| 26 | fi |
| 27 | |
| 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 |
| 32 | # a leading '/'. |
| 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. |
| 36 | # |
| 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 |
| 42 | # options). |
| 43 | |
| 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 |
| 49 | rm -f ${Makefile} |
| 50 | mv Makefile.tem ${Makefile} |
| 51 | |
| 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. |
| 54 | |
| 55 | cat > Multi.tem <<\EOF |
| 56 | |
| 57 | # FIXME: There should be an @-sign in front of the `if'. |
| 58 | # Leave out until this is tested a bit more. |
| 59 | multi-do: |
| 60 | if [ -z "$(MULTIDIRS)" ]; then \ |
| 61 | true; \ |
| 62 | else \ |
| 63 | rootpre=`pwd`/; export rootpre; \ |
| 64 | srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \ |
| 65 | compiler="$(CC)"; \ |
| 66 | for i in `$${compiler} --print-multi-lib 2>/dev/null`; do \ |
| 67 | dir=`echo $$i | sed -e 's/;.*$$//'`; \ |
| 68 | if [ "$${dir}" = "." ]; then \ |
| 69 | true; \ |
| 70 | else \ |
| 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}" \ |
| 78 | $(DO)); then \ |
| 79 | true; \ |
| 80 | else \ |
| 81 | exit 1; \ |
| 82 | fi; \ |
| 83 | else true; \ |
| 84 | fi; \ |
| 85 | fi; \ |
| 86 | done; \ |
| 87 | fi |
| 88 | |
| 89 | # FIXME: There should be an @-sign in front of the `if'. |
| 90 | # Leave out until this is tested a bit more. |
| 91 | multi-clean: |
| 92 | if [ -z "$(MULTIDIRS)" ]; then \ |
| 93 | true; \ |
| 94 | else \ |
| 95 | for dir in Makefile $(MULTIDIRS); do \ |
| 96 | if [ -f ./$$dir/Makefile ]; then \ |
| 97 | if (cd ./$$dir; $(MAKE) $(FLAGS_TO_PASS) $(DO)); \ |
| 98 | then true; \ |
| 99 | else exit 1; \ |
| 100 | fi; \ |
| 101 | else true; \ |
| 102 | fi; \ |
| 103 | done; \ |
| 104 | fi |
| 105 | EOF |
| 106 | |
| 107 | cat ${Makefile} Multi.tem > Makefile.tem |
| 108 | rm -f ${Makefile} Multi.tem |
| 109 | mv Makefile.tem ${Makefile} |
| 110 | |
| 111 | fi # "${enable_multilib}" = yes |