1# Targets:
2#  - all: export the files from Git, produce a ZIP and a TAR archive.
3#  - export: export the files from Git.
4#  - zip: produce a ZIP archive.
5#  - tar: produce a TAR archive.
6#  - clean: remove the staged files.
7#
8
9GIT = git
10ZIP = zip
11TAR = tar
12
13BUILD = ./build
14
15NAME = minimal
16VERSION = latest
17STAGE = $(BUILD)/$(NAME)
18ARCHIVE_NAME = dokuwiki-theme-minimal
19ZIP_NAME = $(ARCHIVE_NAME)-$(VERSION).zip
20TAR_NAME = $(ARCHIVE_NAME)-$(VERSION).tar.gz
21
22all: export zip tar
23	@echo "Build complete."
24
25export:
26	@echo "Exporting files from Git..."
27	@mkdir -p $(BUILD)
28	@if [ -d "$(STAGE)" ] ; then \
29		echo "Export directory already exists." ; \
30	else \
31		$(GIT) checkout-index -a -f --prefix=$(STAGE)/ ; \
32		rm -f $(STAGE)/Makefile ; \
33		git clone git://github.com/znarf/h6e-minimal.git $(STAGE)/h6e-minimal ; \
34		rm -rf $(STAGE)/h6e-minimal/.git ; \
35	fi
36	@echo "Git export complete."
37
38zip:
39	@echo "Creating the ZIP archive..."
40	@(cd $(BUILD) && $(ZIP) -rq $(ZIP_NAME) $(NAME))
41	@echo "ZIP archive done."
42
43tar:
44	@echo "Creating the TAR archive..."
45	@(cd $(BUILD) && $(TAR) -czf $(TAR_NAME) $(NAME))
46	@echo "TAR archive done."
47
48clean:
49	@echo "Cleaning the build directory..."
50	-@rm -rf $(STAGE)
51	-@rm -f $(BUILD)/$(ZIP_NAME)
52	-@rm -f $(BUILD)/$(TAR_NAME)
53	@echo "Staged files and archives removed."
54