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 = openid
16VERSION = latest
17STAGE = $(BUILD)/$(NAME)
18ARCHIVE_NAME = dokuwiki-openid-plugin
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	fi
34	@echo "Git export complete."
35
36zip:
37	@echo "Creating the ZIP archive..."
38	@(cd $(BUILD) && $(ZIP) -rq $(ZIP_NAME) $(NAME))
39	@echo "ZIP archive done."
40
41tar:
42	@echo "Creating the TAR archive..."
43	@(cd $(BUILD) && $(TAR) -czf $(TAR_NAME) $(NAME))
44	@echo "TAR archive done."
45
46clean:
47	@echo "Cleaning the build directory..."
48	-@rm -rf $(STAGE)
49	-@rm -f $(BUILD)/$(ZIP_NAME)
50	-@rm -f $(BUILD)/$(TAR_NAME)
51	@echo "Staged files and archives removed."
52