Makefile 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. # $Id$
  2. .PHONY: run build clean lint lintrun dist
  3. OS:=$(shell uname -s)
  4. ifeq ($(OS),Darwin)
  5. PYTHONDIR:=/System/Library/Frameworks/Python.framework/Versions/Current
  6. export PYTHONPATH=$(wildcard $(PYTHONDIR)/lib/python*/site-packages)
  7. PYTHONBINPREFIX:=$(PYTHONDIR)/bin/
  8. APPCONTENTS:=derived/openMSX_Catapult.app/Contents
  9. PY_DIR:=$(APPCONTENTS)/MacOS
  10. RES_DIR:=$(APPCONTENTS)/Resources
  11. else
  12. PYTHONBINPREFIX:=
  13. PY_DIR:=derived
  14. RES_DIR:=derived
  15. endif
  16. ICONS:=$(wildcard res/*.png) $(wildcard res/*.icns) $(wildcard res/*.ico)
  17. COPY_ICONS:=$(ICONS:res/%=$(RES_DIR)/%)
  18. SOURCES:=$(wildcard src/*.py)
  19. COPY_SRC:=$(SOURCES:src/%=$(PY_DIR)/%)
  20. UI_DESIGNS:=$(wildcard res/*.ui)
  21. UI_GEN_SRC:=$(UI_DESIGNS:res/%.ui=$(PY_DIR)/ui_%.py)
  22. DIST_FILES:=Makefile $(SOURCES) $(ICONS) $(UI_DESIGNS) win32exe.py
  23. CHANGELOG_REVISION=\
  24. $(shell sed -ne "s/\$$Id: ChangeLog \([^ ]*\).*/\1/p" ChangeLog)
  25. VERSION=prerelease-$(CHANGELOG_REVISION)
  26. # Default to build
  27. build:
  28. run: build
  29. ifeq ($(OS),Darwin)
  30. open derived/openMSX_Catapult.app
  31. else
  32. cd $(PY_DIR) && $(PYTHONBINPREFIX)python catapult.py
  33. endif
  34. #TODO make the *.db files dependend on *txt files and generate them
  35. # for now launch autorunfilldb.py manually
  36. dbfiles:
  37. cp tools/autorun.db $(PY_DIR)
  38. cp tools/softdb.db $(PY_DIR)
  39. cp tools/hwimages.db $(PY_DIR)
  40. runcd: build dbfiles
  41. ifeq ($(OS),Darwin)
  42. open derived/openMSX_Catapult.app --cd
  43. else
  44. cd $(PY_DIR) && $(PYTHONBINPREFIX)python catapult.py --cd
  45. endif
  46. build: $(COPY_SRC) $(COPY_ICONS) $(UI_GEN_SRC)
  47. $(COPY_SRC): $(PY_DIR)/%.py: src/%.py
  48. @mkdir -p $(@D)
  49. cp $< $@
  50. $(COPY_ICONS): $(RES_DIR)/%: res/%
  51. @mkdir -p $(@D)
  52. cp $< $@
  53. $(UI_GEN_SRC): $(PY_DIR)/ui_%.py: res/%.ui
  54. @mkdir -p $(@D)
  55. $(PYTHONBINPREFIX)pyuic4 $< -o $@
  56. ifeq ($(OS),Darwin)
  57. build: $(APPCONTENTS)/Info.plist $(APPCONTENTS)/PkgInfo $(APPCONTENTS)/MacOS/run.sh
  58. $(APPCONTENTS)/MacOS/run.sh: build/package-darwin/run.sh
  59. mkdir -p $(@D)
  60. cp $< $@
  61. $(APPCONTENTS)/Info.plist: build/package-darwin/Info.plist ChangeLog
  62. mkdir -p $(@D)
  63. sed -e 's/%VERSION%/$(VERSION)/' < $< > $@
  64. $(APPCONTENTS)/PkgInfo:
  65. mkdir -p $(@D)
  66. echo "APPLoMXC" > $@
  67. endif
  68. clean:
  69. rm -rf derived
  70. # Altough the generated sources are not checked, the modules that are checked
  71. # import them and those import statements are checked.
  72. lint: build
  73. cd src && PYTHONPATH=$(PYTHONPATH):../$(PY_DIR) pylint $(SOURCES:src/%.py=%.py)
  74. lintrun: build
  75. @echo "Checking modified sources with PyLint..."
  76. @MODIFIED=`svn st | sed -ne 's/[AM]..... src\/\(.*\.py\)$$/\1/p'` && \
  77. if [ -n "$$MODIFIED" ]; then \
  78. cd src && ! PYTHONPATH=$(PYTHONPATH):../$(PY_DIR) pylint --errors-only $$MODIFIED | grep .; \
  79. fi
  80. make run
  81. precommit: build
  82. @svn diff
  83. @MODIFIED=`svn st | sed -ne 's/[AM]..... src\/\(.*\.py\)$$/\1/p'` && \
  84. if [ -n "$$MODIFIED" ]; then \
  85. cd src && PYTHONPATH=$(PYTHONPATH):../$(PY_DIR) pylint -rn $$MODIFIED; \
  86. fi
  87. dist:
  88. zip catapult-$(VERSION).zip $(DIST_FILES)