$(eval $(call import.MODULE.rules,MACOSX))

build: macosx.build
archive: macosx.archive
install: macosx.install
uninstall: macosx.uninstall
clean: macosx.clean
xclean: macosx.xclean

########################################
# sync with ../test/module.rules       #
########################################
test.install-strip: | $(dir $(TEST.install.exe))
	$(CP.exe) $(TEST.exe) $(TEST.install.exe)
	$(STRIP.exe) $(TEST.install.exe)

test.install: | $(dir $(TEST.install.exe))
	$(CP.exe) $(TEST.exe) $(TEST.install.exe)

test.uninstall:
	$(RM.exe) -f $(TEST.install.exe)

test.clean:
	$(RM.exe) -f $(TEST.out)

test.xclean: test.clean
########################################

macosx.build: $(MACOSX.m4.out)
macosx.build: $(MACOSX.osl.filelist)

macosx.archive: $(MACOSX.m4.out)
macosx.archive: $(MACOSX.osl.filelist)

macosx.install: test.install
macosx.uninstall: test.uninstall

macosx.clean:
	$(RM.exe) -rf $(MACOSX.xroot/)HandBrake/
	$(RM.exe) -rf $(MACOSX.xroot/)HandBrake.xcarchive
	$(RM.exe) -rf $(MACOSX.xroot/)HandBrake.app
	$(RM.exe) -f $(MACOSX.xroot/)HandBrakeCLI
	$(RM.exe) -f $(MACOSX.xroot/)hbsign.log
	$(RM.exe) -f $(MACOSX.m4.out)
	$(RM.exe) -f $(MACOSX.osl.filelist)

macosx.xclean:
	$(RM.exe) -rf $(MACOSX.build/)
	$(RM.exe) -rf $(MACOSX.xroot/)

$(MACOSX.m4.out): $(BUILD/)project/handbrake.m4
$(MACOSX.m4.out): | $(dir $(MACOSX.m4.out))
$(MACOSX.m4.out): $(MACOSX.build/)%: $(MACOSX.src/)%.m4
	$(M4.exe) -Iproject $< > $@

$(MACOSX.osl.filelist): | $(dir $(MACOSX.osl.filelist))
$(MACOSX.osl.filelist): $(BUILD/)GNUmakefile
	@echo "creating $@"
	@> $@
	$(foreach i,$(foreach m,$(MODULES.NAMES),$($m.OSL.files)),$(call fn.PRINTLN,@echo $i >> $@))
