all: ssh-agent

ssh-agent: ssh-agent.in ssh-agent-noasync.js chrome-emu.js
	rm -f ssh-agent.new ssh-agent
	sed $$'/@@SSH_AGENT_NOASYNC_JS@@/{r ssh-agent-noasync.js\nd}\n/@@CHROME_EMU_JS@@/{r chrome-emu.js\nd}' < ssh-agent.in > ssh-agent.new
	chmod +x ssh-agent.new
	mv ssh-agent.new ssh-agent

ssh-agent-noasync.js: ../chrome/ssh-agent.js
	$(CC) -Dawait='' -Dasync='' -nostdinc -C -E -x c ../chrome/ssh-agent.js -o - | grep -v '^# ' > ssh-agent-noasync.js.new
	mv ssh-agent-noasync.js.new ssh-agent-noasync.js

softokn3-pkcs11.so: softokn3-pkcs11.c
	$(CC) -fPIC -Wall -shared -o softokn3-pkcs11.so softokn3-pkcs11.c

clean:
	rm -f ssh-agent-noasync.js.new ssh-agent-noasync.js
	rm -f softokn3-pkcs11.so
	rm -f ssh-agent.new ssh-agent

distclean: clean

.PHONY: all clean distclean
