-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.example
57 lines (48 loc) · 1.96 KB
/
Makefile.example
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
# This is an example Makefile which can manage the top-level of a Muck project.
# Find the location of this Makefile (this method works with 'make -C', but maybe not with 'make -f'.):
THIS_MAKEFILE=$(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
MAKEFILE_DIR=$(patsubst %/,%,$(dir $(THIS_MAKEFILE)))
# We use the Makefile location to guess our project root and Muck location:
PROJ_ROOT=${MAKEFILE_DIR}
MUCK_DIR=${MAKEFILE_DIR}
# Directory locations:
IN_NAME=1-input
IN_DIR=${PROJ_ROOT}/${IN_NAME}
BUILD_NAME=2-buildarea
BUILD_DIR=${PROJ_ROOT}/${BUILD_NAME}
OUT_DIR_NAME=3-output
DEV_NAME=dev
OUT_DEV_NAME=${OUT_DIR_NAME}/${DEV_NAME}
OUT_DEV_DIR=${PROJ_ROOT}/${OUT_DEV_NAME}
PROD_NAME=prod-$(shell date '+%Y%m%d%H%M%S')
OUT_PROD_NAME=${OUT_DIR_NAME}/${PROD_NAME}
OUT_PROD_DIR=${PROJ_ROOT}/${OUT_PROD_NAME}
OUT_PROD_SYMLINK_NAME=${OUT_DIR_NAME}/prod
OUT_PROD_SYMLINK=${PROJ_ROOT}/${OUT_PROD_SYMLINK_NAME}
# Tell 'make' that our targets aren't really files:
.PHONY: dev prod clean
# We use 'find' instead of 'rm -rf' to preserve existing directory structure.
# This is less confusing for users who rebuild a project while viewing
# outputs -- they don't end up in a detached filesystem node.
dev:
@echo Copying ${IN_NAME} '-->' ${BUILD_NAME}
@rsync -aHAX "${IN_DIR}/" "${BUILD_DIR}"
@echo Building ${BUILD_NAME} '-->' ${OUT_DEV_NAME}
@"${MUCK_DIR}/bin/muck" "${BUILD_DIR}" "${OUT_DEV_DIR}"
@echo
@echo "DEV Built Successfully! Output is at: ${OUT_DEV_DIR}"
@echo
# Copy 'dev' to 'prod':
prod: dev
@echo Copying ${OUT_DEV_NAME} '-->' ${OUT_PROD_NAME}
@rsync -aHAX "${OUT_DEV_DIR}/" "${OUT_PROD_DIR}"
@echo Updating ${OUT_PROD_SYMLINK_NAME} symlink
@ln -sfn "${PROD_NAME}" "${OUT_PROD_SYMLINK}"
@echo
@echo "PROD Built Successfully! Output is at: ${OUT_PROD_SYMLINK}"
@echo
# Remove everything from the Build and Dev directories:
clean:
@echo Cleaning ${BUILD_NAME} and ${OUT_DEV_NAME}
-@find "${BUILD_DIR}" -not -type d -delete
-@find "${OUT_DEV_DIR}" -not -type d -delete