$(mak\COPY)
$(mak\IMPORTS)

######################## Header .di file generation ##############################

import: $(IMPORTS)

$(IMPDIR)\core\sync\barrier.di : src\core\sync\barrier.d
	$(DMD) -conf= -c -o- -Isrc -Iimport -Hf$@ $**

$(IMPDIR)\core\sync\condition.di : src\core\sync\condition.d
	$(DMD) -conf= -c -o- -Isrc -Iimport -Hf$@ $**

$(IMPDIR)\core\sync\config.di : src\core\sync\config.d
	$(DMD) -conf= -c -o- -Isrc -Iimport -Hf$@ $**

$(IMPDIR)\core\sync\exception.di : src\core\sync\exception.d
	$(DMD) -conf= -c -o- -Isrc -Iimport -Hf$@ $**

$(IMPDIR)\core\sync\mutex.di : src\core\sync\mutex.d
	$(DMD) -conf= -c -o- -Isrc -Iimport -Hf$@ $**

$(IMPDIR)\core\sync\rwmutex.di : src\core\sync\rwmutex.d
	$(DMD) -conf= -c -o- -Isrc -Iimport -Hf$@ $**

$(IMPDIR)\core\sync\semaphore.di : src\core\sync\semaphore.d
	$(DMD) -conf= -c -o- -Isrc -Iimport -Hf$@ $**


######################## Header .di file copy ##############################

copydir: $(IMPDIR)

copy: generated\windows\copyimports.exe
	@~generated\windows\copyimports.exe $(COPY)

generated\windows\copyimports.exe: mak\copyimports.d generated\windows\host_dmd.bat
	generated\windows\host_dmd.bat -of=$@ -m$(MODEL) mak\copyimports.d

# find a host dmd on the different CI systems
# - auto-tester: 2.079 installed, but not exposed to the druntime build
# - appveyor: found through PATH
# - azure-make: set as $(HOST_DC)
# - azure-vs: $(DMD_DIR)\dmd2\Windows\bin\dmd.exe
ATCLIENT_DMD = ../../release-build/dmd-2.079.0/windows/bin/dmd.exe

generated\windows\host_dmd.bat:
	+if not exist generated md generated
	+if not exist generated\windows md generated\windows
	-+if exist "$(ATCLIENT_DMD)" (echo @"$(ATCLIENT_DMD)" %* >$@)
	-+if not "$(DMD_DIR)"  == "" ("$(DMD_DIR)\dmd2\Windows\bin\dmd.exe" --version >nul 2>&1 && echo @"$(DMD_DIR)\dmd2\Windows\bin\dmd.exe" %* >$@)
	-+if not "$(HOST_DC)"  == "" ("$(HOST_DC)"  --version >nul 2>&1 && echo @"$(HOST_DC)" %* >$@)
	-+if not "$(HOST_DMD)" == "" ("$(HOST_DMD)" --version >nul 2>&1 && echo @"$(HOST_DMD)" %* >$@)
