Modularize Makefile and add two skeletons: plone3 and zope3
[zope-bootstrap.git] / Makefile.master
1 # -*- makefile -*-
2
3 #
4 # The master makefile sets up the follosing customizable (double-colon) targtets.
5 #
6 # debdepends::
7 #     This optional target may be used by the user to install the necessary 
8 #     system requirements via 'aptitude'. Must be called as root
9 #
10 # setup::
11 #     Called for basic setup. Executed before installing the basic eggs
12 #
13 # eggs::
14 #     Called to install eggs
15 #
16 # buildout::
17 #     Called to install the buildout (e.g. call paster create)
18 #
19 # init-hook::
20 #     Called after the buildout is installed but BEFORE bootstraping
21 #
22 # update-hook::
23 #     Called BEFORE updating the buildout (e.g. before calling bin/buildout)
24 #
25 # bootstrap::
26 #     Called to bootstrap the buildout. Here you can add actions to be
27 #     performed AFTER bootstraping the project whenever a bootstrap is performed
28 #
29 # update::
30 #     Called to update the buildout (calls bin/buildout). Here you can add
31 #     commands to call AFTER bin/buildout returns.
32 #
33 # .gitignore::
34 #     Called to populate the .gitignore file. Use '@$(gitignore) <pattern>' to
35 #     add a pattern
36 #
37 # .env::
38 #     Called to add environment variables to be set when executing a shell
39 #     Use @$(env) <var> <value> to add a variable settings. <var> may be
40 #         PATH         Add <value> to PATH
41 #         PYTHONPATH   Add <value> to PYTHONPATH
42 #         <other>      Set variable to <value>
43
44 # clean::
45 #     Called to clean up all generated files
46 #
47
48 ###########################################################################
49
50 BASEDIR=$(shell pwd)
51
52 default: update-nonet
53 .PHONY: default
54
55 ###########################################################################
56 # Customization targets
57
58 debdepends::
59 .PHONY: debdepends
60
61 setup::
62 .PHONY: setup
63
64 eggs::
65 .PHONY: eggs
66
67 buildout::
68 .PHONY: buildout
69
70 init-hook::
71 .PHONY: init-hook
72
73 update-hook::
74 .PHONY: update-hook
75
76 bootstrap::
77         sed -i -e '1s/^#!.*\/python/#!$(subst /,\/,$(PYTHON))/' $(PYTHON_DIR)/bin/*
78 #       $(PYTHON) bootstrap.py
79         $(PYTHON) -c 'from zc.buildout.buildout import main; main(["bootstrap"])'
80
81 update:: update-hook
82         bin/buildout $(BUILDOUT_OPTS)
83
84 define gitignore
85     _gitignore () {                                             \
86         [ -r .gitignore ] || touch .gitignore;                  \
87         grep -qxF "$$1" .gitignore || echo "$$1" >>.gitignore;  \
88     };                                                          \
89     _gitignore
90 endef
91 .gitignore::
92         @echo "Updating .gitignore"
93         @$(gitignore) "*.pyc"
94         @$(gitignore) "*.egg-info/"
95         @$(gitignore) "/.env"
96
97 define env
98     _env () {                                                   \
99         [ -r .env ] || touch .env;                              \
100         case "$$1" in                                           \
101         PATH|PYTHONPATH) line="export $$1=\"$$2:\$$$$1\"" ;;    \
102         *) line="export $$1=\"$$2\"" ;;                         \
103         esac;                                                   \
104         grep -qxF "$$line" .env || echo "$$line" >>.env;        \
105     };                                                          \
106     _env
107 endef
108 .env::
109         @echo "Updating .env"
110
111 clean::
112         rm -f .gitignore .env
113 .PHONY: clean
114
115 ###########################################################################
116 # internal targets
117
118
119 ###########################################################################
120 # user targets
121
122 init: setup eggs buildout init-hook update-hook bootstrap update .gitignore .env
123
124 versions:
125         @echo "# Add the following lines to [versions] in buildout.cfg to pin all packages"
126         @bin/buildout -Novvvvv | sed -ne 's/^Picked: //p' | sort | uniq 
127
128 shell:
129         @eval "`cat .env`"; $$SHELL
130
131 update-nonet: BUILDOUT_OPTS=-No
132 update-nonet: update