(multi-do, multi-clean): Add comment regarding @-signs.
[deliverable/binutils-gdb.git] / cfg-ml-pos.in
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 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
20 rm -f ${Makefile}
21 mv Makefile.tem ${Makefile}
22 fi
23
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
28 # a trailing '/'.
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.
32 #
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
38 # options).
39
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
45 rm -f ${Makefile}
46 mv Makefile.tem ${Makefile}
47
48 cat > Multi.tem <<\EOF
49
50 # FIXME: There should be an @-sign in front of the `if'.
51 # Leave out until this is tested a bit more.
52 multi-do:
53 if [ -z "$(MULTIDIRS)" ]; then \
54 true; \
55 else \
56 rootpre=`pwd`/; export rootpre; \
57 srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \
58 compiler="$(CC)"; \
59 for i in `$${compiler} --print-multi-lib 2>/dev/null`; do \
60 dir=`echo $$i | sed -e 's/;.*$$//'`; \
61 if [ "$${dir}" = "." ]; then \
62 true; \
63 else \
64 if [ -d $${dir} ]; then \
65 flags=`echo $$i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`; \
66 if (cd $${dir}; $(MAKE) $(FLAGS_TO_PASS) \
67 CFLAGS="$(CFLAGS) $${flags}" \
68 CXXFLAGS="$(CXXFLAGS) $${flags}" \
69 LIBCFLAGS="$(LIBCFLAGS) $${flags}" \
70 LIBCXXFLAGS="$(LIBCXXFLAGS) $${flags}" \
71 $(DO)); then \
72 true; \
73 else \
74 exit 1; \
75 fi; \
76 else true; \
77 fi; \
78 fi; \
79 done; \
80 fi
81
82 # FIXME: There should be an @-sign in front of the `if'.
83 # Leave out until this is tested a bit more.
84 multi-clean:
85 if [ -z "$(MULTIDIRS)" ]; then \
86 true; \
87 else \
88 for dir in Makefile $(MULTIDIRS); do \
89 if [ -f ./$$dir/Makefile ]; then \
90 if (cd ./$$dir; $(MAKE) $(FLAGS_TO_PASS) $(DO)); \
91 then true; \
92 else exit 1; \
93 fi; \
94 else true; \
95 fi; \
96 done; \
97 fi
98 EOF
99
100 cat ${Makefile} Multi.tem > Makefile.tem
101 rm -f ${Makefile} Multi.tem
102 mv Makefile.tem ${Makefile}
103
104 fi # "${enable_multilib}" = yes
This page took 0.033467 seconds and 5 git commands to generate.