[ADD] Makefile for cross_compiler create, complete later.
[sd3000.git] / tools / cross_compiler / Makefile
bloba771a004584a6c478e87b8ebb386083de8ebef67
1 #Makefile to create cross-compiler
3 all:
4 @echo "later do"
6 #ref: http://cross-lfs.org/view/svn/x86/cross-tools/gcc-static.html
7 export CLFS=/mnt/clfs
8 sudo chown ${USER} /mnt/clfs/ -R
9 mkdir -pv ${CLFS}
10 mkdir -v ${CLFS}/usr
12 install -dv ${CLFS}/tools
13 sudo ln -sv ${CLFS}/tools /
14 install -dv ${CLFS}/cross-tools
15 sudo ln -sv ${CLFS}/cross-tools /
16 sudo chown ${USER} /mnt/clfs/ -R
17 sudo chown ${USER} /tools -R
18 sudo chown ${USER} /cross-tools -R
20 cat >> ~/.bashrc << "EOF"
21 set +h
22 umask 022
23 CLFS=/mnt/clfs
24 LC_ALL=POSIX
25 PATH=/cross-tools/bin:/bin:/usr/bin
26 export CLFS LC_ALL PATH
27 EOF
28 source ~/.bash_profile
30 unset CFLAGS
31 unset CXXFLAGS
32 export CLFS_HOST="$(echo $MACHTYPE | \
33 sed "s/$(echo $MACHTYPE | cut -d- -f2)/cross/")"
35 # cd kernel tree
36 install -dv /tools/include
37 make ARCH=i386 headers_check
38 make ARCH=i386 INSTALL_HDR_PATH=dest headers_install
39 cp -rv dest/include/* /tools/include
41 # file-4.26
42 ./configure --prefix=/cross-tools
43 make
44 make install
46 #Cross Binutils-2.18
47 patch -Np1 -i ../binutils-2.18-posix-1.patch
48 patch -Np1 -i ../binutils-2.18-branch_update-3.patch
49 mkdir -v _build
50 cd _build
51 AR=ar AS=as ../configure --prefix=/cross-tools \
52 --host=${CLFS_HOST} --target=${CLFS_TARGET} --with-lib-path=/tools/lib \
53 --disable-nls --enable-shared --disable-multilib
54 make configure-host
55 make
56 make install
57 cp -v ../include/libiberty.h /tools/include
59 #Cross GCC-4.3.2 - Static
60 patch -Np1 -i ../../gcc-4.3.2-specs-1.static.patch
61 patch -Np1 -i ../../gcc-4.3.2-posix-1.patch
62 echo "
63 #undef STARTFILE_PREFIX_SPEC
64 #define STARTFILE_PREFIX_SPEC \"/tools/lib/\"" >> gcc/config/linux.h
65 cp -v gcc/Makefile.in{,.orig}
66 sed -e "s@\(^CROSS_SYSTEM_HEADER_DIR =\).*@\1 /tools/include@g" \
67 gcc/Makefile.in.orig > gcc/Makefile.in
68 mkdir -v _build
69 cd _build
70 AR=ar ../configure --prefix=/cross-tools \
71 --build=${CLFS_HOST} --host=${CLFS_HOST} --target=${CLFS_TARGET} \
72 --disable-multilib --with-local-prefix=/tools --disable-nls \
73 --without-headers --with-newlib --disable-decimal-float \
74 --disable-libgomp --disable-libmudflap --disable-libssp \
75 --disable-shared --disable-threads --enable-languages=c
76 make
77 make install
79 ## uClibc try (0.9.30)
80 #export prefix=/tools
81 #export ldso_dir=/tools/lib
82 #configure uClibc with UCLIBC_HAS_FENV
83 # OR:configure GCC with --disable-decimal-float
84 make CROSS=${CLFS_TARGET}- PREFIX=/tools RUNTIME_PREFIX=/ menuconfig
85 make CROSS=${CLFS_TARGET}- PREFIX=/tools RUNTIME_PREFIX=/ install_dev
86 make CROSS=${CLFS_TARGET}- PREFIX=/tools RUNTIME_PREFIX=/ install
87 cp -r /tools/usr/i386-linux-uclibc/usr/include/* /tools/include/
89 # Cross GCC-4.3.2 - Final (delete old compiled gcc dir)
90 patch -Np1 -i ../../gcc-4.3.2-specs-1.shared.patch
91 patch -Np1 -i ../../gcc-4.3.2-posix-1.patch
92 echo "
93 #undef STARTFILE_PREFIX_SPEC
94 #define STARTFILE_PREFIX_SPEC \"/tools/lib/\"" >> gcc/config/linux.h
95 cp -v gcc/Makefile.in{,.orig}
96 sed -e "s@\(^CROSS_SYSTEM_HEADER_DIR =\).*@\1 /tools/include@g" \
97 gcc/Makefile.in.orig > gcc/Makefile.in
99 #in file: gcc/config/linux.h
100 <make sure>: UCLIBC_DYNAMIC_LINKER=/lib/ld-uClibc.so.0
101 cp -v configure{,.orig}
102 sed -e '/FLAGS_FOR_TARGET.*\/lib\//s@-B[^ ]*/lib/@@g' configure.orig > \
103 configure
104 mkdir -v _build
105 cd _build
106 ####
107 CFLAGS="$CFLAGS -pthread" \
108 AR=ar ../configure --prefix=/cross-tools \
109 --build=${CLFS_HOST} --target=${CLFS_TARGET} --host=${CLFS_HOST} \
110 --disable-multilib --with-local-prefix=/tools --disable-nls \
111 --enable-shared --enable-languages=c,c++ --enable-__cxa_atexit \
112 --enable-c99 --enable-long-long --enable-threads=posix
113 #CFLAGS="$CFLAGS -pthread"
114 #need at /cross-tools/lib: ln -s libpthread.so.0 libpthread.so
115 #<maybe need>cp -dr /tools/include/* /cross-tools/include/
116 CFLAGS="$CFLAGS -pthread" \
117 make AS_FOR_TARGET="${CLFS_TARGET}-as" \
118 LD_FOR_TARGET="${CLFS_TARGET}-ld"
119 make install