Skip to content

Commit e6fe1fe

Browse files
committed
external_deps: fix GLEW windows build
Building glew for windows-i686-mingw resulted in a link error about undefined strlen. This happend because setting CFLAGS.EXTRA on the Make command line clobbers some required flags. Pass the flags in a different way so they append rather than clobbering.
1 parent 7ea55ff commit e6fe1fe

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

external_deps/build.sh

+10-4
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,16 @@ build_glew() {
397397
"${download_only}" && return
398398

399399
cd "${dir_name}"
400+
# env hack: CFLAGS.EXTRA is populated with some flags, which are sometimess necessary for
401+
# compilation, in the makefile with +=. If CFLAGS.EXTRA is set on the command line, those
402+
# += will be ignored. But if it is set via the environment, the two sources are actually
403+
# concatenated how we would like. Bash doesn't allow variables with a dot so use env.
404+
# The hack doesn't work on Mac's ancient Make (the env var has no effect), so we have to
405+
# manually re-add the required flags there.
400406
case "${PLATFORM}" in
401407
windows-*-*)
402-
make SYSTEM="linux-mingw${BITNESS}" GLEW_DEST="${PREFIX}" CC="${CC}" AR="${AR}" RANLIB="${RANLIB}" STRIP="${HOST}-strip" LD="${LD}" CFLAGS.EXTRA="${CFLAGS}" LDFLAGS.EXTRA="${LDFLAGS}"
403-
make install SYSTEM="linux-mingw${BITNESS}" GLEW_DEST="${PREFIX}" CC="${CC}" AR="${AR}" RANLIB="${RANLIB}" STRIP="${HOST}-strip" LD="${LD}" CFLAGS.EXTRA="${CFLAGS}" LDFLAGS.EXTRA="${LDFLAGS}"
408+
env CFLAGS.EXTRA="${CFLAGS}" LDFLAGS.EXTRA="${LDFLAGS}" make SYSTEM="linux-mingw${BITNESS}" GLEW_DEST="${PREFIX}" CC="${CC}" AR="${AR}" RANLIB="${RANLIB}" STRIP="${HOST}-strip" LD="${LD}"
409+
env CFLAGS.EXTRA="${CFLAGS}" LDFLAGS.EXTRA="${LDFLAGS}" make install SYSTEM="linux-mingw${BITNESS}" GLEW_DEST="${PREFIX}" CC="${CC}" AR="${AR}" RANLIB="${RANLIB}" STRIP="${HOST}-strip" LD="${LD}"
404410
mv "${PREFIX}/lib/glew32.dll" "${PREFIX}/bin/"
405411
rm "${PREFIX}/lib/libglew32.a"
406412
cp lib/libglew32.dll.a "${PREFIX}/lib/"
@@ -412,8 +418,8 @@ build_glew() {
412418
;;
413419
linux-*-*)
414420
local strip="${HOST/-unknown-/-}-strip"
415-
make GLEW_DEST="${PREFIX}" CC="${CC}" LD="${CC}" STRIP="${strip}" CFLAGS.EXTRA="${CFLAGS}" LDFLAGS.EXTRA="${LDFLAGS}"
416-
make install GLEW_DEST="${PREFIX}" CC="${CC}" LD="${CC}" CFLAGS.EXTRA="${CFLAGS}" LDFLAGS.EXTRA="${LDFLAGS}" LIBDIR="${PREFIX}/lib"
421+
env CFLAGS.EXTRA="${CFLAGS}" LDFLAGS.EXTRA="${LDFLAGS}" make GLEW_DEST="${PREFIX}" CC="${CC}" LD="${CC}" STRIP="${strip}"
422+
env CFLAGS.EXTRA="${CFLAGS}" LDFLAGS.EXTRA="${LDFLAGS}" make install GLEW_DEST="${PREFIX}" CC="${CC}" LD="${CC}" LIBDIR="${PREFIX}/lib"
417423
;;
418424
*)
419425
log ERROR 'Unsupported platform for GLEW'

0 commit comments

Comments
 (0)