Skip to content

Instantly share code, notes, and snippets.

@wakita
Last active Feb 6, 2016
Embed
What would you like to do?
WindowsでMinGW64 + MSYS環境で開発をするための設定.$DROPBOX/win/bin に保存し,$DROPBOX/win/bin を PATH に追加して利用できます.
#!/bin/sh
if [ "$_system_type" = Darwin ]; then
export OSTYPE=Darwin
export C_INCLUDE_PATH=/opt/brew/include
export CPLUS_INCLUDE_PATH=/opt/brew/include
export CMAKE=/opt/brew/bin/cmake
export MAKE=/usr/bin/make
fi
if [ "$MSYSTYPE" = 1 ]; then
export PKG_CONFIG_PATH=/mingw/msys/local/lib/pkgconfig
export CPPFLAGS="-I/mingw/msys/local/include"
export CFLAGS="$CPPFLAGS -mms-bitfields -mthreads"
export CXXFLAGS="$CFLAGS"
export LDFLAGS="-L/mingw/msys/loadl/lib"
export CMAKE="C:\\Program Files (x86)\\CMake\\bin\\cmake"
export MAKE=/bin/make
fi
if [ "$MSYSTYPE" = 2 ]; then
export PKG_CONFIG_PATH=/mingw64/lib/pkgconfig
# export CC=clang
# export CXX=clang++
export CFLAGS="$CPPFLAGS -mms-bitfields -mthreads"
export CXXFLAGS="-std=c++11 $CFLAGS"
export CMAKE=/mingw64/bin/cmake
export MAKE=/mingw64/bin/mingw32-make
fi
if [ "$OSTYPE" = msys ]; then
export _PROJECT_ROOT_="$PWD"
else
export _PROJECT_ROOT_="`echo "$PWD" | sed -e 's/Dropbox (smartnova)/Dropbox/'`"
fi
_PROJECT_SUFFIX_=`echo "$PWD" | sed -e 's/.*Dropbox (smartnova)\///' -e 's/.*wakita\///'`
if [ "$MSYSTYPE" = 1 ]; then
export _PROJECT_BUILD_="/mingw/msys/tmp/$_PROJECT_SUFFIX_"
elif [ "$MSYSTYPE" = 2 ]; then
export _PROJECT_BUILD_="/tmp/$_PROJECT_SUFFIX_"
else
export _PROJECT_BUILD_="/tmp/$_PROJECT_SUFFIX_"
fi
mkdir -p "$_PROJECT_BUILD_"
PATH="$_PROJECT_BUILD_/bin:$_PROJECT_BUILD_:$PATH"
root() { cd "$_PROJECT_ROOT_"/$1; }
build() { cd "$_PROJECT_BUILD_"/$1; }
cmf() { if [ "$1" = "" ]; then build CMakeFiles; else build CMakeFiles/$1.dir; fi }
_cmake() { "$CMAKE" $*; }
cmake() {
if [ "$MSYSTYPE" = 1 ]; then
"$CMAKE" -DCMAKE_INSTALL_PREFIX:PATH=/mingw/msys/local $* -G"MSYS Makefiles" -H. -B"$_PROJECT_BUILD_"
elif [ "$MSYSTYPE" = 2 ]; then
"$CMAKE" -DCMAKE_INSTALL_PREFIX:PATH=/usr/local -DCMAKE_PREFIX_PATH=/mingw64/lib/cmake/glfw $* -G"MSYS Makefiles" -H. -B"$_PROJECT_BUILD_"
elif [ "$OSTYPE" = Darwin ]; then
/opt/brew/bin/cmake -DCMAKE_PREFIX_PATH=/opt/brew/lib/cmake/glfw $* -G"Unix Makefiles" -H"$_PROJECT_ROOT_" -B"$_PROJECT_BUILD_"
fi
}
make() {
$MAKE -C "$_PROJECT_BUILD_" $*;
}
vmake() { make VERBOSE=1 $*; }
debug() {
if [ -x "$_PROJECT_BUILD_/$1" ]; then gdb "$_PROJECT_BUILD_/$1"
elif [ -x "$_PROJECT_BUILD_/bin/$1" ]; then gdb "$_PROJECT_BUILD_/bin/$1"
fi
}
distclean() { rm -rf "$_PROJECT_BUILD_"; }
PATH="$DROPBOX"/win/bin:$DROPBOX/bin:$PATH
pf() { cd "${PROGRAMFILES}"/$1; }
drop() { cd "$DROPBOX"/$1; }
win() { drop win/$1; }
LANG=C
if [ -f /msys.ico ]; then
export MSYSTYPE=1
export LIBRARY_PATH=/mingw/msys/local/lib
PATH=/mingw/mingw64/bin:$PATH
elif [ -f /msys2.ico ]; then
export MSYSTYPE=2
PATH=/mingw64/bin:$PATH
fi
cmake-root() { . "$DROPBOX/win/bin/cmake-root"; }
lf() { ls -FC $*; }
la() { ls -aFC $*; }
ll() { ls -l $*; }
vi() { vim $*; }
dojo() {
drop work/opengl/dojo
cmake-root
}
@wakita

This comment has been minimized.

Copy link
Owner Author

@wakita wakita commented May 13, 2015

MSYSのpkg-configに対応するために環境変数(PKG_CONFIG_PATH)の設定を加えました.

gcc, g++ のような MinGW のツールが MSYS の mount のおかげで見える /usr/local/lib のようなパス指定に対応していないことに気づき,NTFS のパス指定 (/mingw/msys/local/lib) に変更しました.

いくつかのマクロの記述を簡潔にしました.Mac や Linux ではテストしていません.今後,対応します.

@wakita

This comment has been minimized.

Copy link
Owner Author

@wakita wakita commented Jun 5, 2015

MSYS2への対応のために大幅に書き換えました.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment