RIME_ROOT = $(CURDIR)
RIME_COMPILER_OPTIONS = CC=clang CXX=clang++ CXXFLAGS="-stdlib=libc++" LDFLAGS="-stdlib=libc++"


.PHONY: all release debug clean thirdparty

all: release

release:
	mkdir -p xbuild
	cd xbuild; cmake -G Xcode .. -DBUILD_STATIC=ON -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON
	cd xbuild; xcodebuild -project rime.xcodeproj -configuration Release build | grep -v setenv | tee build.log

debug:
	mkdir -p xdebug
	cd xdebug; cmake -G Xcode .. -DBUILD_STATIC=ON -DBUILD_TEST=ON -DBUILD_SEPARATE_LIBS=ON
	cd xdebug; xcodebuild -project rime.xcodeproj -configuration Debug build | grep -v setenv | tee build.log

clean:
	rm -rf xbuild > /dev/null 2>&1 || true
	rm -rf xdebug > /dev/null 2>&1 || true
	rm build.log > /dev/null 2>&1 || true

thirdparty:
	$(RIME_COMPILER_OPTIONS) make -f Makefile.thirdparty
	make -f Makefile.thirdparty clean-src

thirdparty/%:
	make -f Makefile.thirdparty $(@:thirdparty/%=%)
