summaryrefslogtreecommitdiff
path: root/Makefile
blob: f7987a8df7855fda8ad9e19a6b3c1a9920433da6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
BUILD_DIR ?= build
TAG ?= $(shell date +%Y%m%d)
JSON_TARBALL := $(BUILD_DIR)/release-$(TAG)-json.tar.gz
PHP_TARBALL := $(BUILD_DIR)/release-$(TAG)-php.tar.gz

.PHONY: build build-php update clean

build: build-json build-php

build-json: update
	tar czf "$(JSON_TARBALL)" -C "$(BUILD_DIR)/json" .
	shasum -a 256 "$(JSON_TARBALL)" | awk '{print $$1}' > "$(JSON_TARBALL).sha256"

build-php: update
	cd php-generator && composer install --no-dev --optimize-autoloader
	mkdir -p "$(BUILD_DIR)/php"
	php php-generator/generate.php "$(BUILD_DIR)/json" "$(BUILD_DIR)/php"
	tar czf "$(PHP_TARBALL)" -C "$(BUILD_DIR)/php" .
	shasum -a 256 "$(PHP_TARBALL)" | awk '{print $$1}' > "$(PHP_TARBALL).sha256"

update: $(BUILD_DIR)/.metadata.updated

$(BUILD_DIR)/.metadata.updated: $(BUILD_DIR)/.metadata.en.updated $(BUILD_DIR)/.metadata.zh.updated
	touch "$@"

$(BUILD_DIR)/.metadata.en.updated:
	LANGUAGE=EN_US BUILD_DIR="$(BUILD_DIR)/json" ./scripts/update-metadata.sh
	touch "$@"

$(BUILD_DIR)/.metadata.zh.updated:
	LANGUAGE=ZH_CN BUILD_DIR="$(BUILD_DIR)/json" ./scripts/update-metadata.sh
	touch "$@"

clean:
	rm -rf "$(BUILD_DIR)/"