-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
70 lines (49 loc) · 1.76 KB
/
Makefile
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Copyright (c) 2016, Abdó Roig-Maranges <[email protected]>
# All rights reserved.
#
# This file is part of 'LaTeX Base Cookiecutter'.
# So that we can use newlines in recipes with $(\n)
define \n
endef
# Shell settings
SHELL := /bin/bash
.SHELLFLAGS := -e -u -c
# Use a single shell
.ONESHELL:
# So we can use $$(variable) on the prerequisites, that expand at matching time.
.SECONDEXPANSION:
BUILD_DIR := build
TESTPROJ_DIR := $(BUILD_DIR)/testproj
all: build
.PHONY: build clean
## Build test project
build:
@rm -Rf $(BUILD_DIR)
mkdir -p $(BUILD_DIR)
cookiecutter --no-input -o $(BUILD_DIR) $(abspath .) project_slug=$(notdir $(TESTPROJ_DIR))
rsync -a --exclude '.dummy' test/ $(TESTPROJ_DIR)
## Clean rendered test project
clean:
@rm -Rf $(BUILD_DIR)
# -------------------------------------------------------------------------- #
# Source maintenance #
# -------------------------------------------------------------------------- #
.PHONY: update-template update-copyright
## Update cookiecutter template branch
update-template:
@python make/cookiecutter-update.py ".cookiecutter.json" template
## Update copyright from file headers
update-copyright:
@year=$$(date '+%Y')
git ls-files | while read f; do
sed -i "1,10{s/Copyright (c) \([0-9]\+\)\(-[0-9]\+\)\?,/Copyright (c) \1-$$year,/}" "$$f"
sed -i "1,10{s/Copyright (c) $$year-$$year,/Copyright (c) $$year,/}" "$$f"
done
.PHONY: help
## Print Makefile documentation
help:
@perl -0 -nle 'printf("%-25s - %s\n", "$$2", "$$1") while m/^##\s*([^\r\n]+)\n^([\w-]+):[^=]/gm' \
$(MAKEFILE_LIST) | sort
printf "\n"
perl -0 -nle 'printf("%-25s - %s\n", "$$2=", "$$1") while m/^##\s*([^\r\n]+)\n^([\w-]+)\s*:=/gm' \
$(MAKEFILE_LIST) | sort