
SRCPATH=$(VPATH)/
ifeq ($(TOPDIR),)
TOPDIR=..
BUILD=..
endif

include $(TOPDIR)/Rules.mak

CONFIG_OBJ = dn.txt oids.txt eku.txt
INSTALLS = Info.plist xca.completion xca.desktop xca.xml

.install-stamp all: $(CONFIG_OBJ)
.install-stamp: $(INSTALLS)

MSG := \# Do not edit this file, rather use

%.txt: preamble.txt %.text
	@$(PRINT) "  GEN    [$(BASENAME)] $@"
ifeq ($(HOST), WINDOWS)
	(echo "$(MSG) PROFILE\Application Data\xca\$@" && cat $^) | sed 's/$$/\r/' > $@
else ifeq ($(HOST), DARWIN)
	(echo "$(MSG) HOME/Library/Application Support/data/xca/$@" && cat $^) > $@
else
	(echo "$(MSG) /etc/xca/$@ or HOME/.xca/$@" && cat $^) > $@
endif


install:
	install -m 755 -d $(DESTDIR)$(xca_prefix) \
		$(DESTDIR)$(datarootdir)/applications \
		$(DESTDIR)$(datarootdir)/mime/packages \
		$(DESTDIR)$(datarootdir)/bash-completion/completions
	install -m 644 $(CONFIG_OBJ) $(SRCPATH)*.xca \
			$(DESTDIR)$(xca_prefix)
	install -m 644 $(SRCPATH)xca.desktop $(DESTDIR)$(datarootdir)/applications
	install -m 644 $(SRCPATH)xca.xml $(DESTDIR)$(datarootdir)/mime/packages
	install -m 644 $(SRCPATH)xca.completion $(DESTDIR)$(datarootdir)/bash-completion/completions/xca
	if test -z "$(DESTDIR)"; then \
	  update-mime-database $(datarootdir)/mime || :; \
	  update-desktop-database || :; \
	fi
app: Info.plist PkgInfo | $(CONFIG_OBJ)
	mkdir -p $(APPDIR)/Resources
	install -m 644 $^ $(APPDIR)
	install -m 644 $(CONFIG_OBJ) $(SRCPATH)*.xca $(APPDIR)/Resources

