Commit | Line | Data |
---|---|---|
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 | ||
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. | |
55b07f57 DE |
41 | # |
42 | # ??? The variables will be undefined when they're not used | |
43 | # (eg: native libiberty) and things will work just fine, but some may argue | |
44 | # that's not clean. We can always revisit this as necessary (probably by | |
45 | # defining all the relevant vars as empty and then instead of prepending | |
46 | # corrected values we can modify them in place). | |
9eb59e0b DE |
47 | |
48 | if grep ALL_MULTI ${Makefile} >/dev/null 2>/dev/null | |
49 | then | |
50 | cat > Multi.tem <<EOF | |
51 | ALL_MULTI = all-multi | |
52 | INSTALL_MULTI = install-multi | |
53 | MOSTLYCLEAN_MULTI = mostlyclean-multi | |
54 | CLEAN_MULTI = clean-multi | |
55 | DISTCLEAN_MULTI = distclean-multi | |
56 | EOF | |
57 | ||
58 | cat Multi.tem ${Makefile} > Makefile.tem | |
59 | rm -f Multi.tem ${Makefile} | |
60 | mv Makefile.tem ${Makefile} | |
61 | ||
62 | cat > Multi.tem <<\EOF | |
63 | ||
64 | # FIXME: We use --print-multi-lib but the others don't. Standardize. | |
65 | all-multi: | |
66 | if [ -z "$(MULTIDIRS)" ]; then \ | |
67 | true; \ | |
68 | else \ | |
69 | rootpre=`pwd`/; export rootpre; \ | |
70 | srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \ | |
71 | compiler="$(CC)"; \ | |
72 | for i in `$${compiler} --print-multi-lib 2>/dev/null`; do \ | |
73 | dir=`echo $$i | sed -e 's/;.*$$//'`; \ | |
74 | if [ "$${dir}" = "." ]; then \ | |
75 | true; \ | |
76 | else \ | |
77 | if [ -d $${dir} ]; then \ | |
78 | flags=`echo $$i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`; \ | |
79 | if (cd $${dir}; $(MAKE) $(FLAGS_TO_PASS) \ | |
80 | CFLAGS="$(CFLAGS) $${flags}" \ | |
81 | CXXFLAGS="$(CXXFLAGS) $${flags}" \ | |
82 | LIBCFLAGS="$(LIBCFLAGS) $${flags}" \ | |
83 | LIBCXXFLAGS="$(LIBCXXFLAGS) $${flags}" \ | |
84 | all); then \ | |
85 | true; \ | |
86 | else \ | |
87 | exit 1; \ | |
88 | fi; \ | |
89 | else true; \ | |
90 | fi; \ | |
91 | fi; \ | |
92 | done; \ | |
93 | fi | |
94 | ||
95 | install-multi mostlyclean-multi clean-multi distclean-multi realclean-multi: | |
96 | if [ -n "$(MULTIDIRS)" ]; then \ | |
97 | rootpre=`pwd`/; export rootpre; \ | |
98 | srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \ | |
99 | $(MAKE) DO=`echo $@ | sed -e 's/-multi$$//'` DODIRS="$(MULTIDIRS)" $(FLAGS_TO_PASS) multi_subdir_do; \ | |
100 | else true; fi | |
101 | ||
102 | multi_subdir_do: | |
103 | for i in $(DODIRS); do \ | |
104 | if [ -f ./$$i/Makefile ] ; then \ | |
105 | if (cd ./$$i; $(MAKE) $(FLAGS_TO_PASS) $(DO)) ; \ | |
106 | then true ; \ | |
107 | else exit 1 ; \ | |
108 | fi ; \ | |
109 | else true; \ | |
110 | fi ; \ | |
111 | done | |
112 | EOF | |
113 | ||
114 | cat ${Makefile} Multi.tem > Makefile.tem | |
115 | rm -f ${Makefile} Multi.tem | |
116 | mv Makefile.tem ${Makefile} | |
117 | fi | |
118 | ||
119 | fi # "${enable_multilib}" = yes |