#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

GEN_CERT_HEADER = $(srcdir)/gen_cert_header.py
TEST_SSL_PATH = $(srcdir)/../manager/ssl/tests/unit/test_signed_manifest/

marketplace-prod-public.inc: marketplace-prod-public.crt $(GEN_CERT_HEADER)
	$(PYTHON) $(GEN_CERT_HEADER) marketplaceProdPublicRoot $< > $@

marketplace-prod-reviewers.inc: marketplace-prod-reviewers.crt $(GEN_CERT_HEADER)
	$(PYTHON) $(GEN_CERT_HEADER) marketplaceProdReviewersRoot $< > $@

marketplace-dev-public.inc: marketplace-dev-public.crt $(GEN_CERT_HEADER)
	$(PYTHON) $(GEN_CERT_HEADER) marketplaceDevPublicRoot $< > $@

marketplace-dev-reviewers.inc: marketplace-dev-reviewers.crt $(GEN_CERT_HEADER)
	$(PYTHON) $(GEN_CERT_HEADER) marketplaceDevReviewersRoot $< > $@

marketplace-stage.inc: marketplace-stage.crt $(GEN_CERT_HEADER)
	$(PYTHON) $(GEN_CERT_HEADER) marketplaceStageRoot $< > $@

ifeq ($(shell test -s trusted-app-public.der; echo $$?),0)
TRUSTED_APP_PUBLIC=trusted-app-public.der
else
TRUSTED_APP_PUBLIC=
endif

manifest-signing-root.inc: $(TRUSTED_APP_PUBLIC) $(GEN_CERT_HEADER)
	$(PYTHON) $(GEN_CERT_HEADER) trustedAppPublicRoot $(TRUSTED_APP_PUBLIC) > $@

manifest-signing-test-root.inc: $(TEST_SSL_PATH)trusted_ca1.der $(GEN_CERT_HEADER)
	$(PYTHON) $(GEN_CERT_HEADER) trustedAppTestRoot $< > $@

xpcshell.inc: $(srcdir)/../manager/ssl/tests/unit/test_signed_apps/trusted_ca1.der $(GEN_CERT_HEADER)
	$(PYTHON) $(GEN_CERT_HEADER) xpcshellRoot $< > $@

export:: \
  marketplace-prod-public.inc \
  marketplace-prod-reviewers.inc \
  marketplace-dev-public.inc \
  marketplace-dev-reviewers.inc \
  marketplace-stage.inc \
  manifest-signing-root.inc \
  manifest-signing-test-root.inc \
  xpcshell.inc \
  $(NULL)
