Skip to content

Commit 25d0c86

Browse files
committed
external_deps: refactor the GLEW build
1 parent 4da2440 commit 25d0c86

File tree

1 file changed

+32
-11
lines changed

1 file changed

+32
-11
lines changed

external_deps/build.sh

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -499,32 +499,53 @@ build_glew() {
499499

500500
cd "${dir_name}"
501501

502+
local glew_env=(LDFLAGS.EXTRA="${LDFLAGS}")
503+
local glew_options=(GLEW_DEST="${PREFIX}" CC="${CC}" AR="${AR}" STRIP="${STRIP}")
504+
505+
case "${PLATFORM}" in
506+
windows-*-*)
507+
glew_env+=(CFLAGS.EXTRA="${CFLAGS}")
508+
glew_options+=(SYSTEM="linux-mingw${BITNESS}" LD="${LD}" AR="${AR}" RANLIB="${RANLIB}")
509+
;;
510+
macos-*-*)
511+
glew_env+=(CFLAGS.EXTRA="${CFLAGS} -dynamic -fno-common")
512+
glew_options+=(SYSTEM=darwin LD="${CC}")
513+
;;
514+
linux-*-*)
515+
glew_env+=(CFLAGS.EXTRA="${CFLAGS}")
516+
glew_options+=(LIBDIR="${PREFIX}/lib" LD="${CC}")
517+
;;
518+
*)
519+
log ERROR 'Unsupported platform for GLEW'
520+
;;
521+
esac
522+
502523
# env hack: CFLAGS.EXTRA is populated with some flags, which are sometimess necessary for
503524
# compilation, in the makefile with +=. If CFLAGS.EXTRA is set on the command line, those
504525
# += will be ignored. But if it is set via the environment, the two sources are actually
505526
# concatenated how we would like. Bash doesn't allow variables with a dot so use env.
506527
# The hack doesn't work on Mac's ancient Make (the env var has no effect), so we have to
507528
# manually re-add the required flags there.
529+
case "${PLATFORM}" in
530+
macos-*-*)
531+
make "${glew_env[@]}" "${glew_options[@]}"
532+
make install "${glew_env[@]}" "${glew_options[@]}"
533+
;;
534+
*)
535+
env "${glew_env[@]}" make "${glew_options[@]}"
536+
env "${glew_env[@]}" make install "${glew_options[@]}"
537+
;;
538+
esac
539+
508540
case "${PLATFORM}" in
509541
windows-*-*)
510-
env CFLAGS.EXTRA="${CFLAGS}" LDFLAGS.EXTRA="${LDFLAGS}" make SYSTEM="linux-mingw${BITNESS}" GLEW_DEST="${PREFIX}" CC="${CC}" AR="${AR}" RANLIB="${RANLIB}" STRIP="${STRIP}" LD="${LD}"
511-
env CFLAGS.EXTRA="${CFLAGS}" LDFLAGS.EXTRA="${LDFLAGS}" make install SYSTEM="linux-mingw${BITNESS}" GLEW_DEST="${PREFIX}" CC="${CC}" AR="${AR}" RANLIB="${RANLIB}" STRIP="${STRIP}" LD="${LD}"
512542
mv "${PREFIX}/lib/glew32.dll" "${PREFIX}/bin/"
513543
rm "${PREFIX}/lib/libglew32.a"
514544
cp lib/libglew32.dll.a "${PREFIX}/lib/"
515545
;;
516546
macos-*-*)
517-
make SYSTEM=darwin GLEW_DEST="${PREFIX}" CC="${CC}" LD="${CC}" CFLAGS.EXTRA="${CFLAGS} -dynamic -fno-common" LDFLAGS.EXTRA="${LDFLAGS}"
518-
make install SYSTEM=darwin GLEW_DEST="${PREFIX}" CC="${CC}" LD="${CC}" CFLAGS.EXTRA="${CFLAGS} -dynamic -fno-common" LDFLAGS.EXTRA="${LDFLAGS}"
519547
install_name_tool -id "@rpath/libGLEW.${GLEW_VERSION}.dylib" "${PREFIX}/lib/libGLEW.${GLEW_VERSION}.dylib"
520548
;;
521-
linux-*-*)
522-
env CFLAGS.EXTRA="${CFLAGS}" LDFLAGS.EXTRA="${LDFLAGS}" make GLEW_DEST="${PREFIX}" CC="${CC}" LD="${CC}" STRIP="${STRIP}"
523-
env CFLAGS.EXTRA="${CFLAGS}" LDFLAGS.EXTRA="${LDFLAGS}" make install GLEW_DEST="${PREFIX}" CC="${CC}" LD="${CC}" LIBDIR="${PREFIX}/lib"
524-
;;
525-
*)
526-
log ERROR 'Unsupported platform for GLEW'
527-
;;
528549
esac
529550
}
530551

0 commit comments

Comments
 (0)