* cfg-ml-pos.in (MULTITOP): Trim excess trailing "/.".
[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 ${with_multisubdir} | sed -e 's:[^/]*:..:g'`
16 # TOP is used by newlib and should not be used elsewhere for this purpose.
17 # MULTITOP is the proper one to use.
18 # FIXME: newlib needs to be updated to use MULTITOP so we can delete TOP.
19 # Newlib may wish to continue to use TOP for its own purposes of course.
20 sed -e "s:^TOP[ ]*=[ ]*\([./]*\)[ ]*$:TOP = ${dotdot}/\1:" \
21 -e "s:^MULTITOP[ ]*=.*$:MULTITOP = ${dotdot}:" \
22 ${Makefile} > Makefile.tem
23 rm -f ${Makefile}
24 mv Makefile.tem ${Makefile}
25 fi
26
27 # MULTIDIRS is non-empty for the cpu top level Makefile (eg: newlib/Makefile)
28 # and lists the subdirectories to recurse into.
29 # MULTISUBDIR is non-empty in each cpu subdirectory's Makefile
30 # (eg: newlib/h8300h/Makefile) and is the installed subdirectory name with
31 # a leading '/'.
32 # MULTIDO is used for targets like all, install, and check where
33 # $(FLAGS_TO_PASS) augmented with the subdir's compiler option is needed.
34 # MULTICLEAN is used for the *clean targets.
35 #
36 # ??? It is possible to merge MULTIDO and MULTICLEAN into one. They are
37 # currently kept separate because we don't want the *clean targets to require
38 # the existence of the compiler (which MULTIDO currently requires) and
39 # therefore we'd have to record the directory options as well as names
40 # (currently we just record the names and use --print-multi-lib to get the
41 # options).
42
43 sed -e "s:^MULTIDIRS[ ]*=.*$:MULTIDIRS = ${multidirs}:" \
44 -e "s:^MULTISUBDIR[ ]*=.*$:MULTISUBDIR = ${multisubdir}:" \
45 -e 's:^MULTIDO[ ]*=.*$:MULTIDO = $(MAKE):' \
46 -e 's:^MULTICLEAN[ ]*=.*$:MULTICLEAN = $(MAKE):' \
47 ${Makefile} > Makefile.tem
48 rm -f ${Makefile}
49 mv Makefile.tem ${Makefile}
50
51 # ??? May wish to add a check to avoid appending this to Makefiles that
52 # don't need it. It's not necessary, but is cleaner.
53
54 cat > Multi.tem <<\EOF
55
56 # FIXME: There should be an @-sign in front of the `if'.
57 # Leave out until this is tested a bit more.
58 multi-do:
59 if [ -z "$(MULTIDIRS)" ]; then \
60 true; \
61 else \
62 rootpre=`pwd`/; export rootpre; \
63 srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \
64 compiler="$(CC)"; \
65 for i in `$${compiler} --print-multi-lib 2>/dev/null`; do \
66 dir=`echo $$i | sed -e 's/;.*$$//'`; \
67 if [ "$${dir}" = "." ]; then \
68 true; \
69 else \
70 if [ -d $${dir} ]; then \
71 flags=`echo $$i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`; \
72 if (cd $${dir}; $(MAKE) $(FLAGS_TO_PASS) \
73 CFLAGS="$(CFLAGS) $${flags}" \
74 CXXFLAGS="$(CXXFLAGS) $${flags}" \
75 LIBCFLAGS="$(LIBCFLAGS) $${flags}" \
76 LIBCXXFLAGS="$(LIBCXXFLAGS) $${flags}" \
77 $(DO)); then \
78 true; \
79 else \
80 exit 1; \
81 fi; \
82 else true; \
83 fi; \
84 fi; \
85 done; \
86 fi
87
88 # FIXME: There should be an @-sign in front of the `if'.
89 # Leave out until this is tested a bit more.
90 multi-clean:
91 if [ -z "$(MULTIDIRS)" ]; then \
92 true; \
93 else \
94 for dir in Makefile $(MULTIDIRS); do \
95 if [ -f ./$$dir/Makefile ]; then \
96 if (cd ./$$dir; $(MAKE) $(FLAGS_TO_PASS) $(DO)); \
97 then true; \
98 else exit 1; \
99 fi; \
100 else true; \
101 fi; \
102 done; \
103 fi
104 EOF
105
106 cat ${Makefile} Multi.tem > Makefile.tem
107 rm -f ${Makefile} Multi.tem
108 mv Makefile.tem ${Makefile}
109
110 fi # "${enable_multilib}" = yes
This page took 0.031938 seconds and 4 git commands to generate.