pkg.create:: $(PKG.appcast) $(PKG.cli.dmg) $(PKG.gui.dmg)


$(PKG.appcast): | $(dir $(PKG.appcast))
$(PKG.appcast): $(PKG.gui.dmg)
$(PKG.appcast): $(BUILD/)project/handbrake.m4
$(PKG.appcast): $(PKG.in/)appcast.xml.m4
	$(M4.exe) -I$(BUILD/)project \
	    -D__APPCAST_dmg="$(notdir $(PKG.gui.dmg))" \
	    -D__APPCAST_dmg_size="$(shell stat -f '%z' $(PKG.gui.dmg))" \
	    $(PKG.in/)appcast.xml.m4 > $@

$(PKG.cli.dmg): | $(dir $(PKG.cli.dmg))
$(PKG.cli.dmg): | $(STAGE.out.cli/)
	hdiutil create -srcfolder $(STAGE.out.cli/) -fs HFS+ -format UDRO -mode 755 \
	    -volname $(basename $(notdir $@)) \
	    -ov $(PKG.cli.tmp.dmg)
	hdiutil convert -format UDBZ -o $@ $(PKG.cli.tmp.dmg)
	$(RM.exe) $(PKG.cli.tmp.dmg)

$(PKG.gui.dmg): | $(dir $(PKG.gui.dmg))
$(PKG.gui.dmg): | $(STAGE.out.gui/)
ifeq (1-darwin,$(FEATURE.xcode)-$(BUILD.system))
	hdiutil create -srcfolder $(STAGE.out.gui/) -fs HFS+ -format UDRO -mode 755 \
	    -volname $(basename $(notdir $@)) \
	    -ov $(PKG.gui.tmp.dmg)
	hdiutil convert -format UDBZ -o $@ $(PKG.gui.tmp.dmg)
	$(RM.exe) $(PKG.gui.tmp.dmg)
else
	$(TOUCH.exe) $@
endif

$(STAGE.out.cli/):
	$(MKDIR.exe) -p $@
ifeq (1-darwin,$(FEATURE.xcode)-$(BUILD.system))
	$(CP.exe) $(XCODE.symroot)/HandBrakeCLI $(STAGE.out.cli/)
	$(call STAGE.doc,$(STAGE.out.cli/))
else
	$(CP.exe) $(TEST.exe) $(STAGE.cli/)
	$(call STAGE.doc,$(STAGE.out.cli/))
endif

$(STAGE.out.gui/):
	$(MKDIR.exe) -p $@
ifeq (1-darwin,$(FEATURE.xcode)-$(BUILD.system))
	$(CP.exe) -R $(XCODE.symroot)/HandBrake.app $(STAGE.out.gui/)
	$(call STAGE.doc,$(STAGE.out.gui/))
endif
