Skip to content

Commit 24f2034

Browse files
committed
Add docker build and add mingw64 cross compile
1 parent 2812d7e commit 24f2034

7 files changed

+44
-11
lines changed

Dockerfile

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM debian
2+
3+
RUN apt-get update && apt-get install -y gcc-mingw-w64-i686 g++-mingw-w64-i686 gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 libtool pkg-config bzip2 zip make autoconf wget patch git automake flex bison cmake xsltproc && rm -rf /var/lib/apt/lists/*
4+
5+
COPY . /avrdude-build-script
6+
7+
WORKDIR /avrdude-build-script
8+
9+
ENTRYPOINT ["/avrdude-build-script/package-avrdude.bash"]

Readme.md

+16
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,22 @@ Just run:
1818
Setup has been done on partially set up development machines.
1919
If you find any package missing from the following list, please open an issue at once!
2020

21+
### Docker Building
22+
23+
Run:
24+
```
25+
mkdir dist
26+
docker build . -t avrdude-builder
27+
# cross compile i686
28+
docker run --rm -it -v $PWD/dist:/avrdude-build-script/dist -e CROSS_COMPILE=mingw avrdude-builder
29+
# cross compile x86_64
30+
docker run --rm -it -v $PWD/dist:/avrdude-build-script/dist -e CROSS_COMPILE=mingw64 avrdude-builder
31+
# remove container
32+
docker rmi avrdude-builder
33+
```
34+
35+
If you do not need cross compile, just remove `-e CROSS_COMPILE=mingw`.
36+
2137
#### Debian requirements
2238

2339
```bash

avrdude-6.3.build.bash

+1-6
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,7 @@ fi
4040

4141
COMMON_FLAGS=""
4242

43-
if [[ $CROSS_COMPILE == "mingw" ]] ; then
44-
CFLAGS="-DHAVE_LIBHIDAPI $CFLAGS"
45-
LIBS="-lhidapi -lsetupapi -Wl,-Bstatic -lwinpthread"
46-
fi
47-
48-
if [[ $OS == "Msys" ]] ; then
43+
if [[ $CROSS_COMPILE == "mingw" || $CROSS_COMPILE == "mingw64" || $OS == "Msys" ]] ; then
4944
CFLAGS="-DHAVE_LIBHIDAPI $CFLAGS"
5045
LIBS="-lhidapi -lsetupapi -Wl,-Bstatic -lwinpthread"
5146
fi

libftdi-1.4.build.bash

+5-1
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,14 @@ cd build/
3636

3737
CMAKE_EXTRA_FLAG="-DSHAREDLIBS=OFF -DBUILD_TESTS=OFF"
3838

39-
if [[ $OS == "GNU/Linux" ]] ; then
39+
if [[ $OS == "GNU/Linux" && $CROSS_COMPILE == "mingw" ]] ; then
4040
CMAKE_EXTRA_FLAG="$CMAKE_EXTRA_FLAG -DCMAKE_TOOLCHAIN_FILE=./cmake/Toolchain-i686-w64-mingw32.cmake"
4141
fi
4242

43+
if [[ $OS == "GNU/Linux" && $CROSS_COMPILE == "mingw64" ]] ; then
44+
CMAKE_EXTRA_FLAG="$CMAKE_EXTRA_FLAG -DCMAKE_TOOLCHAIN_FILE=./cmake/Toolchain-x86_64-w64-mingw32.cmake"
45+
fi
46+
4347
cmake $CMAKE_EXTRA_FLAG -DCMAKE_INSTALL_PREFIX="$PREFIX" -DLIBUSB_INCLUDE_DIR="$PREFIX/include/libusb-1.0" -DLIBFTDI_LIBRARY_DIRS="$PREFIX/lib" -DLIBUSB_LIBRARIES="usb-1.0" ../
4448
make -j 1
4549
make install

libncurses-5.9.build.bash

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ cd objdir
2020
PREFIX=`pwd`
2121
cd -
2222

23-
if [[ $OS == "Msys" || $OS == "Cygwin" || $CROSS_COMPILE_HOST == "i686-w64-mingw32" || $CROSS_COMPILE_HOST == "aarch64-linux-gnu" ]] ; then
23+
if [[ $OS == "Msys" || $OS == "Cygwin" || $CROSS_COMPILE_HOST == "i686-w64-mingw32" || $CROSS_COMPILE_HOST == "x86_64-w64-mingw32" || $CROSS_COMPILE_HOST == "aarch64-linux-gnu" ]] ; then
2424
#Avoid compiling ncurses in Windows platform
2525
exit 0
2626
fi

libusb-compat-0.1.5.build.bash

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fi
4141
tar xfv libusb-compat-0.1.5.tar.bz2
4242

4343
cd libusb-compat-0.1.5
44-
if [[ $OS == "Msys" || $OS == "Cygwin" || $CROSS_COMPILE_HOST == "i686-w64-mingw32" ]] ; then
44+
if [[ $OS == "Msys" || $OS == "Cygwin" || $CROSS_COMPILE_HOST == "i686-w64-mingw32" || $CROSS_COMPILE_HOST == "x86_64-w64-mingw32" ]] ; then
4545
patch -p1 < ../libusb-compat-0.1.5-patches/01-mingw-build.patch
4646
autoreconf --force --install
4747
fi

package-avrdude.bash

+11-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ if [[ $CROSS_COMPILE == "mingw" ]] ; then
2727
export CROSS_COMPILE_HOST="i686-w64-mingw32"
2828
export TARGET_OS="Windows"
2929
OUTPUT_TAG=i686-w64-mingw32
30+
elif [[ $CROSS_COMPILE == "mingw64" ]] ; then
31+
32+
export CC="x86_64-w64-mingw32-gcc"
33+
export CXX="x86_64-w64-mingw32-g++"
34+
export CROSS_COMPILE_HOST="x86_64-w64-mingw32"
35+
export TARGET_OS="Windows"
36+
OUTPUT_TAG=x86_64-w64-mingw32
3037

3138
elif [[ $CROSS_COMPILE == "arm64-cross" ]] ; then
3239
export CC="aarch64-linux-gnu-gcc"
@@ -109,14 +116,16 @@ if [[ ${OUTPUT_TAG} == *"mingw"* ]] ; then
109116
#cp libusb-win32-bin-1.2.6.0/bin/x86/libusb0_x86.dll objdir/bin/libusb0.dll
110117
rm -f avrdude-${OUTPUT_VERSION}-${OUTPUT_TAG}.zip
111118
cp -a objdir avrdude
112-
zip -r avrdude-${OUTPUT_VERSION}-${OUTPUT_TAG}.zip avrdude/bin/ avrdude/etc/avrdude.conf
119+
mkdir -p dist/
120+
zip -r dist/avrdude-${OUTPUT_VERSION}-${OUTPUT_TAG}.zip avrdude/bin/ avrdude/etc/avrdude.conf
113121
rm -r avrdude
114122

115123
else
116124

117125
rm -f avrdude-${OUTPUT_VERSION}-${OUTPUT_TAG}.tar.bz2
118126
cp -a objdir avrdude
119-
tar -cjvf avrdude-${OUTPUT_VERSION}-${OUTPUT_TAG}.tar.bz2 avrdude/bin/avrdude avrdude/etc/avrdude.conf
127+
mkdir -p dist/
128+
tar -cjvf dist/avrdude-${OUTPUT_VERSION}-${OUTPUT_TAG}.tar.bz2 avrdude/bin/avrdude avrdude/etc/avrdude.conf
120129
rm -r avrdude
121130

122131
fi

0 commit comments

Comments
 (0)