Skip to content

Commit 1665cd6

Browse files
committed
external_deps: refactor the GLEW build
1 parent f0cf87f commit 1665cd6

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
@@ -497,32 +497,53 @@ build_glew() {
497497

498498
cd "${dir_name}"
499499

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

0 commit comments

Comments
 (0)