summaryrefslogtreecommitdiffstats
path: root/make
diff options
context:
space:
mode:
authorkonablend <[email protected]>2009-03-03 02:49:54 +0000
committerkonablend <[email protected]>2009-03-03 02:49:54 +0000
commit55afb374694267dd7209afd2ec279e8f51154bcf (patch)
tree8d56c354b0998d39fc0c992b1abd24753a4c46eb /make
parent0a6c39fcd2f352d0413298274efab13056fd429a (diff)
BuildSystem:
- fixed OSX + Xcode to support parallel builds - enhanced OSX + Xcode to use proper pass-thru for all make targets - added global target --> install - added install: test.install - added install: gtk.install - updated pre-generated building guides (these will go away when wiki is updated) - updated xml2wiki script to spit out heading git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2205 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'make')
-rw-r--r--make/configure.py36
-rw-r--r--make/include/base.defs19
-rw-r--r--make/include/base.rules16
-rw-r--r--make/include/main.defs8
-rw-r--r--make/include/main.rules16
-rw-r--r--make/xcodemake.sh75
6 files changed, 136 insertions, 34 deletions
diff --git a/make/configure.py b/make/configure.py
index ace634d9f..839077a45 100644
--- a/make/configure.py
+++ b/make/configure.py
@@ -55,7 +55,7 @@ def findExecutable( name ):
###############################################################################
-def computeDefaultMakeJobs():
+def computeNumCPU():
## good for darwin9.6.0 and linux
try:
n = os.sysconf( 'SC_NPROCESSORS_ONLN' )
@@ -103,6 +103,7 @@ for i in range( 2 ):
project_dir = os.path.dirname( project_dir )
if len( project_dir ) == 0:
project_dir = os.curdir
+initial_project_dir = project_dir
###############################################################################
@@ -304,6 +305,10 @@ else:
## create parser
parser = OptionParser( 'Usage: %prog' )
+## add hidden options
+parser.add_option( '', '--conf-method', default='terminal', action='store', help=optparse.SUPPRESS_HELP )
+
+## add install options
group = OptionGroup( parser, 'Installation Options' )
group.add_option( '', '--prefix', default=d_prefix, action='store',
help='specify destination for final products (%s)' % (d_prefix) )
@@ -348,7 +353,13 @@ for tool in tools.items:
tool.addToGroup( group )
parser.add_option_group( group )
-(options, args) = parser.parse_args()
+(options,args) = parser.parse_args()
+
+exports = []
+for arg in args:
+ m = re.match( '([^=]+)=(.*)', arg )
+ if m:
+ exports.append( m.groups() )
## recompute values when launch mode
if options.launch:
@@ -359,7 +370,7 @@ if options.launch:
else:
project_dir = os.path.normpath( relpath( project_dir, build_dir ))
if options.launch_jobs == 0:
- options.launch_jobs = computeDefaultMakeJobs()
+ options.launch_jobs = computeNumCPU()
if options.launch_jobs < 1:
options.launch_jobs = 1
elif options.launch_jobs > 8:
@@ -420,7 +431,7 @@ class Repository:
self.type = 'unofficial'
# parse output: svnversion PROJECT_DIR
- cmd = 'svnversion ' + project_dir
+ cmd = 'svnversion ' + initial_project_dir
print 'running: %s' % (cmd)
try:
p = subprocess.Popen( cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
@@ -431,7 +442,7 @@ class Repository:
pass
# parse output: svn info PROJECT_DIR
- cmd = 'svn info ' + project_dir
+ cmd = 'svn info ' + initial_project_dir
print 'running: %s' % (cmd)
try:
p = subprocess.Popen( cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
@@ -584,11 +595,9 @@ class Config:
## create configure line, stripping arg --launch, quoting others
configure = []
for arg in sys.argv[1:]:
- #if arg.find( '--launch' ) == 0:
- # continue
if arg == '--launch':
continue
- configure.append( '"%s"' % (arg.replace('"', '\\"')) )
+ configure.append( "'%s'" % (arg.replace("'", '%c%c%c%c%c' % (0x27,0x22,0x27,0x22,0x27))) )
## create singletones
repo = Repository()
@@ -640,6 +649,7 @@ config.add( 'HOST.systemc', guessHost.systemc )
config.add( 'HOST.release', guessHost.release )
config.add( 'HOST.title', '%s %s' % (guessHost.systemc,archMode.default) )
config.add( 'HOST.extra', guessHost.extra )
+config.add( 'HOST.ncpu', computeNumCPU() )
config.addBlank()
config.add( 'BUILD.spec', guessBuild )
@@ -650,9 +660,14 @@ config.add( 'BUILD.systemc', guessBuild.systemc )
config.add( 'BUILD.release', guessBuild.release )
config.add( 'BUILD.title', '%s %s' % (guessBuild.systemc,archMode.mode) )
config.add( 'BUILD.extra', guessBuild.extra )
+config.add( 'BUILD.method', 'terminal' )
config.add( 'BUILD.cross', guessBuild.cross )
config.add( 'BUILD.date', time.strftime('%c') )
config.add( 'BUILD.arch', archMode.mode )
+config.add( 'BUILD.jobs', computeNumCPU() )
+
+config.addBlank()
+config.add( 'CONF.method', options.conf_method )
config.addBlank()
config.add( 'BUILD/', os.curdir + os.sep )
@@ -679,6 +694,11 @@ config.add( 'GCC.archs', archMode.mode if guessBuild.cross else '' )
config.add( 'GCC.g', options.debug )
config.add( 'GCC.O', options.optimize )
+if len(exports):
+ config.addBlank()
+ for nv in exports:
+ config.add( nv[0], nv[1] )
+
config.addMake( '' )
config.addMake( '## include (optional) customization file' )
config.addMake( '-include $(BUID/)GNUmakefile.custom' )
diff --git a/make/include/base.defs b/make/include/base.defs
index 3b4e666f3..4e6da0e64 100644
--- a/make/include/base.defs
+++ b/make/include/base.defs
@@ -24,6 +24,8 @@ endef
## $(1) module name (uppercase)
##
define import.MODULE.rules
+.PHONY: $($(1).name).build $($(1).name).clean
+
$($(1).name).report:
@$(MAKE) report.true REPORT=module REPORT.module=$(1)
@@ -31,20 +33,3 @@ $($(1).name).report:
report.modules:: $($(1).name).report
endef
-
-.PHONY: report.main report.gcc report.modules
-
-report.modules::
-
-.PHONY: report.main
-report.main:
- @$(MAKE) report.true REPORT=main
-
-.PHONY: report.gcc
-report.gcc:
- @$(MAKE) report.true REPORT=gcc
-
-## needed for nested make (which drives each report)
-.PHONY: report.true
-report.true:
- @true
diff --git a/make/include/base.rules b/make/include/base.rules
new file mode 100644
index 000000000..f12886432
--- /dev/null
+++ b/make/include/base.rules
@@ -0,0 +1,16 @@
+.PHONY: report.main report.gcc report.modules
+
+report.modules::
+
+.PHONY: report.main
+report.main:
+ @$(MAKE) report.true REPORT=main
+
+.PHONY: report.gcc
+report.gcc:
+ @$(MAKE) report.true REPORT=gcc
+
+## needed for nested make (which drives each report)
+.PHONY: report.true
+report.true:
+ @true
diff --git a/make/include/main.defs b/make/include/main.defs
index 45fb178ae..93271a365 100644
--- a/make/include/main.defs
+++ b/make/include/main.defs
@@ -1,11 +1,3 @@
-.DELETE_ON_ERROR:
-.SUFFIXES:
-
-.PHONY: build
-build:
-
-###############################################################################
-
include $(PROJECT/)make/include/base.defs
include $(PROJECT/)make/include/contrib.defs
include $(PROJECT/)make/include/function.defs
diff --git a/make/include/main.rules b/make/include/main.rules
index b389022f3..1f996cdc5 100644
--- a/make/include/main.rules
+++ b/make/include/main.rules
@@ -1,3 +1,13 @@
+.DELETE_ON_ERROR:
+.SUFFIXES:
+
+###############################################################################
+
+## file-wide conditional to use xcode rules if xcode=1 method=terminal
+ifeq ($(FEATURE.xcode):$(BUILD.method),1:terminal)
+ include $(PROJECT/)macosx/module.xcode
+else
+
## only included using special report targets
ifneq (,$(REPORT))
include $(PROJECT/)make/include/report.defs
@@ -5,8 +15,10 @@ endif
###############################################################################
-.PHONY: clean xclean doc report
+.PHONY: build install clean xclean doc report
+build:
+install:
clean:
xclean: contrib.xclean clean
doc:
@@ -37,3 +49,5 @@ reconfigure:
## target to build all dependency dirs
$(sort $(dir $(BUILD.out))):
$(MKDIR.exe) -p $@
+
+endif ## xcode=1 method=terminal
diff --git a/make/xcodemake.sh b/make/xcodemake.sh
new file mode 100644
index 000000000..5354b54cc
--- /dev/null
+++ b/make/xcodemake.sh
@@ -0,0 +1,75 @@
+#!/bin/sh -ex
+#
+
+## This script is invoked by Xcode external targets.
+##
+## We must guarantee no jobserver is passed through since the file-descriptors
+## have been clobbered by Xcode. If this is not done then make behaves as if
+## it is allowed to run an infinite number of jobs.
+##
+MAKEFLAGS=
+
+cd $EXTERNAL_BUILD
+
+## re/configure if not configured by Xcode or if missing top-makefile
+if [ $EXTERNAL_METHOD != 'xcode' -o ! -f $EXTERNAL_BUILD/GNUmakefile ]; then
+ ## compute --arch value based on Xcode configuration naming convention
+ case "$CONFIGURATION" in
+ *.i386)
+ args="--arch=i386"
+ ;;
+ *.x86_64)
+ args="--arch=x86_64"
+ ;;
+ *.ppc)
+ args="--arch=ppc"
+ ;;
+ *.ppc64)
+ args="--arch=ppc64"
+ ;;
+ *)
+ args=
+ ;;
+ esac
+
+ ## invoke configure with (hidden) option which indicates conf performed by xcode
+ $EXTERNAL_PROJECT/configure PATH=$PATH --conf-method=xcode $args
+fi
+
+## safeguard against passing blank value which would result in unlimited jobs
+if [ -z "$EXTERNAL_JOBS" ]; then
+ jobs=
+else
+ jobs=--jobs=$EXTERNAL_JOBS
+fi
+
+## compute target
+case "$1:$2" in
+contrib:clean)
+ target=contrib.xclean
+ ;;
+contrib:*)
+ target=contrib.install
+ ;;
+*:clean)
+ target=clean
+ ;;
+libhb:'')
+ if [ -z "$EXTERNAL_GOALS" ]; then
+ target=build
+ else
+ target="$EXTERNAL_GOALS"
+ fi
+ ;;
+*:'')
+ target=build
+ ;;
+*)
+ echo "usage: $0 PRODUCT ACTION"
+ exit 1
+ ;;
+esac
+
+## handoff
+set -x
+exec make -C $EXTERNAL_BUILD BUILD.method=xcode $jobs $target