c0798a38c35ff7c6821d581e76e4c8dae0abd647
[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 # FIXME: following line needs testing in multilevel dir (eg: m68k).
16 dotdot=`echo ${multisubdir} | sed -e 's:/[^/]*:../:g'`
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. MULTISUBDIR is non-empty in
26 # each cpu subdirectory's Makefile (eg: newlib/h8300h/Makefile) and is the
27 # installed subdirectory name with a trailing '/'.
28 # XXX_MULTI is a set of helpers for all, install, etc.
29 # Makefile.in is free to override them since these are prepended to the top.
30
31 cat > Multi.tem <<EOF
32 MULTIDIRS = ${multidirs}
33 MULTISUBDIR = ${multisubdir}
34 EOF
35 cat Multi.tem ${Makefile} > Makefile.tem
36 rm -f Multi.tem ${Makefile}
37 mv Makefile.tem ${Makefile}
38
39 # Add default definitions for all, install, clean, etc.
40 # if the Makefile uses them.
41
42 if grep ALL_MULTI ${Makefile} >/dev/null 2>/dev/null
43 then
44 cat > Multi.tem <<EOF
45 ALL_MULTI = all-multi
46 INSTALL_MULTI = install-multi
47 MOSTLYCLEAN_MULTI = mostlyclean-multi
48 CLEAN_MULTI = clean-multi
49 DISTCLEAN_MULTI = distclean-multi
50 EOF
51
52 cat Multi.tem ${Makefile} > Makefile.tem
53 rm -f Multi.tem ${Makefile}
54 mv Makefile.tem ${Makefile}
55
56 cat > Multi.tem <<\EOF
57
58 # FIXME: We use --print-multi-lib but the others don't. Standardize.
59 all-multi:
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 all); then \
79 true; \
80 else \
81 exit 1; \
82 fi; \
83 else true; \
84 fi; \
85 fi; \
86 done; \
87 fi
88
89 install-multi mostlyclean-multi clean-multi distclean-multi realclean-multi:
90 if [ -n "$(MULTIDIRS)" ]; then \
91 rootpre=`pwd`/; export rootpre; \
92 srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \
93 $(MAKE) DO=`echo $@ | sed -e 's/-multi$$//'` DODIRS="$(MULTIDIRS)" $(FLAGS_TO_PASS) multi_subdir_do; \
94 else true; fi
95
96 multi_subdir_do:
97 for i in $(DODIRS); do \
98 if [ -f ./$$i/Makefile ] ; then \
99 if (cd ./$$i; $(MAKE) $(FLAGS_TO_PASS) $(DO)) ; \
100 then true ; \
101 else exit 1 ; \
102 fi ; \
103 else true; \
104 fi ; \
105 done
106 EOF
107
108 cat ${Makefile} Multi.tem > Makefile.tem
109 rm -f ${Makefile} Multi.tem
110 mv Makefile.tem ${Makefile}
111 fi
112
113 fi # "${enable_multilib}" = yes
This page took 0.115193 seconds and 3 git commands to generate.