Skip to content

Commit ed15d43

Browse files
committed
Make compile_cross generic
1 parent 94f3a82 commit ed15d43

File tree

1 file changed

+30
-14
lines changed

1 file changed

+30
-14
lines changed

compile_linuxarm_openocd.sh

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with this program; if not, write to the Free Software
1616
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17-
ARCH=`arm-linux-gnueabihf-gcc -v 2>&1 | awk '/Target/ { print $2 }'`
17+
18+
if [ x$CROSS_COMPILER == x ]; then
19+
CROSS_COMPILER=${CROSS_COMPILE}-gcc
20+
fi
21+
22+
ARCH=`$CROSS_COMPILER -v 2>&1 | awk '/Target/ { print $2 }'`
1823

1924
mkdir -p distrib/$ARCH
2025
cd distrib/$ARCH
@@ -24,12 +29,16 @@ cd -
2429
#disable pkg-config
2530
export PKG_CONFIG_PATH=`pwd`
2631

27-
if [[ ${ARCH} != *darwin* ]]; then
32+
if [[ ${ARCH} == *mingw* ]]; then
33+
export CFLAGS="-mno-ms-bitfields"
34+
fi
35+
36+
if [[ ${ARCH} == *linux* ]]; then
2837

2938
cd eudev-3.1.5
3039
export UDEV_DIR=`pwd`
3140
./autogen.sh
32-
./configure --enable-static --disable-shared --disable-blkid --disable-kmod --disable-manpages --host=arm-linux-gnueabihf
41+
./configure --enable-static --disable-shared --disable-blkid --disable-kmod --disable-manpages --host=${CROSS_COMPILE}
3342
make clean
3443
make -j4
3544
cd ..
@@ -42,7 +51,7 @@ fi
4251

4352
cd libusb-1.0.20
4453
export LIBUSB_DIR=`pwd`
45-
./configure --enable-static --disable-shared --host=arm-linux-gnueabihf
54+
./configure --enable-static --disable-shared --host=${CROSS_COMPILE}
4655
make clean
4756
make
4857
cd ..
@@ -57,7 +66,7 @@ cd libusb-compat-0.1.5
5766
export LIBUSB0_DIR=`pwd`
5867
automake --add-missing
5968
autoreconf
60-
./configure --enable-static --disable-shared --host=arm-linux-gnueabihf
69+
./configure --enable-static --disable-shared --host=${CROSS_COMPILE}
6170
make clean
6271
make
6372
cd ..
@@ -70,7 +79,7 @@ export libudev_LIBS="-L$UDEV_DIR/src/libudev/.libs/ -ludev"
7079
cd hidapi
7180
./bootstrap
7281
export HIDAPI_DIR=`pwd`
73-
./configure --enable-static --disable-shared --host=arm-linux-gnueabihf
82+
./configure --enable-static --disable-shared --host=${CROSS_COMPILE}
7483
make clean
7584
make -j4
7685
cd ..
@@ -81,7 +90,7 @@ if [ -d build ]; then
8190
rm -rf build
8291
fi
8392
mkdir build && cd build
84-
cmake -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc -DBUILD_TESTS=no -DDOCUMENTATION=no -DEXAMPLES=no -DFTDIPP=no -DFTDI_EEPROM=no -DLINK_PYTHON_LIBRARY=no -DPYTHON_BINDINGS=no -DCMAKE_INSTALL_PREFIX=$LIBFTDI1_DIR ..
93+
cmake -DCMAKE_C_COMPILER=${CROSS_COMPILER} -DBUILD_TESTS=no -DDOCUMENTATION=no -DEXAMPLES=no -DFTDIPP=no -DFTDI_EEPROM=no -DLINK_PYTHON_LIBRARY=no -DPYTHON_BINDINGS=no -DCMAKE_INSTALL_PREFIX=$LIBFTDI1_DIR ..
8594
cd ..
8695
make clean
8796
make ftdi1-static
@@ -97,23 +106,30 @@ export LIBFTDI_CFLAGS="-I$LIBFTDI1_DIR/src/"
97106
export LIBFTDI_LIBS="-L$LIBFTDI1_DIR/src/ -lftdi1 -lpthread"
98107
export HIDAPI_CFLAGS="-I$HIDAPI_DIR/hidapi/"
99108

100-
if [[ ${ARCH} != *darwin* ]]; then
101-
102-
export HIDAPI_LIBS="-L$HIDAPI_DIR/linux/.libs/ -L$HIDAPI_DIR/libusb/.libs/ -lhidapi-hidraw -lhidapi-libusb"
103-
104-
else
109+
if [[ ${ARCH} == *linux* ]]; then
110+
export HIDAPI_LIBS="-L$HIDAPI_DIR/linux/.libs/ -L$HIDAPI_DIR/libusb/.libs/ -lhidapi-hidraw -lhidapi-libusb"
111+
fi
105112

113+
if [[ ${ARCH} == *darwin* ]]; then
106114
export HIDAPI_LIBS="-L$HIDAPI_DIR/mac/.libs/ -L$HIDAPI_DIR/libusb/.libs/ -lhidapi"
107115
fi
108116

117+
if [[ ${ARCH} == *mingw* ]]; then
118+
export HIDAPI_LIBS="-L$HIDAPI_DIR/windows/.libs/ -L$HIDAPI_DIR/libusb/.libs/ -lhidapi"
119+
fi
120+
121+
if [[ ${ARCH} == *mingw* ]]; then
122+
OPENOCD_COMPILE_SWITCHES="--enable-remote-bitbang --enable-stlink --enable-usb-blaster-2 --enable-ti-icdi --enable-jlink --enable-usbprog --enable-cmsis-dap"
123+
else
109124
OPENOCD_COMPILE_SWITCHES="--enable-remote-bitbang --enable-stlink --enable-usb-blaster-2 --enable-ti-icdi --enable-jlink --enable-usbprog --enable-cmsis-dap --enable-jtag_vpi --enable-ioutil"
125+
fi
110126

111-
if [[ ${ARCH} != *darwin* ]]; then
127+
if [[ ${ARCH} == *linux* ]]; then
112128
OPENOCD_COMPILE_SWITCHES="$OPENOCD_COMPILE_SWITCHES --enable-sysfsgpio"
113129
fi
114130

115131
export CFLAGS="-DHAVE_LIBUSB_ERROR_NAME"
116-
PKG_CONFIG_PATH=`pwd` ./configure $OPENOCD_COMPILE_SWITCHES --disable-werror --prefix=$PREFIX --host=arm-linux-gnueabihf
132+
PKG_CONFIG_PATH=`pwd` ./configure $OPENOCD_COMPILE_SWITCHES --disable-werror --prefix=$PREFIX --host=${CROSS_COMPILE}
117133
make clean
118134
CFLAGS=-static make
119135
make install

0 commit comments

Comments
 (0)