Makefile.cross revision 1.2
1# $OpenBSD: Makefile.cross,v 1.2 2005/01/10 17:47:15 espie Exp $ 2 3cross-tools: cross-includes cross-binutils cross-gcc cross-lib 4cross-distrib: cross-tools cross-bin cross-etc-root-var 5 6CROSSCPPFLAGS?= -nostdinc -I${CROSSDIR}/usr/include 7CROSSLDFLAGS?= -nostdlib -L${CROSSDIR}/usr/lib -static 8CROSSCFLAGS?= ${CROSSCPPFLAGS} 9CROSSCXXFLAGS?= ${CROSSCPPFLAGS} 10LDSTATIC?= -static 11 12CROSSDIR= ${DESTDIR}/usr/cross/${TARGET} 13CROSSENV= AR=${CROSSDIR}/usr/bin/ar AS=${CROSSDIR}/usr/bin/as \ 14 CC=${CROSSDIR}/usr/bin/cc CPP=${CROSSDIR}/usr/bin/cpp \ 15 CXX=${CROSSDIR}/usr/bin/c++ \ 16 LD=${CROSSDIR}/usr/bin/ld NM=${CROSSDIR}/usr/bin/nm \ 17 LORDER=/usr/bin/lorder RANLIB=${CROSSDIR}/usr/bin/ranlib \ 18 SIZE=${CROSSDIR}/usr/bin/size STRIP=${CROSSDIR}/usr/bin/strip \ 19 HOSTCC=\"${CC}\" HOSTCXX=\"${CXX}\" NOMAN= DESTDIR=${CROSSDIR} \ 20 HOSTCFLAGS=\"${CFLAGS}\" HOSTCXXFLAGS=\"${CXXFLAGS}\" \ 21 HOSTLDFLAGS=\"${LDFLAGS} \" \ 22 CFLAGS=\"${CROSSCFLAGS}\" CPPFLAGS=\"${CROSSCPPFLAGS}\" \ 23 CXXFLAGS=\"${CROSSCXXFLAGS}\" \ 24 LDFLAGS=\"${CROSSLDFLAGS}\" 25CROSSPATH= ${PATH}:${CROSSDIR}/usr/bin 26CROSSLANGS?= c c++ 27 28TARGET_CANON=`cat ${CROSSDIR}/TARGET_CANON` 29TARGET_ARCH=`cat ${CROSSDIR}/TARGET_ARCH` 30 31CROSSDIRS= ${CROSSDIR}/.dirs_done 32CROSSOBJ= ${CROSSDIR}/usr/obj/.obj_done 33CROSSINCLUDES= ${CROSSDIR}/usr/include/.includes_done 34CROSSBINUTILS= ${CROSSDIR}/usr/bin/.binutils_done 35CROSSGCC= ${CROSSDIR}/usr/bin/.gcc_done 36NO_CROSS= isakmpd tn3270 less sudo openssl libkeynote libssl \ 37 photurisd keynote sectok ssh 38 39# no libcrypto.... these won't build 40NO_CROSS+= telnetd login_krb5 login_krb5-or-pwd dc passwd telnet ppp \ 41 tcpdump 42# need host setup for ydr 43NO_CROSS+=afs 44# explicit cross-compile 45NO_CROSS+=bind 46 47cross-dirs: ${CROSSDIRS} 48cross-obj: ${CROSSOBJ} 49cross-includes: ${CROSSINCLUDES} 50cross-binutils: ${CROSSBINUTILS} 51cross-gcc: ${CROSSGCC} 52 53cross-env: 54 @echo ${CROSSENV} MACHINE=${TARGET} \ 55 MACHINE_ARCH=`cat ${CROSSDIR}/TARGET_ARCH` 56 57${CROSSDIRS}: 58 @-mkdir -p ${CROSSDIR} 59 @case ${TARGET} in \ 60 alpha|amd64|hppa|hppa64|i386|m68k|m88k|powerpc|sparc|sparc64|vax) \ 61 echo ${TARGET} ;;\ 62 amiga|hp300|mac68k|mvme68k) \ 63 echo m68k ;;\ 64 luna88k|mvme88k) \ 65 echo m88k ;;\ 66 macppc|mvmeppc) \ 67 echo powerpc ;;\ 68 sgi) \ 69 echo mips64 ;;\ 70 *) \ 71 (echo Unknown arch ${TARGET} >&2) ; exit 1;; \ 72 esac > ${CROSSDIR}/TARGET_ARCH 73 @echo TARGET_ARCH is `cat ${CROSSDIR}/TARGET_ARCH` 74 @eval `grep '^osr=' sys/conf/newvers.sh`; \ 75 sed "s/\$$/-unknown-openbsd$$osr/" ${CROSSDIR}/TARGET_ARCH > \ 76 ${CROSSDIR}/TARGET_CANON 77 @-mkdir -p ${CROSSDIR} 78 @-mkdir -p ${CROSSDIR}/usr/${TARGET_CANON} 79 @ln -sf ${CROSSDIR}/usr/include \ 80 ${CROSSDIR}/usr/${TARGET_CANON}/include 81 @ln -sf ${CROSSDIR}/usr/lib \ 82 ${CROSSDIR}/usr/${TARGET_CANON}/lib 83 @-mkdir -p ${CROSSDIR}/usr/${TARGET_CANON}/bin 84 @(cd ${.CURDIR}/etc && DESTDIR=${CROSSDIR} ${MAKE} distrib-dirs) 85 @touch ${CROSSDIRS} 86 87${CROSSOBJ}: ${CROSSDIRS} 88 @-mkdir -p ${CROSSDIR}/usr/obj 89 @(cd ${.CURDIR} && \ 90 BSDOBJDIR=${CROSSDIR}/usr/obj \ 91 MACHINE=${TARGET} \ 92 MACHINE_ARCH=${TARGET_ARCH} \ 93 BSDSRCDIR=${.CURDIR} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \ 94 ${MAKE} obj) 95 @touch ${CROSSOBJ} 96 97${CROSSINCLUDES}: ${CROSSOBJ} 98 @-mkdir -p ${CROSSDIR}/usr/include 99 @(cd ${.CURDIR}/include && \ 100 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \ 101 MAKEOBJDIR=obj.${MACHINE}.${TARGET} \ 102 ${MAKE} prereq && \ 103 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \ 104 MAKEOBJDIR=obj.${MACHINE}.${TARGET} \ 105 ${MAKE} DESTDIR=${CROSSDIR} includes) 106 @touch ${CROSSINCLUDES} 107 108.if ${MACHINE_ARCH} == "m68k" || ${MACHINE_ARCH} == "m88k" || \ 109 ${MACHINE_ARCH} == "vax" 110BINUTILS= ar as ld nm ranlib objcopy objdump strings strip 111NEW_BINUTILS?= No 112.else 113BINUTILS= ar as gasp ld nm objcopy objdump ranlib readelf size \ 114 strings strip 115NEW_BINUTILS?= Yes 116.endif 117 118${CROSSBINUTILS}: ${CROSSINCLUDES} 119.if ${NEW_BINUTILS:L} == "yes" 120 (cd ${.CURDIR}/gnu/usr.bin/binutils; \ 121 MAKEOBJDIR=obj.${MACHINE}.${TARGET} \ 122 TARGET_ARCH=${TARGET_ARCH} \ 123 ${MAKE} -f Makefile.bsd-wrapper depend && \ 124 MAKEOBJDIR=obj.${MACHINE}.${TARGET} \ 125 TARGET_ARCH=${TARGET_ARCH} \ 126 ${MAKE} -f Makefile.bsd-wrapper all && \ 127 DESTDIR=${CROSSDIR} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \ 128 ${MAKE} -f Makefile.bsd-wrapper install) 129.else 130 (cd ${.CURDIR}/gnu/usr.bin/gas; \ 131 TARGET_MACHINE_ARCH=${TARGET_ARCH} \ 132 MAKEOBJDIR=obj.${MACHINE}.${TARGET} ${MAKE} depend all; \ 133 TARGET_MACHINE_ARCH=${TARGET_ARCH} \ 134 DESTDIR=${CROSSDIR} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \ 135 ${MAKE} NOMAN= install) 136 ln -sf ${CROSSDIR}/usr/bin/as \ 137 ${CROSSDIR}/usr/${TARGET_ARCH}/bin/as 138 (cd ${.CURDIR}/gnu/usr.bin/ld; \ 139 TARGET_MACHINE_ARCH=${TARGET_ARCH} \ 140 MAKEOBJDIR=obj.${MACHINE}.${TARGET} \ 141 ${MAKE} NOPIC= NOMAN= depend all; \ 142 TARGET_MACHINE_ARCH=${TARGET_ARCH} \ 143 DESTDIR=${CROSSDIR} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \ 144 ${MAKE} NOPIC= NOMAN= install) 145 ln -sf ${CROSSDIR}/usr/bin/ld \ 146 ${CROSSDIR}/usr/${TARGET_CANON}/bin/ld 147 (cd ${.CURDIR}/usr.bin/ar; \ 148 MAKEOBJDIR=obj.${MACHINE}.${TARGET} ${MAKE} NOMAN= depend all; \ 149 DESTDIR=${CROSSDIR} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \ 150 ${MAKE} NOMAN= install) 151 ln -sf ${CROSSDIR}/usr/bin/ar \ 152 ${CROSSDIR}/usr/${TARGET_CANON}/bin/ar 153 (cd ${.CURDIR}/usr.bin/ranlib; \ 154 MAKEOBJDIR=obj.${MACHINE}.${TARGET} ${MAKE} NOMAN= depend all; \ 155 DESTDIR=${CROSSDIR} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \ 156 ${MAKE} NOMAN= install) 157 ln -sf ${CROSSDIR}/usr/bin/ranlib \ 158 ${CROSSDIR}/usr/${TARGET_CANON}/bin/ranlib 159 (cd ${.CURDIR}/usr.bin/strip; \ 160 MAKEOBJDIR=obj.${MACHINE}.${TARGET} \ 161 ${MAKE} TARGET_MACHINE_ARCH=${TARGET_ARCH} \ 162 NOMAN= depend all; \ 163 DESTDIR=${CROSSDIR} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \ 164 ${MAKE} TARGET_MACHINE_ARCH=${TARGET_ARCH} \ 165 NOMAN= install) 166 ln -sf ${CROSSDIR}/usr/bin/strip \ 167 ${CROSSDIR}/usr/${TARGET_CANON}/bin/strip 168.endif 169 @for cmd in ${BINUTILS}; do \ 170 if [ ! -e ${CROSSDIR}/usr/bin/$$cmd -a \ 171 -e ${CROSSDIR}/usr/bin/${TARGET_CANON}-$$cmd ]; then \ 172 ln -sf ${TARGET_CANON}-$$cmd ${CROSSDIR}/usr/bin/$$cmd ;\ 173 elif [ -e ${CROSSDIR}/usr/bin/$$cmd -a \ 174 ! -e ${CROSSDIR}/usr/bin/${TARGET_CANON}-$$cmd ]; then \ 175 ln -sf $$cmd ${CROSSDIR}/usr/bin/${TARGET_CANON}-$$cmd; \ 176 fi ;\ 177 if [ -e ${CROSSDIR}/usr/bin/$$cmd -a \ 178 ! -e ${CROSSDIR}/usr/${TARGET_CANON}/bin/$$cmd ]; then \ 179 ln -sf ${CROSSDIR}/usr/bin/$$cmd \ 180 ${CROSSDIR}/usr/${TARGET_CANON}/bin/$$cmd; \ 181 fi ;\ 182 done 183 @touch ${CROSSBINUTILS} 184 185# bsd.own.mk can't do it for us 186.if ${TARGET} == "amd64" || ${TARGET} == "cats" || \ 187 ${TARGET} == "hppa" || ${TARGET} == "hppa64" || \ 188 ${TARGET} == "i386" || \ 189 ${TARGET} == "sparc64" || ${TARGET} == "sgi" 190USE_GCC3=yes 191.else 192USE_GCC3=no 193.endif 194 195${CROSSGCC}: ${CROSSBINUTILS} 196.if ${USE_GCC3:L} == "yes" 197 (cd ${.CURDIR}/gnu/usr.bin/gcc; \ 198 MAKEOBJDIR=obj.${MACHINE}.${TARGET} \ 199 TARGET_ARCH=${TARGET_ARCH} CROSSDIR=${CROSSDIR} \ 200 ${MAKE} -f Makefile.bsd-wrapper depend && \ 201 MAKEOBJDIR=obj.${MACHINE}.${TARGET} \ 202 TARGET_ARCH=${TARGET_ARCH} CROSSDIR=${CROSSDIR} \ 203 ${MAKE} -f Makefile.bsd-wrapper all && \ 204 DESTDIR=${CROSSDIR} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \ 205 ${MAKE} -f Makefile.bsd-wrapper install) 206 ln -sf ${TARGET_CANON}-g++ ${CROSSDIR}/usr/bin/c++ 207 ln -sf ${CROSSDIR}/usr/libexec/cpp \ 208 ${CROSSDIR}/usr/bin/cpp 209.else 210 (cd ${CROSSDIR}/usr/obj/gnu/egcs/gcc; \ 211 /bin/sh ${.CURDIR}/gnu/egcs/gcc/configure \ 212 --with-gnu-as --with-gnu-ld --prefix ${CROSSDIR}/usr \ 213 --target ${TARGET_CANON} \ 214 --enable-languages="c,c++" --enable-cpp --disable-nls \ 215 --with-gxx-include-dir=${CROSSDIR}/usr/include/g++ && \ 216 PATH=${CROSSPATH} ${MAKE} BISON=yacc LANGUAGES="${CROSSLANGS}" \ 217 CFLAGS="${CFLAGS} -I${.CURDIR}/gnu/lib/libiberty/include" \ 218 LIBIBERTY_INCLUDES=${.CURDIR}/gnu/lib/libiberty/include \ 219 DEMANGLER_PROG= DEMANGLE_H= LDFLAGS="${LDSTATIC}" build_infodir=. \ 220 GCC_FOR_TARGET="./xgcc -B./ -I${CROSSDIR}/usr/include" && \ 221 ${MAKE} BISON=yacc LANGUAGES="${CROSSLANGS}" LDFLAGS="${LDSTATIC}" \ 222 GCC_FOR_TARGET="./xgcc -B./ -I${CROSSDIR}/usr/include" \ 223 CFLAGS="${CFLAGS} -I${.CURDIR}/gnu/lib/libiberty/include" \ 224 LIBIBERTY_INCLUDES=${.CURDIR}/gnu/lib/libiberty/include \ 225 build_infodir=. INSTALL_MAN= INSTALL_HEADERS_DIR= install) 226 ln -sf ${TARGET_CANON}-gcc ${CROSSDIR}/usr/bin/cc 227 ln -sf ${TARGET_CANON}-g++ ${CROSSDIR}/usr/bin/c++ 228 ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 229 ${CROSSDIR}/usr/obj/gnu/egcs/gcc/cpp \ 230 ${CROSSDIR}/usr/libexec/cpp 231 sed -e 's#/usr/libexec/cpp#${CROSSDIR}/usr/libexec/cpp#' \ 232 -e 's#/usr/include#${CROSSDIR}/usr/include#' \ 233 ${.CURDIR}/usr.bin/cpp/cpp.sh > ${CROSSDIR}/usr/bin/cpp 234 chmod ${BINMODE} ${CROSSDIR}/usr/bin/cpp 235 chown ${BINOWN}:${BINGRP} ${CROSSDIR}/usr/bin/cpp 236.endif 237 @touch ${CROSSGCC} 238 239# XXX MAKEOBJDIR maybe should be obj.${TARGET} here, revisit later 240cross-lib: ${CROSSGCC} 241 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}; \ 242 export MACHINE MACHINE_ARCH; \ 243 (cd ${.CURDIR}/lib; \ 244 for lib in csu libc; do \ 245 (cd $$lib; \ 246 eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \ 247 ${MAKE} depend all install); \ 248 done; \ 249 eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \ 250 SKIPDIR=\"${NO_CROSS} libocurses/PSD.doc\" \ 251 ${MAKE} depend all install) 252 253cross-bin: ${CROSSOBJ} 254 MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH}; \ 255 export MACHINE MACHINE_ARCH; \ 256 for i in libexec bin sbin usr.bin usr.sbin; do \ 257 (cd ${.CURDIR}/$$i; \ 258 eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \ 259 SKIPDIR=\"${BINUTILS} ${NO_CROSS}\" \ 260 ${MAKE} depend all install); \ 261 done 262 263cross-etc-root-var: ${CROSSOBJ} 264 (cd ${.CURDIR}/etc && \ 265 DESTDIR=${CROSSDIR} ${MAKE} distribution-etc-root-var) 266 267cross-depend: 268 @(cd ${.CURDIR} && \ 269 BSDOBJDIR=${CROSSDIR}/usr/obj \ 270 BSDSRCDIR=${.CURDIR} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \ 271 SKIPDIR="${NO_CROSS}" \ 272 ${MAKE} depend) 273 274cross-clean: 275 @(cd ${.CURDIR} && \ 276 BSDOBJDIR=${CROSSDIR}/usr/obj \ 277 BSDSRCDIR=${.CURDIR} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \ 278 SKIPDIR="${NO_CROSS}" \ 279 ${MAKE} clean) 280 281cross-cleandir: 282 @(cd ${.CURDIR} && \ 283 BSDOBJDIR=${CROSSDIR}/usr/obj \ 284 BSDSRCDIR=${.CURDIR} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \ 285 SKIPDIR="${NO_CROSS}" \ 286 ${MAKE} cleandir) 287 288