2008年5月14日水曜日

mac win兼用makefile

このエントリーをブックマークに追加 このエントリーを含むはてなブックマーク
とりあえず、現状こんな感じになりました。pythonなのにbdist_winistしてないのはなぜとか聞かないように。しかしmacとwinのmakefileを1つのファイルで済ます方針はどうなんでしょうね?releaseのためのbuildツリーを作る方法はそのためのmakefileを作って呼ぶようにすればいいので、このコードでの共有は本質的ではないです。ビルドステップの共有化(抽象化?)というべきか同じ名前のターゲットが用意されていることぐらいですか?改行はdosだし。びみょ~~~。

人様からみて参考になりそうなのはdmgまわりとかかな。


# Makefile for M$ Windows platform with MinGW make, mingw32-make to build
#

.PHONY: clean Release Develop useReleaseConfig useDevelopConfig abstRelease abstDevelop

all: installer
installer: Release
abstRelease: RelaseExecutable useReleaseConfig
abstDevelop: DevelopExecutable useDevelopConfig
clean: clean_installer clean_config clean_executable clean_workspace
#do not remove tree.


ifeq ($(PLATFORM),win32)
Release: abstRelease wxPyGammon.nsi
d:\bin\NSIS\makensis.exe wxPyGammon.nsi
copy workspace\wxPyGammon-installer.exe Release.exe
Develop: abstDevelop wxPyGammon.nsi
d:\bin\NSIS\makensis.exe wxPyGammon.nsi
copy workspace\wxPyGammon-installer.exe Develop.exe
clean_installer:
-del /Q Release.exe
-del /Q Develop.exe
-del /Q workspace\wxPyGammon-installer.exe
endif

ifeq ($(PLATFORM),darwin)

define create-dmg
hdiutil create -size $(word 1,$(shell du -sk workspace))k -type UDIF -fs HFS+ -volname 'wxPyGammon' -layout None $@
endef

define mount-dmg
hdiutil attach $^ -mountpoint dmg
endef

define unmount-dmg
WC_DEV=`hdiutil info | grep dmg | grep "^/dev" | awk '{print $$1}'` && \
hdiutil detach $$WC_DEV
endef

define dmgify
-mkdir dmg
$(mount-dmg)
cp -R workspace/dist/wxPyGammon.app dmg/wxPyGammon.app
$(unmount-dmg)
rm -rf dmg
endef

Release: Release.dmg
$(dmgify)
Develop: Develop.dmg
$(dmgify)

Release.dmg: abstRelease
$(create-dmg)
Develop.dmg: abstDevelop
$(create-dmg)

clean_installer:
-$(unmount-dmg)
-rm -rf dmg
-rm Release.dmg
-rm Develop.dmg
endif



ifeq ($(PLATFORM),win32)
DevelopExecutable: wxPyGammon.exe
RelaseExecutable: wxPyGammon.exe
wxPyGammon.exe: wxPyGammon.spec workspace
python D:\bin\pyinstaller-1.3\Build.py workspace/wxPyGammon.spec
wxPyGammon.spec: source workspace
python D:\bin\pyinstaller-1.3\Makespec.py -w -F -n wxPyGammon -o workspace tree/wxPyGammon
clean_executable:
-del /Q workspace\wxPyGammon.exe
endif


ifeq ($(PLATFORM),darwin)
DevelopExecutable: wxPyGammon.py MacOSXSetup.py useDevelopConfig workspace
python MacOSXSetup.py py2app

RelaseExecutable: wxPyGammon.py MacOSXSetup.py useReleaseConfig workspace
python MacOSXSetup.py py2app

wxPyGammon.py: source
mv tree/wxPyGammon tree/wxPyGammon.py
clean_executable:
-rm -rf workspace/wxPyGammon.app
endif

useReleaseConfig: source
ifeq ($(PLATFORM),win32)
copy tree\release\connection.cfg tree\config\connection.cfg
endif
ifeq ($(PLATFORM),darwin)
cp tree/release/connection.cfg tree/config/connection.cfg
endif

useDevelopConfig: source
ifeq ($(PLATFORM),win32)
copy tree\develop\connection.cfg tree\config\connection.cfg
endif
ifeq ($(PLATFORM),darwin)
cp tree/develop/connection.cfg tree/config/connection.cfg
endif

clean_config:
ifeq ($(PLATFORM),win32)
-del /Q tree\config\connection.cfg
endif
ifeq ($(PLATFORM),darwin)
-rm tree/config/connection.cfg
endif


#Get Latest from SVN
source: tree update_tree
tree:
svn co http://svn.tonic-water.com/projects/proprietary/wxpygammon/trunk/src/ tree
svn co http://svn.tonic-water.com/projects/proprietary/bglib/trunk/src/ tree/bglib
update_tree:
svn update tree
svn update tree/bglib

clean_tree:
ifeq ($(PLATFORM),win32)
-rmdir /S /Q tree
endif
ifeq ($(PLATFORM),darwin)
-rm -rf tree
endif


workspace:
mkdir workspace
clean_workspace:
ifeq ($(PLATFORM),win32)
-rmdir /S /Q workspace
endif
ifeq ($(PLATFORM),darwin)
-rm -rf workspace
endif

0 件のコメント: