Install.make 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. # This should be "include"d from the top-level Makefile, and nowhere else
  2. BIN_DIST_FILES = $(FILES) \
  3. $(GRASS_NAME).tmp \
  4. bin \
  5. demolocation \
  6. docs \
  7. driver \
  8. etc \
  9. fonts \
  10. gui \
  11. include \
  12. lib \
  13. locale \
  14. scripts \
  15. utils \
  16. share
  17. # Shell commands
  18. MAKE_DIR_CMD = $(MKDIR) -m 755
  19. strip: strip-check
  20. find $(ARCH_DISTDIR) -type f -perm +111 -print0 | xargs -0 strip
  21. strip-check:
  22. @ if [ ! -f "$(ARCH_BINDIR)/$(GRASS_NAME)" ] ; then \
  23. echo "ERROR: GRASS has not been compiled. Try \"make\" first." >&2 ; \
  24. echo " Strip aborted, exiting Make." >&2 ; \
  25. exit 1; \
  26. fi
  27. install:
  28. @ echo $(ARCH_BINDIR)/$(GRASS_NAME)
  29. $(MAKE) install-check-built
  30. ifeq ($(strip $(MACOSX_APP)),1)
  31. $(MAKE) install-macosx
  32. else
  33. $(MAKE) install-check-parent
  34. $(MAKE) install-check-writable
  35. $(MAKE) install-check-prefix
  36. $(MAKE) real-install
  37. endif
  38. install-check-built:
  39. @ if [ ! -f "$(ARCH_BINDIR)/$(GRASS_NAME)" ] ; then \
  40. echo "ERROR: GRASS has not been compiled. Try \"make\" first."; \
  41. echo " Installation aborted, exiting Make."; \
  42. exit; \
  43. fi
  44. install-check-parent: | $(DESTDIR)
  45. @ INST_PATH=`dirname $(DESTDIR)$(INST_DIR)`; \
  46. while [ ! -d "$(DESTDIR)$$INST_PATH" ]; do \
  47. INST_PATH=`dirname $$INST_PATH`; \
  48. done; \
  49. if [ ! -d "$(DESTDIR)$(INST_DIR)" -a ! -w "$(DESTDIR)$$INST_PATH" ] ; then \
  50. echo "ERROR: Directory $$INST_PATH is a parent directory of your" >&2 ; \
  51. echo " install directory $(INST_DIR) and is not writable." >&2 ; \
  52. echo " Perhaps you need root access." >&2 ; \
  53. echo " Installation aborted, exiting Make." >&2 ; \
  54. exit 1; \
  55. fi
  56. install-check-writable:
  57. @ if [ -d "$(DESTDIR)$(INST_DIR)" -a ! -w "$(DESTDIR)$(INST_DIR)" ] ; then \
  58. echo "ERROR: Your install directory $(INST_DIR) is not writable." >&2 ; \
  59. echo " Perhaps you need root access." >&2 ; \
  60. echo " Installation aborted, exiting Make." >&2 ; \
  61. exit 1; \
  62. fi
  63. install-check-prefix:
  64. @ result=`echo "$(DESTDIR)$(INST_DIR)" | awk '{ if (tolower($$1) ~ /grass/) print $$1 }'`; \
  65. if [ "$$result" = "" ] ; then \
  66. echo "WARNING: Your install directory $(INST_DIR)" >&2 ; \
  67. echo " does not contain the word 'grass'." >&2 ; \
  68. echo " It is highly recommended that the word 'grass' be part" >&2 ; \
  69. echo " of your install directory to avoid conflicts." >&2 ; \
  70. echo " Do you want to continue? [y/n]" >&2 ; \
  71. read ans; \
  72. if [ "$$ans" != "y" -a "$$ans" != "Y" ] ; then \
  73. echo "Installation aborted, exiting Make." >&2 ; \
  74. exit 1; \
  75. fi; \
  76. fi
  77. ifneq ($(strip $(MINGW)),)
  78. STARTUP = $(INST_DIR)/etc/$(GRASS_NAME).py
  79. else
  80. STARTUP = $(DESTDIR)$(UNIX_BIN)/$(GRASS_NAME)
  81. endif
  82. FONTCAP = etc/fontcap
  83. TMPGISRC = demolocation/.grassrc$(GRASS_VERSION_MAJOR)$(GRASS_VERSION_MINOR)
  84. PLATMAKE = include/Make/Platform.make
  85. GRASSMAKE = include/Make/Grass.make
  86. real-install: | $(DESTDIR) $(DESTDIR)$(INST_DIR) $(DESTDIR)$(UNIX_BIN)
  87. -tar cBCf $(GISBASE) - . | tar xBCf $(DESTDIR)$(INST_DIR) - 2>/dev/null
  88. -rm $(DESTDIR)$(INST_DIR)/$(GRASS_NAME).tmp
  89. $(MAKE) $(STARTUP)
  90. -rm $(DESTDIR)$(INST_DIR)/$(FONTCAP)
  91. $(MAKE) $(DESTDIR)$(INST_DIR)/$(FONTCAP)
  92. -rm $(DESTDIR)$(INST_DIR)/$(TMPGISRC)
  93. $(MAKE) $(DESTDIR)$(INST_DIR)/$(TMPGISRC)
  94. -rm $(DESTDIR)$(INST_DIR)/$(PLATMAKE)
  95. $(MAKE) $(DESTDIR)$(INST_DIR)/$(PLATMAKE)
  96. -rm $(DESTDIR)$(INST_DIR)/$(GRASSMAKE)
  97. $(MAKE) $(DESTDIR)$(INST_DIR)/$(GRASSMAKE)
  98. -$(CHMOD) -R a+rX $(DESTDIR)$(INST_DIR) 2>/dev/null
  99. $(DESTDIR):
  100. $(MAKE_DIR_CMD) -p $@
  101. $(DESTDIR)$(INST_DIR) $(DESTDIR)$(UNIX_BIN):
  102. $(MAKE_DIR_CMD) $@
  103. $(STARTUP): $(ARCH_DISTDIR)/$(GRASS_NAME).tmp
  104. sed -e 's#'@GISBASE@'#'$(INST_DIR)'#g' \
  105. -e 's#'@LD_LIBRARY_PATH_VAR@'#'$(LD_LIBRARY_PATH_VAR)'#g' \
  106. -e 's#'@CONFIG_PROJSHARE@'#'$(PROJSHARE)'#g' \
  107. $< > $@
  108. -$(CHMOD) a+x $@
  109. define fix_gisbase
  110. sed -e 's#$(GISBASE)#$(INST_DIR)#g' $< > $@
  111. endef
  112. define fix_grass_home
  113. sed -e 's#^\(GRASS_HOME.[^=]*\).*#\1= $(INST_DIR)#g' \
  114. -e 's#$(GISBASE)#$(INST_DIR)#g' $< > $@
  115. endef
  116. define fix_grass_arch
  117. sed -e 's#^\(ARCH_DISTDIR.[^=]*\).*#\1= $(INST_DIR)#g' \
  118. -e 's#^\(ARCH_BINDIR.[^=]*\).*#\1= $(UNIX_BIN)#g' $< > $@
  119. endef
  120. $(DESTDIR)$(INST_DIR)/$(FONTCAP): $(GISBASE)/$(FONTCAP)
  121. $(call fix_gisbase)
  122. $(DESTDIR)$(INST_DIR)/$(TMPGISRC): $(GISBASE)/$(TMPGISRC)
  123. $(call fix_gisbase)
  124. $(DESTDIR)$(INST_DIR)/$(PLATMAKE): $(GISBASE)/$(PLATMAKE)
  125. $(call fix_grass_home)
  126. $(DESTDIR)$(INST_DIR)/$(GRASSMAKE): $(GISBASE)/$(GRASSMAKE)
  127. $(call fix_grass_arch)
  128. install-macosx:
  129. $(MAKE) -C macosx install-macosx
  130. install-strip:
  131. $(MAKE) strip
  132. $(MAKE) install
  133. bindist:
  134. ifeq ($(strip $(MACOSX_APP)),1)
  135. $(MAKE) bindist-macosx
  136. else
  137. $(MAKE) real-bindist
  138. endif
  139. BINDISTNAME = grass-$(GRASS_VERSION_NUMBER)-$(ARCH)-$(DATE)
  140. real-bindist:
  141. -tar cCBf $(ARCH_DISTDIR) - $(BIN_DIST_FILES) | gzip -fc > $(BINDISTNAME).tar.gz
  142. -size=`ls -l $(BINDISTNAME).tar.gz | awk '{print $$5}'`; \
  143. sed -e "s/BIN_DIST_VERSION/$(GRASS_VERSION_NUMBER)-$(ARCH)-$(DATE)/" \
  144. -e "s/GRASSPRG_NAME/$(GRASS_NAME)/" \
  145. -e "s/SIZE_TAR_FILE/$$size/" -e "s#BIN_DIST_DIR#'$(INST_DIR)'#" \
  146. -e "s/ARCHITECTURE/$(ARCH)/" \
  147. -e "s/LD_LIBRARY_PATH_VAR/$(LD_LIBRARY_PATH_VAR)/" \
  148. -e "s/TEST_STR=/TEST_STR=executable/" \
  149. -e "s#IMPORTANT.*#Generated from the binaryInstall.src file using the command make bindist#" \
  150. -e "s/# executable shell.*//" -e "s/# make bindist.*//" \
  151. binaryInstall.src > $(BINDISTNAME)-install.sh ; \
  152. chmod a+x $(BINDISTNAME)-install.sh 2>/dev/null
  153. bindist-macosx:
  154. $(MAKE) -C macosx bindist-macosx
  155. # make a source package for distribution:
  156. srcdist: distclean
  157. -$(MAKE_DIR_CMD) ./grass-$(GRASS_VERSION_NUMBER)
  158. @ # needed to store code in package with grass-version path:
  159. -mv * ./grass-$(GRASS_VERSION_NUMBER)
  160. @ # do not include the debian control files:
  161. -mv ./grass-$(GRASS_VERSION_NUMBER)/debian .
  162. @ #we use -h to get the linked files into as real files:
  163. tar cvfzh grass-$(GRASS_VERSION_NUMBER).tar.gz ./grass-$(GRASS_VERSION_NUMBER)/* --exclude=.git
  164. @ # restore src code location:
  165. -mv ./grass-$(GRASS_VERSION_NUMBER)/* .
  166. -rmdir ./grass-$(GRASS_VERSION_NUMBER)
  167. @ echo "Distribution source package: grass-$(GRASS_VERSION_NUMBER).tar.gz ready. Calculating MD5 sum..."
  168. md5sum grass-$(GRASS_VERSION_NUMBER).tar.gz > grass-$(GRASS_VERSION_NUMBER).md5sum
  169. # make a source package for library distribution:
  170. srclibsdist: distclean
  171. -$(MAKE_DIR_CMD) ./grass-lib-$(GRASS_VERSION_NUMBER)
  172. @ # needed to store code in package with grass-version path:
  173. -cp -L * ./grass-lib-$(GRASS_VERSION_NUMBER)
  174. -cp -rL utils ./grass-lib-$(GRASS_VERSION_NUMBER)
  175. -cp -rL demolocation ./grass-lib-$(GRASS_VERSION_NUMBER)
  176. -cp -rL include ./grass-lib-$(GRASS_VERSION_NUMBER)
  177. -cp -rL --parents lib/external/shapelib ./grass-lib-$(GRASS_VERSION_NUMBER)
  178. -cp -rL --parents lib/external/bwidget ./grass-lib-$(GRASS_VERSION_NUMBER)
  179. -cp -rL --parents lib/datetime ./grass-lib-$(GRASS_VERSION_NUMBER)
  180. -cp -rL --parents lib/db ./grass-lib-$(GRASS_VERSION_NUMBER)
  181. -cp -rL --parents lib/gis ./grass-lib-$(GRASS_VERSION_NUMBER)
  182. -cp -rL --parents lib/linkm ./grass-lib-$(GRASS_VERSION_NUMBER)
  183. -cp -rL --parents lib/form ./grass-lib-$(GRASS_VERSION_NUMBER)
  184. -cp -rL --parents lib/vector ./grass-lib-$(GRASS_VERSION_NUMBER)
  185. -cp -rL --parents db/drivers ./grass-lib-$(GRASS_VERSION_NUMBER)
  186. tar chvfz grass-lib-$(GRASS_VERSION_NUMBER).tar.gz ./grass-lib-$(GRASS_VERSION_NUMBER)/* --exclude=CVS
  187. -rm -r ./grass-lib-$(GRASS_VERSION_NUMBER)
  188. @ echo "Distribution source package: grass-lib-$(GRASS_VERSION_NUMBER).tar.gz ready."
  189. .PHONY: strip strip-check
  190. .PHONY: install-check-built install-check-parent install-check-writable install-check-prefix
  191. .PHONY: install real-install install-strip install-macosx
  192. .PHONY: bindist real-bindist bindist-macosx srcdist srclibsdist