Rewrite so Makefiles do not reference undefined variables.
[deliverable/binutils-gdb.git] / cfg-ml-pos.in
CommitLineData
9eb59e0b
DE
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
9if [ "${enable_multilib}" = yes ]; then
10
11if [ -z "${with_multisubdir}" ]; then
12 multisubdir=
13else
14 multisubdir="/${with_multisubdir}"
9eb59e0b 15 dotdot=`echo ${multisubdir} | sed -e 's:/[^/]*:../:g'`
549b77a9 16 # TOP is used by newlib and should not be used elsewhere for this purpose.
9eb59e0b
DE
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}
22fi
23
24# MULTIDIRS is non-empty for the cpu top level Makefile (eg: newlib/Makefile)
549b77a9
DE
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.
55b07f57 32#
549b77a9
DE
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).
9eb59e0b 39
549b77a9
DE
40sed -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
45rm -f ${Makefile}
46mv Makefile.tem ${Makefile}
9eb59e0b 47
549b77a9 48cat > Multi.tem <<\EOF
9eb59e0b 49
549b77a9 50multi-do:
9eb59e0b
DE
51 if [ -z "$(MULTIDIRS)" ]; then \
52 true; \
53 else \
54 rootpre=`pwd`/; export rootpre; \
55 srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \
56 compiler="$(CC)"; \
57 for i in `$${compiler} --print-multi-lib 2>/dev/null`; do \
58 dir=`echo $$i | sed -e 's/;.*$$//'`; \
59 if [ "$${dir}" = "." ]; then \
60 true; \
61 else \
62 if [ -d $${dir} ]; then \
63 flags=`echo $$i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`; \
64 if (cd $${dir}; $(MAKE) $(FLAGS_TO_PASS) \
65 CFLAGS="$(CFLAGS) $${flags}" \
66 CXXFLAGS="$(CXXFLAGS) $${flags}" \
67 LIBCFLAGS="$(LIBCFLAGS) $${flags}" \
68 LIBCXXFLAGS="$(LIBCXXFLAGS) $${flags}" \
549b77a9 69 $(DO)); then \
9eb59e0b
DE
70 true; \
71 else \
72 exit 1; \
73 fi; \
74 else true; \
75 fi; \
76 fi; \
77 done; \
78 fi
79
549b77a9
DE
80multi-clean:
81 if [ -z "$(MULTIDIRS)" ]; then \
82 true; \
83 else \
84 for dir in Makefile $(MULTIDIRS); do \
85 if [ -f ./$$dir/Makefile ]; then \
86 if (cd ./$$dir; $(MAKE) $(FLAGS_TO_PASS) $(DO)); \
87 then true; \
88 else exit 1; \
89 fi; \
90 else true; \
91 fi; \
92 done; \
93 fi
9eb59e0b
DE
94EOF
95
549b77a9
DE
96cat ${Makefile} Multi.tem > Makefile.tem
97rm -f ${Makefile} Multi.tem
98mv Makefile.tem ${Makefile}
9eb59e0b
DE
99
100fi # "${enable_multilib}" = yes
This page took 0.036332 seconds and 4 git commands to generate.