UB.xcconfigs = osx1010.i386 osx1010.x86_64
UB.builds    = $(wildcard $(foreach n,$(UB.xcconfigs),$(SRC/)build.$n))
UB.first     = $(word 1,$(UB.xcconfigs))
UB.more      = $(wordlist 2,999,$(UB.xcconfigs))
UB.products/ = macosx/release/

UB.BUILD = $(SRC/)configure --force --build=ub.$(1) --xcconfig=$(1) --launch --launch-quiet

## linefeed is important
define UB.BUILD.item
	$(call UB.BUILD,$(1)) --launch-jobs=0

endef

define UB.BUILD.SERIAL
	$(foreach n,$(UB.xcconfigs),$(call UB.BUILD.item,$n))
endef

define UB.BUILD.PARALLEL
	$(call UB.BUILD,$(1)) >/dev/null 2>&1
endef

define UB.COMBINE
	$(RM.exe) -fr ub.combine
	$(MKDIR.exe) -p ub.combine
	$(CP.exe) ub.$(UB.first)/$(UB.products/)HandBrakeCLI ub.combine/.
	$(LIPO.exe) $(foreach n,$(UB.xcconfigs),ub.$n/$(UB.products/)HandBrakeCLI) -create -output ub.combine/HandBrakeCLI
	$(CP.exe) -R ub.$(UB.first)/$(UB.products/)HandBrake.app ub.combine/.
	$(LIPO.exe) $(foreach n,$(UB.xcconfigs),ub.$n/$(UB.products/)$(1)) -create -output ub.combine/$(1)
	@lipo -info ub.combine/$(1)
	@sync
	@echo ""
	@echo "$@: { $(UB.xcconfigs) } combined -> ub.combine/HandBrakeCLI"
	@echo "$@: UB executable size: `du -sh ub.combine/HandBrakeCLI | awk '{ print $$1 }'`"
	@echo ""
	@echo "$@: { $(UB.xcconfigs) } combined -> ub.combine/HandBrake.app"
	@echo "$@: UB executable size: `du -sh ub.combine/$(1) | awk '{ print $$1 }'`"
endef
