all:
	/bin/bash ../../../scripts/check-env.sh
	/usr/bin/python3 ../../../scripts/update_version.py
	xcodegen generate
	xcodebuild -configuration Release -alltargets SYMROOT="$(CURDIR)/build"
# Copy LaunchDaemons
	mkdir -p 'build/Release/Karabiner-Elements Privileged Daemons v2.app/Contents/Library/LaunchDaemons'
	cp ../../../vendor/Karabiner-DriverKit-VirtualHIDDevice/files/LaunchDaemons/*.plist 'build/Release/Karabiner-Elements Privileged Daemons v2.app/Contents/Library/LaunchDaemons'
	cp LaunchDaemons/*.plist 'build/Release/Karabiner-Elements Privileged Daemons v2.app/Contents/Library/LaunchDaemons'

clean:
	rm -rf *.xcodeproj
	rm -rf build

xcode:
	open *.xcodeproj

install:
	bash ../../../scripts/codesign.sh build/Release

	sudo rsync -a --delete \
		'build/Release/Karabiner-Elements Privileged Daemons v2.app' \
		'/Library/Application Support/org.pqrs/Karabiner-Elements'
