pkgin_all: script to auto-install all packages
[minix.git] / tools / gcc / Makefile
blob63d829b65d234e0f58a22e28bc540cde684792d1
1 # $NetBSD: Makefile,v 1.52 2012/09/18 07:05:15 skrll Exp $
3 .include <bsd.own.mk>
5 .ifdef __MINIX
6 HAVE_GCC= 45
8 GCC_LANGUAGES=c
9 .else
10 GCC_LANGUAGES=c c++ objc
11 .endif
12 MODULE= gcc4
14 MKNATIVE_CONFIG_TARGET_LIBS= \
15 configure-target-libstdc++-v3 \
16 configure-target-libobjc
18 .if ${HAVE_GCC} == 45
19 MKNATIVE_TARGET= gcc45
20 GNUHOSTDIST= ${.CURDIR}/../../external/gpl3/gcc/dist
21 MKNATIVE_CONFIG_TARGET_LIBS+= \
22 configure-target-libgomp
23 .else
24 MKNATIVE_TARGET= gcc4
25 .endif
27 BINENV= /usr/bin/env -i
29 VAX_CONFIGURE_ARGS=
31 .if ${MACHINE_ARCH} == "x86_64" || ${MACHINE_ARCH} == "sparc64"
32 MULTILIB_ARGS= --enable-multilib
33 .else
34 MULTILIB_ARGS= --disable-multilib
35 .endif
37 .if ${MKSOFTFLOAT} != "no"
38 SOFTFLOAT_ARGS= -with-float=soft
39 .endif
41 # LSC FIXME We are not using the correct target ATM, so overrides for now...
42 COMMON_CONFIGURE_ARGS= --target=${MACHINE_GNU_PLATFORM} \
43 --disable-libssp \
44 --disable-threads \
45 --disable-visibility \
46 --disable-libunwind \
47 --enable-long-long \
48 --enable-threads \
49 --with-bugurl=http://www.NetBSD.org/Misc/send-pr.html \
50 --with-pkgversion="NetBSD nb1 20120916" \
51 --with-system-zlib \
52 ${VAX_CONFIGURE_ARGS} \
53 --enable-__cxa_atexit
54 .if defined(GCC_CONFIG_ARCH.${MACHINE_ARCH})
55 COMMON_CONFIGURE_ARGS+= --with-arch=${GCC_CONFIG_ARCH.${MACHINE_ARCH}}
56 .endif
57 .if defined(GCC_CONFIG_TUNE.${MACHINE_ARCH})
58 COMMON_CONFIGURE_ARGS+= --with-tune=${GCC_CONFIG_TUNE.${MACHINE_ARCH}}
59 .endif
61 CONFIGURE_ARGS= ${COMMON_CONFIGURE_ARGS}
62 .if ${HAVE_GCC} >= 45
63 CONFIGURE_ARGS+= \
64 --with-mpc=${TOOLDIR} \
65 --with-mpfr=${TOOLDIR} \
66 --with-gmp=${TOOLDIR}
67 .endif
68 CONFIGURE_ARGS+= \
69 --disable-nls \
70 ${MULTILIB_ARGS} \
71 ${SOFTFLOAT_ARGS} \
72 --program-transform-name="s,^,${MACHINE_GNU_PLATFORM}-," \
73 --enable-languages="${GCC_LANGUAGES}"
75 GCC_CPPFLAGS= -DNETBSD_TOOLS -DTARGET_SYSTEM_ROOT=0 \
76 -DTARGET_SYSTEM_ROOT_RELOCATABLE
78 .if ${HOST_OSTYPE:C/\-.*//} == "Minix"
79 GCC_CPPFLAGS+= -D_NETBSD_SOURCE -D_POSIX_SOURCE -D_COMPAT_MINIX
80 CONFIGURE_ENV+= LDFLAGS=-lm
81 .endif
83 MAKE_ARGS= MACHINE= MAKEINFO=${TOOL_MAKEINFO:Q} \
84 LIBGCC= LIBGCC1= LIBGCC1_TEST= LIBGCC2= INSTALL_LIBGCC= \
85 EXTRA_PARTS= CPPFLAGS=${GCC_CPPFLAGS:Q} \
86 AR=${HOST_AR:Q} RANLIB=${HOST_RANLIB:Q}
88 CONFIGURE_ENV+= gcc_cv_libc_provides_ssp=yes \
89 gcc_cv_as_sparc_gotdata_op=no
91 MKNATIVE_ENV= ${BINENV} ${CONFIGURE_ENV:NC*:NLD*} \
92 CC_FOR_BUILD=${HOST_CC:Q} \
93 CC=${CC:Q}' '${CCADDFLAGS:Q} \
94 CXX=${CXX:Q}' '${CCADDFLAGS:Q}' '${CXXADDFLAGS:Q} \
95 CPP=${CPP:Q}' '-I${DESTDIR}/usr/include \
96 CFLAGS= CPPFLAGS= CXXFLAGS= LDFLAGS= \
97 AS=${AS:Q} AWK=${TOOL_AWK:Q} LD=${LD:Q} \
98 MSGFMT=${TOOLDIR}/bin/${_TOOL_PREFIX}msgfmt \
99 NM=${NM:Q} OBJDUMP=${OBJDUMP:Q} \
100 XGETTEXT=${TOOLDIR}/bin/${_TOOL_PREFIX}xgettext \
101 LIBS=-lintl \
102 ac_cv_prog_cc_cross=yes \
103 ac_cv_func_strcoll_works=yes \
104 ac_cv_func_elf_getshstrndx=no \
105 gcc_cv_func_printf_ptr=yes \
106 gcc_cv_libc_provides_ssp=yes \
107 gdb_cv_printf_has_long_double=yes \
108 gdb_cv_printf_has_long_long=yes \
109 gdb_cv_scanf_has_long_double=yes \
110 gcc_cv_as_sparc_gotdata_op=no
112 ALL_TARGET= all-gcc
113 INSTALL_TARGET= install-gcc
115 .include "${.CURDIR}/../Makefile.gmakehost"
116 BUILD_MAKE=${TOOL_GMAKE}
119 # mknative-gcc specific stuff
122 .if ${HAVE_GCC} < 45
123 GCCSRCDIR=${.CURDIR}/../../gnu/dist/gcc4
124 .else
125 GCCSRCDIR=${.CURDIR}/../../external/gpl3/gcc/dist
126 .endif
128 CXXADDFLAGS= --sysroot=${DESTDIR}
129 CCADDFLAGS= --sysroot=${DESTDIR} -L${DESTDIR}/lib -L${DESTDIR}/usr/lib -B${DESTDIR}/usr/lib/ -I${.OBJDIR}/.native/gcc/include
131 NEWCONFIGDIR?= ${.CURDIR}/../..
132 MKNATIVE?= ${.CURDIR}/mknative-gcc
134 bootstrap-libgcc: .configure_done
135 @echo 'Creating files needed for libgcc by a native bootstrap build.'
136 @MAKE=${BUILD_MAKE:Q} ${HOST_SH} ${MKNATIVE} lib${MKNATIVE_TARGET} \
137 ${.OBJDIR}/build ${NEWCONFIGDIR} ${MACHINE_GNU_PLATFORM} \
138 ${DESTDIR}
140 native-gcc: .native/.configure_done
141 @echo 'Extracting GNU GCC configury for a native toolchain.'
142 @MAKE=${BUILD_MAKE:Q} ${HOST_SH} ${MKNATIVE} ${MKNATIVE_TARGET} \
143 ${.OBJDIR}/.native ${NEWCONFIGDIR} ${MACHINE_GNU_PLATFORM} \
144 ${DESTDIR}
146 NATIVE_CONFIGURE_ARGS= ${COMMON_CONFIGURE_ARGS}
147 .if ${HAVE_GCC} >= 45
148 NATIVE_CONFIGURE_ARGS+= \
149 --with-mpc=${DESTDIR}/usr \
150 --with-mpfr=${DESTDIR}/usr \
151 --with-gmp=${DESTDIR}/usr
153 . if ${MACHINE_ARCH} != "vax"
154 NATIVE_CONFIGURE_ARGS+= --enable-tls
155 . endif
156 .endif
157 NATIVE_CONFIGURE_ARGS+= \
158 --disable-multilib \
159 --disable-symvers \
160 --disable-libstdcxx-pch \
161 --build=`${GCCSRCDIR}/config.guess` \
162 --host=${MACHINE_GNU_PLATFORM}
164 .native/.configure_done: ${_GNU_CFGSRC} ${.CURDIR}/Makefile
165 mkdir .native 2>/dev/null || true
166 PATH=${TOOLDIR}/bin:$$PATH; export PATH; \
167 (cd .native && ${MKNATIVE_ENV} \
168 ${HOST_SH} ${GNUHOSTDIST}/configure \
169 ${NATIVE_CONFIGURE_ARGS}) && \
170 (cd .native && ${MKNATIVE_ENV} ${BUILD_MAKE} all-build-libiberty)
171 PATH=${TOOLDIR}/bin:$$PATH; export PATH; \
172 (cd .native && ${MKNATIVE_ENV} ${BUILD_MAKE} configure-gcc configure-libcpp) && \
173 (cd .native && ${MKNATIVE_ENV} ${BUILD_MAKE} configure-libiberty) && \
174 (cd .native && ${MKNATIVE_ENV} ${BUILD_MAKE} configure-libdecnumber)
175 # edit Makefile so that maybe-all-gcc does not depend on all-gcc any more.
176 (cd .native && mv Makefile Makefile.config && \
177 ${TOOL_SED} -e 's/\(maybe-all-gcc:\) all-gcc/\1/' \
178 -e 's/\(maybe-all-target-libgcc:\) all-target-libgcc/\1/' \
179 < Makefile.config > Makefile)
180 PATH=${TOOLDIR}/bin:$$PATH; export PATH; \
181 (cd .native/gcc && ${MKNATIVE_ENV} ${BUILD_MAKE} -e tree-check.h config.h multilib.h gcov-iov.h)
182 PATH=${TOOLDIR}/bin:$$PATH; export PATH; \
183 (cd .native/gcc && ${MKNATIVE_ENV} ${BUILD_MAKE} -e libgcc.mvars tconfig.h unwind.h)
184 (cd .native && touch gcc/cc1obj gcc/cc1plus gcc/f771 gcc/libgcc.a gcc/libgcc_s.so)
185 .for _lib in ${MKNATIVE_CONFIG_TARGET_LIBS}
186 PATH=${TOOLDIR}/bin:$$PATH; export PATH; \
187 (cd .native && ${MKNATIVE_ENV} ${BUILD_MAKE} \
188 ${_lib} \
189 ALL_GCC_C= ALL_GCC_CXX= \
190 CC_FOR_TARGET=${CC:Q}' '${CCADDFLAGS:Q} \
191 CXX_FOR_TARGET=${CXX:Q}' '${CCADDFLAGS:Q}' '${CXXADDFLAGS:Q} \
192 RAW_CXX_FOR_TARGET=${CXX:Q}' '${CCADDFLAGS:Q}' '${CXXADDFLAGS:Q} \
193 CPP=${CPP:Q}' '-I${DESTDIR}/usr/include \
194 ac_cv_prog_cc_cross=yes) && \
195 true
196 .endfor
197 PATH=${TOOLDIR}/bin:$$PATH; export PATH; \
198 (cd .native/${MACHINE_GNU_PLATFORM}/libstdc++-v3/include && \
199 ${MKNATIVE_ENV} ${BUILD_MAKE} \
200 CC_FOR_TARGET=${CC:Q}' '${CCADDFLAGS:Q} \
201 CXX_FOR_TARGET=${CXX:Q}' '${CCADDFLAGS:Q}' '${CXXADDFLAGS:Q} \
202 CPP=${CPP:Q}' '-I${DESTDIR}/usr/include \
203 all-local) && \
204 true
205 .if 0
206 PATH=${TOOLDIR}/bin:$$PATH; export PATH; \
207 (cd .native/${MACHINE_GNU_PLATFORM}/libiberty && \
208 ${MKNATIVE_ENV} ${BUILD_MAKE} needed-list)
209 .endif
210 @touch $@
212 clean: clean.native
213 clean.native:
214 -rm -r -f .native