Makefile
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:12k
源码类别:

通讯编程

开发平台:

Visual C++

  1. ########################################################################################################
  2. #
  3. # Makefile wrapper to build tk on Mac OS X in a way compatible with the tk/macosx Xcode buildsystem
  4. # uses the standard unix build system in tk/unix (which can be used directly instead of this
  5. # if you are not using the tk/macosx projects).
  6. #
  7. # Copyright (c) 2002-2007 Daniel A. Steffen <das@users.sourceforge.net>
  8. #
  9. # See the file "license.terms" for information on usage and redistribution of
  10. # this file, and for a DISCLAIMER OF ALL WARRANTIES.
  11. #
  12. # RCS: @(#) $Id: Makefile,v 1.7.2.17 2007/04/29 02:26:47 das Exp $
  13. #
  14. ########################################################################################################
  15. #-------------------------------------------------------------------------------------------------------
  16. # customizable settings
  17. DESTDIR ?=
  18. INSTALL_ROOT ?= ${DESTDIR}
  19. BUILD_DIR ?= ${CURDIR}/../../build
  20. SYMROOT ?= ${BUILD_DIR}/${PROJECT}
  21. OBJROOT ?= ${SYMROOT}
  22. EXTRA_CONFIGURE_ARGS ?=
  23. EXTRA_MAKE_ARGS ?=
  24. INSTALL_PATH ?= /Library/Frameworks
  25. APPLICATION_INSTALL_PATH ?= /Applications/Utilities
  26. PREFIX ?= /usr/local
  27. BINDIR ?= ${PREFIX}/bin
  28. LIBDIR ?= ${INSTALL_PATH}
  29. MANDIR ?= ${PREFIX}/man
  30. # tcl build directory (containing tclConfig.sh and Makefile)
  31. TCL_BUILD_DIR ?= ${BUILD_DIR}/tcl/${BUILD_STYLE}
  32. # location of installed tcl, only used if tcl in TCL_BUILD_DIR can't be found
  33. TCL_FRAMEWORK_DIR ?= /Library/Frameworks
  34. TCLSH_DIR ?= ${PREFIX}
  35. # set to non-empty value to install manpages in addition to html help:
  36. INSTALL_MANPAGES ?=
  37. # set to non-empty value to build TkX11 instead of TkAqua:
  38. TK_X11 ?=
  39. #-------------------------------------------------------------------------------------------------------
  40. # meta targets
  41. meta := all install embedded install-embedded clean distclean test
  42. styles := develop deploy
  43. all := ${styles}
  44. all : ${all}
  45. install := ${styles:%=install-%}
  46. install : ${install}
  47. install-%: action := install-
  48. embedded := ${styles:%=embedded-%}
  49. embedded : embedded-deploy
  50. install-embedded := ${embedded:%=install-%}
  51. install-embedded : install-embedded-deploy
  52. clean := ${styles:%=clean-%}
  53. clean : ${clean}
  54. clean-%: action := clean-
  55. distclean := ${styles:%=distclean-%}
  56. distclean : ${distclean}
  57. distclean-%: action := distclean-
  58. test := ${styles:%=test-%}
  59. test : ${test}
  60. test-%: action := test-
  61. targets := $(foreach v,${meta},${$v})
  62. #-------------------------------------------------------------------------------------------------------
  63. # build styles
  64. BUILD_STYLE =
  65. CONFIGURE_ARGS =
  66. OBJ_DIR = ${OBJROOT}/${BUILD_STYLE}
  67. develop_make_args := BUILD_STYLE=Development CONFIGURE_ARGS=--enable-symbols
  68. deploy_make_args := BUILD_STYLE=Deployment INSTALL_TARGET=install-strip
  69. embedded_make_args := EMBEDDED_BUILD=1
  70. install_make_args := INSTALL_BUILD=1
  71. ${targets}:
  72. ${MAKE} ${action}${PROJECT} 
  73. $(foreach s,${styles} embedded install,$(if $(findstring $s,$@),${${s}_make_args}))
  74. #-------------------------------------------------------------------------------------------------------
  75. # project specific settings
  76. PROJECT := tk
  77. PRODUCT_NAME := Tk
  78. UNIX_DIR := ${CURDIR}/../unix
  79. VERSION := $(shell awk -F= '/^TK_VERSION/ {print $$2; nextfile}' ${UNIX_DIR}/configure.in)
  80. TCL_VERSION := ${VERSION}
  81. wish := wish
  82. WISH = wish${VERSION}
  83. BUILD_TARGET := all tktest
  84. INSTALL_TARGET := install
  85. ifneq ($(wildcard ${TCL_BUILD_DIR}/tclConfig.sh),)
  86. TCL_DIR := ${TCL_BUILD_DIR}
  87. TCL_FRAMEWORK_DIR := ${TCL_BUILD_DIR}/..
  88. else
  89. TCL_DIR := ${TCL_FRAMEWORK_DIR}/Tcl.framework
  90. TCL_EXE := ${TCLSH_DIR}/tclsh${TCL_VERSION}
  91. MAKE_VARS = TCL_EXE
  92. export DYLD_FRAMEWORK_PATH := ${TCL_FRAMEWORK_DIR}
  93. endif
  94. export CPPROG := cp -p
  95. ifeq (${TK_X11},)
  96. override CONFIGURE_ARGS := ${CONFIGURE_ARGS} --enable-aqua
  97. else
  98. VERSION := ${VERSION}-X11
  99. wish := ${wish}-X11
  100. endif
  101. INSTALL_TARGETS = install-binaries install-libraries
  102. ifeq (${EMBEDDED_BUILD},)
  103. INSTALL_TARGETS += install-private-headers install-demos
  104. endif
  105. ifeq (${INSTALL_BUILD}_${EMBEDDED_BUILD}_${BUILD_STYLE},1__Deployment)
  106. INSTALL_TARGETS += html-tk
  107. ifneq (${INSTALL_MANPAGES},)
  108. INSTALL_TARGETS += install-doc
  109. endif
  110. endif
  111. MAKE_VARS += INSTALL_ROOT INSTALL_TARGETS VERSION
  112. MAKE_ARGS_V = $(foreach v,${MAKE_VARS},$v='${$v}')
  113. build-${PROJECT}: target = ${BUILD_TARGET}
  114. install-${PROJECT}: target = ${INSTALL_TARGET}
  115. clean-${PROJECT} distclean-${PROJECT} test-${PROJECT}: 
  116. target = $*
  117. DO_MAKE = +${MAKE} -C ${OBJ_DIR} ${target} ${MAKE_ARGS_V} ${MAKE_ARGS} ${EXTRA_MAKE_ARGS}
  118. #-------------------------------------------------------------------------------------------------------
  119. # locations for custom tk install actions
  120. ifeq (${INSTALL_BUILD},1)
  121. TOP_DIR := ${INSTALL_ROOT}/
  122. APP_DIR := ${APPLICATION_INSTALL_PATH}
  123. FMWK_DIR := ${LIBDIR}
  124. else
  125. TOP_DIR := ${SYMROOT}
  126. APP_DIR := .
  127. FMWK_DIR := .
  128. endif
  129. TCL_FMWK_DIR := ${FMWK_DIR}/Tcl.framework/Versions/${TCL_VERSION}
  130. TK_FMWK_DIR := ${FMWK_DIR}/${PRODUCT_NAME}.framework/Versions/${VERSION}
  131. #-------------------------------------------------------------------------------------------------------
  132. # build rules
  133. ${PROJECT}:
  134. ${MAKE} install-${PROJECT} INSTALL_ROOT=${OBJ_DIR}/
  135. ${OBJ_DIR}/Makefile: ${UNIX_DIR}/Makefile.in ${UNIX_DIR}/configure 
  136.      ${UNIX_DIR}/tkConfig.sh.in Tk-Info.plist.in Wish-Info.plist.in
  137. mkdir -p ${OBJ_DIR} && cd ${OBJ_DIR} && 
  138. if [ ${UNIX_DIR}/configure -nt config.status ]; then ${UNIX_DIR}/configure 
  139. --prefix=${PREFIX} --bindir=${BINDIR} --libdir=${LIBDIR} 
  140. --mandir=${MANDIR} --enable-threads --enable-framework 
  141. --with-tcl=${TCL_DIR} 
  142. ${CONFIGURE_ARGS} ${EXTRA_CONFIGURE_ARGS}; else ./config.status; fi
  143. ifneq (${TK_X11},)
  144. @cd ${OBJ_DIR} && sed -e 's#/Versions/${TCL_VERSION}#/Versions/${VERSION}#' 
  145. tkConfig.sh > tkConfig.sh.1 && mv -f tkConfig.sh.1 tkConfig.sh
  146. endif
  147. build-${PROJECT}: ${OBJ_DIR}/Makefile
  148. ${DO_MAKE}
  149. ifeq (${INSTALL_BUILD},)
  150. # symolic link hackery to trick
  151. # 'make install INSTALL_ROOT=${OBJ_DIR}'
  152. # into building Tk.framework and wish in ${SYMROOT}
  153. @cd ${OBJ_DIR} && mkdir -p $(dir ./${LIBDIR}) $(dir ./${BINDIR}) ${SYMROOT} && 
  154. rm -rf ./${LIBDIR} ./${BINDIR} && ln -fs ${SYMROOT} ./${LIBDIR} && 
  155. ln -fs ${SYMROOT} ./${BINDIR} && ln -fs ${OBJ_DIR}/tktest ${SYMROOT}
  156. ifeq (${TK_X11},)
  157. @rm -f ${OBJ_DIR}/${BINDIR} && 
  158. ln -fs Wish.app/Contents/MacOS/Wish ${SYMROOT}/${WISH}
  159. endif
  160. # Create symbolic link to Tcl.framework in ${SYMROOT}if necessary
  161. @cd ${SYMROOT} && if [ ! -e Tcl.framework -o -L Tcl.framework ]; then 
  162. rm -f Tcl.framework && ln -s ${TCL_FRAMEWORK_DIR}/Tcl.framework . ; fi
  163. endif
  164. install-${PROJECT}: build-${PROJECT}
  165. ifeq (${EMBEDDED_BUILD}_${INSTALL_ROOT},1_)
  166. @echo "Cannot install-embedded with empty INSTALL_ROOT !" && false
  167. endif
  168. ifeq (${EMBEDDED_BUILD},1)
  169. @rm -rf "${INSTALL_ROOT}/${LIBDIR}/Tk.framework"
  170. endif
  171. ${DO_MAKE}
  172. ifeq (${EMBEDDED_BUILD}_${TK_X11},1_)
  173. # workaround bug with 'cp -pRH' on Darwin 6 and earlier
  174. @if [ "`uname -r | awk -F. '{print $$1}'`" -lt 7 ]; then 
  175. mkdir -p ${TOP_DIR}/{"${TCL_FMWK_DIR}","${TK_FMWK_DIR}"}/PrivateHeaders; fi
  176. endif
  177. ifeq (${INSTALL_BUILD},1)
  178. ifeq (${EMBEDDED_BUILD},1)
  179. # if we are embedding frameworks, don't install wish
  180. @rm -f "${INSTALL_ROOT}${BINDIR}/${WISH}" && 
  181. rmdir -p "${INSTALL_ROOT}${BINDIR}" 2>&- || true
  182. else
  183. # redo prebinding (when not building for Mac OS X 10.4 or later only)
  184. @if [ "`echo "$${MACOSX_DEPLOYMENT_TARGET}" | 
  185. awk -F '10\.' '{print int($$2)}'`" -lt 4 -a "`echo "$${CFLAGS}" | 
  186. awk -F '-mmacosx-version-min=10\.' '{print int($$2)}'`" -lt 4 ]; 
  187. then cd ${INSTALL_ROOT}/; 
  188. if [ ! -d usr/lib ]; then mkdir -p usr && ln -fs /usr/lib usr/ && RM_USRLIB=1; fi; 
  189. if [ -n "${TK_X11}" -a ! -d usr/X11R6 ]; then mkdir -p usr && ln -fs /usr/X11R6 usr/ && RM_USRX11=1; fi; 
  190. if [ ! -d System ]; then ln -fs /System . && RM_SYSTEM=1; fi; 
  191. if [ ! -d ./${LIBDIR}/Tcl.framework ]; then ln -fs ${TCL_FRAMEWORK_DIR}/Tcl.framework ./${LIBDIR}; RM_TCL=1; fi; 
  192. redo_prebinding -r . "./${TK_FMWK_DIR}/${PRODUCT_NAME}"; 
  193. if [ -z "${TK_X11}" ]; then redo_prebinding -r . "./${TK_FMWK_DIR}/Resources/Wish.app/Contents/MacOS/Wish"; 
  194. else redo_prebinding -r . "./${BINDIR}/${WISH}"; fi; 
  195. if [ -n "$${RM_USRLIB:-}" ]; then rm -f usr/lib; rmdir -p usr 2>&-; fi; 
  196. if [ -n "$${RM_USRX11:-}" ]; then rm -f usr/X11R6; rmdir -p usr 2>&-; fi; 
  197. if [ -n "$${RM_SYSTEM:-}" ]; then rm -f System; fi; 
  198. if [ -n "$${RM_TCL:-}" ]; then rm -f ./${LIBDIR}/Tcl.framework; fi; fi
  199. # install wish symbolic link
  200. @ln -fs ${WISH} ${INSTALL_ROOT}${BINDIR}/${wish}
  201. endif
  202. endif
  203. ifeq (${BUILD_STYLE}_${EMBEDDED_BUILD},Development_)
  204. # keep copy of debug library around, so that
  205. # Deployment build can be installed on top
  206. # of Development build without overwriting
  207. # the debug library
  208. @cd ${INSTALL_ROOT}${LIBDIR}/${PRODUCT_NAME}.framework/Versions/${VERSION} && 
  209. ln -f "${PRODUCT_NAME}" "${PRODUCT_NAME}_debug"
  210. endif
  211. ifeq (${TK_X11},)
  212. ifeq (${EMBEDDED_BUILD},)
  213. # install Wish.app link in APPLICATION_INSTALL_PATH and setup 'Wish Shell' compatibility links
  214. @cd ${TOP_DIR} && if [ -n "${APP_DIR}" ]; then mkdir -p "./${APP_DIR}" && rm -rf "./${APP_DIR}/Wish.app" && 
  215. ln -fsh "./$$(echo ${APP_DIR} | sed -e 's#/[^/][^/]*#/..#g')/${FMWK_DIR}/${PRODUCT_NAME}.framework/Resources/Wish.app" "./${APP_DIR}" && 
  216. ln -fsh Wish.app "./${APP_DIR}/Wish Shell.app"; fi && 
  217. ln -fsh Wish.app "./${TK_FMWK_DIR}/Resources/Wish Shell.app" && 
  218. ln -fsh Wish "./${TK_FMWK_DIR}/Resources/Wish.app/Contents/MacOS/Wish Shell"
  219. else
  220. # if we are embedding frameworks, move them into the app and fix their install names
  221. @cd ${TOP_DIR} && 
  222. rm -rf "./${APP_DIR}/Wish.app" && mkdir -p "./${APP_DIR}" && 
  223. mv -f "./${TK_FMWK_DIR}/Resources/Wish.app" "./${APP_DIR}" && 
  224. ln -fsh Wish.app "./${APP_DIR}/Wish Shell.app" && 
  225. rm -rf "./${APP_DIR}/Wish.app/Contents/Frameworks" && 
  226. mkdir -p "./${APP_DIR}/Wish.app/Contents/Frameworks" && 
  227. ${CPPROG} -RH "./${FMWK_DIR}"/T{cl,k}.framework "./${APP_DIR}/Wish.app/Contents/Frameworks" && 
  228. cd "./${APP_DIR}/Wish.app/Contents" && 
  229. rm -rf Frameworks/Tcl.framework/{,/Versions/$(TCL_VERSION)}/{Headers,PrivateHeaders,*_debug,lib*.a,*Config.sh} && 
  230. rm -rf Frameworks/Tk.framework/{,/Versions/$(VERSION)}/{Headers,PrivateHeaders,*_debug,lib*.a,*Config.sh} && 
  231. fix_install_id ( ) { 
  232.     chmod -RH a+w "$$1"; 
  233.     install_name_tool -id $$(otool -L "$$1" | awk "/$$2.framework.*[^:]$$/ {sub("^.*/Frameworks","@executable_path/../Frameworks",$$1); print $$1}") "$$1"; 
  234.     chmod -RH a-w "$$1"; 
  235. } && 
  236. fix_install_name ( ) { 
  237.     chmod -RH a+w "$$1"; 
  238.     install_name_tool -change $$(otool -L "$$1" | awk "/$$2.framework.*[^:]$$/ {print $$1; sub("^.*/Frameworks","@executable_path/../Frameworks",$$1); print $$1}") "$$1"; 
  239.     chmod -RH a-w "$$1"; 
  240. } && 
  241. fix_install_id Frameworks/Tcl.framework/Tcl Tcl && fix_install_id Frameworks/Tk.framework/Tk Tk && 
  242. fix_install_name MacOS/Wish Tcl && fix_install_name MacOS/Wish Tk
  243. ifeq (${INSTALL_BUILD},1)
  244. @cd ${TOP_DIR} && rm -rf "./${FMWK_DIR}"/T{cl,k}.framework && rmdir -p "./${FMWK_DIR}" 2>&- || true
  245. endif
  246. endif
  247. endif
  248. clean-${PROJECT}: %-${PROJECT}:
  249. ${DO_MAKE}
  250. rm -rf ${SYMROOT}/{${PRODUCT_NAME}.framework,${WISH},tktest}
  251. rm -f ${OBJ_DIR}{${LIBDIR},${BINDIR}} && 
  252. rmdir -p ${OBJ_DIR}$(dir ${LIBDIR}) 2>&- || true && 
  253. rmdir -p ${OBJ_DIR}$(dir ${BINDIR}) 2>&- || true
  254. distclean-${PROJECT}: %-${PROJECT}: clean-${PROJECT}
  255. ${DO_MAKE}
  256. rm -rf ${OBJ_DIR}
  257. test-${PROJECT}: %-${PROJECT}: build-${PROJECT}
  258. ${DO_MAKE}
  259. #-------------------------------------------------------------------------------------------------------
  260. .PHONY: ${meta} ${targets} ${PROJECT} build-${PROJECT} install-${PROJECT} 
  261. clean-${PROJECT} distclean-${PROJECT}
  262. .NOTPARALLEL:
  263. #-------------------------------------------------------------------------------------------------------