1 | ######################################################################################################## |
---|
2 | # |
---|
3 | # Makefile wrapper to build tcl on Mac OS X in a way compatible with the tk/macosx Xcode buildsystem |
---|
4 | # uses the standard unix build system in tcl/unix (which can be used directly instead of this |
---|
5 | # if you are not using the tk/macosx projects). |
---|
6 | # |
---|
7 | # Copyright (c) 2002-2008 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: GNUmakefile,v 1.9 2008/03/11 22:28:34 das Exp $ |
---|
13 | # |
---|
14 | ######################################################################################################## |
---|
15 | |
---|
16 | #------------------------------------------------------------------------------------------------------- |
---|
17 | # customizable settings |
---|
18 | |
---|
19 | DESTDIR ?= |
---|
20 | INSTALL_ROOT ?= ${DESTDIR} |
---|
21 | |
---|
22 | BUILD_DIR ?= ${CURDIR}/../../build |
---|
23 | SYMROOT ?= ${BUILD_DIR}/${PROJECT} |
---|
24 | OBJROOT ?= ${SYMROOT} |
---|
25 | |
---|
26 | EXTRA_CONFIGURE_ARGS ?= |
---|
27 | EXTRA_MAKE_ARGS ?= |
---|
28 | |
---|
29 | INSTALL_PATH ?= /Library/Frameworks |
---|
30 | PREFIX ?= /usr/local |
---|
31 | BINDIR ?= ${PREFIX}/bin |
---|
32 | LIBDIR ?= ${INSTALL_PATH} |
---|
33 | MANDIR ?= ${PREFIX}/man |
---|
34 | |
---|
35 | # set to non-empty value to install manpages in addition to html help: |
---|
36 | INSTALL_MANPAGES ?= |
---|
37 | |
---|
38 | #------------------------------------------------------------------------------------------------------- |
---|
39 | # meta targets |
---|
40 | |
---|
41 | meta := all install embedded install-embedded clean distclean test |
---|
42 | |
---|
43 | styles := develop deploy |
---|
44 | |
---|
45 | all := ${styles} |
---|
46 | all : ${all} |
---|
47 | |
---|
48 | install := ${styles:%=install-%} |
---|
49 | install : ${install} |
---|
50 | install-%: action := install- |
---|
51 | |
---|
52 | embedded := ${styles:%=embedded-%} |
---|
53 | embedded : embedded-deploy |
---|
54 | install-embedded := ${embedded:%=install-%} |
---|
55 | install-embedded : install-embedded-deploy |
---|
56 | |
---|
57 | clean := ${styles:%=clean-%} |
---|
58 | clean : ${clean} |
---|
59 | clean-%: action := clean- |
---|
60 | distclean := ${styles:%=distclean-%} |
---|
61 | distclean : ${distclean} |
---|
62 | distclean-%: action := distclean- |
---|
63 | |
---|
64 | test := ${styles:%=test-%} |
---|
65 | test : ${test} |
---|
66 | test-%: action := test- |
---|
67 | |
---|
68 | targets := $(foreach v,${meta},${$v}) |
---|
69 | |
---|
70 | #------------------------------------------------------------------------------------------------------- |
---|
71 | # build styles |
---|
72 | |
---|
73 | BUILD_STYLE = |
---|
74 | CONFIGURE_ARGS = |
---|
75 | OBJ_DIR = ${OBJROOT}/${BUILD_STYLE} |
---|
76 | |
---|
77 | empty := |
---|
78 | space := ${empty} ${empty} |
---|
79 | objdir := $(subst ${space},\ ,${OBJ_DIR}) |
---|
80 | |
---|
81 | develop_make_args := BUILD_STYLE=Development CONFIGURE_ARGS=--enable-symbols |
---|
82 | deploy_make_args := BUILD_STYLE=Deployment INSTALL_TARGET=install-strip \ |
---|
83 | EXTRA_CFLAGS=-DNDEBUG |
---|
84 | embedded_make_args := EMBEDDED_BUILD=1 |
---|
85 | install_make_args := INSTALL_BUILD=1 |
---|
86 | |
---|
87 | ${targets}: |
---|
88 | ${MAKE} ${action}${PROJECT} \ |
---|
89 | $(foreach s,${styles} embedded install,$(if $(findstring $s,$@),${${s}_make_args})) |
---|
90 | |
---|
91 | #------------------------------------------------------------------------------------------------------- |
---|
92 | # project specific settings |
---|
93 | |
---|
94 | PROJECT := tcl |
---|
95 | PRODUCT_NAME := Tcl |
---|
96 | |
---|
97 | UNIX_DIR := ${CURDIR}/../unix |
---|
98 | VERSION := $(shell awk -F= '/^TCL_VERSION/ {print $$2; nextfile}' ${UNIX_DIR}/configure.in) |
---|
99 | TCLSH := tclsh${VERSION} |
---|
100 | |
---|
101 | BUILD_TARGET := all tcltest |
---|
102 | INSTALL_TARGET := install |
---|
103 | |
---|
104 | export CPPROG := cp -p |
---|
105 | |
---|
106 | INSTALL_TARGETS = install-binaries install-libraries |
---|
107 | ifeq (${EMBEDDED_BUILD},) |
---|
108 | INSTALL_TARGETS += install-private-headers |
---|
109 | endif |
---|
110 | ifeq (${INSTALL_BUILD}_${EMBEDDED_BUILD}_${BUILD_STYLE},1__Deployment) |
---|
111 | INSTALL_TARGETS += html-tcl |
---|
112 | ifneq (${INSTALL_MANPAGES},) |
---|
113 | INSTALL_TARGETS += install-doc |
---|
114 | endif |
---|
115 | endif |
---|
116 | |
---|
117 | MAKE_VARS := INSTALL_ROOT INSTALL_TARGETS VERSION GENERIC_FLAGS |
---|
118 | MAKE_ARGS_V = $(foreach v,${MAKE_VARS},$v='${$v}') |
---|
119 | |
---|
120 | build-${PROJECT}: target = ${BUILD_TARGET} |
---|
121 | install-${PROJECT}: target = ${INSTALL_TARGET} |
---|
122 | clean-${PROJECT} distclean-${PROJECT} test-${PROJECT}: \ |
---|
123 | target = $* |
---|
124 | |
---|
125 | DO_MAKE = +${MAKE} -C "${OBJ_DIR}" ${target} ${MAKE_ARGS_V} ${MAKE_ARGS} ${EXTRA_MAKE_ARGS} |
---|
126 | |
---|
127 | #------------------------------------------------------------------------------------------------------- |
---|
128 | # build rules |
---|
129 | |
---|
130 | ${PROJECT}: |
---|
131 | ${MAKE} install-${PROJECT} INSTALL_ROOT="${OBJ_DIR}/" |
---|
132 | |
---|
133 | ${objdir}/Makefile: ${UNIX_DIR}/Makefile.in ${UNIX_DIR}/configure \ |
---|
134 | ${UNIX_DIR}/tclConfig.sh.in Tcl-Info.plist.in |
---|
135 | mkdir -p "${OBJ_DIR}" && cd "${OBJ_DIR}" && \ |
---|
136 | if [ ${UNIX_DIR}/configure -nt config.status ]; then ${UNIX_DIR}/configure -C \ |
---|
137 | --prefix="${PREFIX}" --bindir="${BINDIR}" --libdir="${LIBDIR}" \ |
---|
138 | --mandir="${MANDIR}" --enable-threads --enable-framework --enable-dtrace \ |
---|
139 | ${CONFIGURE_ARGS} ${EXTRA_CONFIGURE_ARGS}; else ./config.status; fi |
---|
140 | |
---|
141 | build-${PROJECT}: ${objdir}/Makefile |
---|
142 | ${DO_MAKE} |
---|
143 | ifeq (${INSTALL_BUILD},) |
---|
144 | # symolic link hackery to trick |
---|
145 | # 'make install INSTALL_ROOT=${OBJ_DIR}' |
---|
146 | # into building Tcl.framework and tclsh in ${SYMROOT} |
---|
147 | @cd "${OBJ_DIR}" && mkdir -p $(dir $(subst ${space},\ ,./${LIBDIR})) $(dir $(subst ${space},\ ,./${BINDIR})) "${SYMROOT}" && \ |
---|
148 | rm -f "./${LIBDIR}" "./${BINDIR}" && ln -fs "${SYMROOT}" "./${LIBDIR}" && \ |
---|
149 | ln -fs "${SYMROOT}" "./${BINDIR}" && ln -fs "${OBJ_DIR}/tcltest" "${SYMROOT}" |
---|
150 | endif |
---|
151 | |
---|
152 | install-${PROJECT}: build-${PROJECT} |
---|
153 | ifeq (${EMBEDDED_BUILD}_${INSTALL_ROOT},1_) |
---|
154 | @echo "Cannot install-embedded with empty INSTALL_ROOT !" && false |
---|
155 | endif |
---|
156 | ifeq (${EMBEDDED_BUILD},1) |
---|
157 | @rm -rf "${INSTALL_ROOT}/${LIBDIR}/Tcl.framework" |
---|
158 | endif |
---|
159 | ${DO_MAKE} |
---|
160 | ifeq (${INSTALL_BUILD},1) |
---|
161 | ifeq (${EMBEDDED_BUILD},1) |
---|
162 | # if we are embedding frameworks, don't install tclsh |
---|
163 | @rm -f "${INSTALL_ROOT}${BINDIR}/${TCLSH}" && \ |
---|
164 | rmdir -p "${INSTALL_ROOT}${BINDIR}" 2>&- || true |
---|
165 | else |
---|
166 | # redo prebinding (when not building for Mac OS X 10.4 or later only) |
---|
167 | @if [ "`echo "$${MACOSX_DEPLOYMENT_TARGET}" | \ |
---|
168 | awk -F '10\\.' '{print int($$2)}'`" -lt 4 -a "`echo "$${CFLAGS}" | \ |
---|
169 | awk -F '-mmacosx-version-min=10\\.' '{print int($$2)}'`" -lt 4 ]; \ |
---|
170 | then cd ${INSTALL_ROOT}/; \ |
---|
171 | if [ ! -d usr/lib ]; then mkdir -p usr && ln -fs /usr/lib usr/ && RM_USRLIB=1; fi; \ |
---|
172 | if [ ! -d System ]; then ln -fs /System . && RM_SYSTEM=1; fi; \ |
---|
173 | redo_prebinding -r . "./${LIBDIR}/${PRODUCT_NAME}.framework/Versions/${VERSION}/${PRODUCT_NAME}"; \ |
---|
174 | redo_prebinding -r . "./${BINDIR}/${TCLSH}"; \ |
---|
175 | if [ -n "$${RM_USRLIB:-}" ]; then rm -f usr/lib; rmdir -p usr 2>&-; fi; \ |
---|
176 | if [ -n "$${RM_SYSTEM:-}" ]; then rm -f System; fi; fi |
---|
177 | # install tclsh symbolic link |
---|
178 | @ln -fs ${TCLSH} "${INSTALL_ROOT}${BINDIR}/tclsh" |
---|
179 | endif |
---|
180 | endif |
---|
181 | ifeq (${BUILD_STYLE}_${EMBEDDED_BUILD},Development_) |
---|
182 | # keep copy of debug library around, so that |
---|
183 | # Deployment build can be installed on top |
---|
184 | # of Development build without overwriting |
---|
185 | # the debug library |
---|
186 | @cd "${INSTALL_ROOT}${LIBDIR}/${PRODUCT_NAME}.framework/Versions/${VERSION}" && \ |
---|
187 | ln -f "${PRODUCT_NAME}" "${PRODUCT_NAME}_debug" |
---|
188 | endif |
---|
189 | |
---|
190 | clean-${PROJECT}: %-${PROJECT}: |
---|
191 | ${DO_MAKE} |
---|
192 | rm -rf "${SYMROOT}"/{${PRODUCT_NAME}.framework,${TCLSH},tcltest} |
---|
193 | rm -f "${OBJ_DIR}"{"${LIBDIR}","${BINDIR}"} && \ |
---|
194 | rmdir -p "${OBJ_DIR}"$(dir $(subst ${space},\ ,${LIBDIR})) 2>&- || true && \ |
---|
195 | rmdir -p "${OBJ_DIR}"$(dir $(subst ${space},\ ,${BINDIR})) 2>&- || true |
---|
196 | |
---|
197 | distclean-${PROJECT}: %-${PROJECT}: clean-${PROJECT} |
---|
198 | ${DO_MAKE} |
---|
199 | rm -rf "${OBJ_DIR}" |
---|
200 | |
---|
201 | test-${PROJECT}: %-${PROJECT}: build-${PROJECT} |
---|
202 | ${DO_MAKE} |
---|
203 | |
---|
204 | #------------------------------------------------------------------------------------------------------- |
---|
205 | |
---|
206 | .PHONY: ${meta} ${targets} ${PROJECT} build-${PROJECT} install-${PROJECT} \ |
---|
207 | clean-${PROJECT} distclean-${PROJECT} |
---|
208 | |
---|
209 | .NOTPARALLEL: |
---|
210 | |
---|
211 | #------------------------------------------------------------------------------------------------------- |
---|