Skip to content

Commit ecfc28f

Browse files
committed
add examples to preeseeds, overhaul make.md
1 parent 4d85746 commit ecfc28f

File tree

3 files changed

+131
-21
lines changed

3 files changed

+131
-21
lines changed

docs/source/index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,4 @@ extending
2929
dependencies
3030
make
3131
contributing
32-
usage-old
3332
```

docs/source/make.md

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,26 @@ If the dependencies are up-to-date, "make" will skip the build process for the t
1919

2020
This way, "make" can handle the complex and interdependent steps to form processes of a project, automatically handling the correct order of steps and avoiding unnecessary execution of steps.
2121

22-
## The "phony" target
22+
## The "PHONY" target
2323

24-
In "make", a "phony" target is a special type of target that is used to define a target that is not a file or directory. Phony targets are used to describe actions that need to be performed but do not result in a file that can be used as a target in another rule.
24+
In "make", a "PHONY" target is a special type of target that is used to define a target that is not a file or directory.
25+
Phony targets are used to describe actions that need to be performed but do not result in a file that can be used as a target in another rule.
2526

26-
For example, a common use case for a phony target is to define a "clean" target that removes all generated files.
27-
A makefile could have a rule like the following:
27+
For example, a common use case for a PHONY target is to define a "clean" target that removes all generated files.
28+
A Makefile could have a rule like the following:
2829

29-
```makefile
30+
```Makefile
3031
.PHONY: clean
3132

3233
clean:
3334
rm -rf build
3435
```
3536

36-
The ".PHONY" line indicates that the "clean" target is a phony target. When "make clean" is run, the command in the rule will be executed to remove the "build" directory.
37+
The ".PHONY" line indicates that the "clean" target is a PHONY target.
38+
When "make clean" is run, the command in the rule will be executed to remove the "build" directory.
3739

38-
Phony targets are useful because they provide a way to define targets that don't correspond to files and can be used to perform arbitrary actions such as cleaning the build directory or running tests.
39-
Additionally, "make" considers phony targets to always be out-of-date, so the commands for a phony target will always be executed, even if its dependencies are up-to-date.
40+
PHONY targets are useful because they provide a way to define targets that don't correspond to files and can be used to perform arbitrary actions such as cleaning the build directory or running tests.
41+
Additionally, "make" considers PHONY targets to always be out-of-date, so the commands for a PHONY target will always be executed, even if its dependencies are up-to-date.
4042
This can be useful when you want to guarantee that an action is performed, such as cleaning the build directory before a build.
4143

4244
(make-sentinel-files)=
@@ -52,32 +54,32 @@ To overcome this challenge, other methods, such as using sentinel files, can be
5254
Sentinel files are used to indicate whether a target has been built, or if a process has been completed.
5355
```
5456

55-
For example, a makefile could use a sentinel file to track the state of a build process.
56-
The makefile could contain a rule like the following:
57+
For example, a Makefile could use a sentinel file to track the state of a build process.
58+
The Makefile could contain a rule like the following:
5759

58-
```makefile
60+
```Makefile
5961

6062
build: sentinel
6163
# build commands go here
6264

6365
sentinel:
64-
# build commands go here
6566
touch sentinel
6667
```
6768

68-
In this example, the "sentinel" file is used to track the state of the build. If the "sentinel" file exists, it means that the build has been completed and the build commands will be skipped.
69+
In this example, the "sentinel" file is used to track the state of the build.
70+
If the "sentinel" file exists, it means that the build has been completed and the build commands will be skipped.
6971
If the "sentinel" file does not exist, the build commands will be executed and the "sentinel" file will be created to indicate that the build has been completed.
7072

7173
Sentinel files are useful in "make" because they provide a way to track the state of a build or process, allowing "make" to determine if a target needs to be rebuilt.
7274
This helps to avoid unnecessary rebuilds, which can save time and resources.
7375

7476
## Variables
7577

76-
In "make", variables are used to store values that can be referenced in multiple places throughout the makefile. Variables are defined by assigning a value to a name and can be used in rules, dependencies, and commands.
78+
In "make", variables are used to store values that can be referenced in multiple places throughout the Makefile. Variables are defined by assigning a value to a name and can be used in rules, dependencies, and commands.
7779

78-
For example, the following makefile uses a variable to store the name of the compiler:
80+
For example, the following Makefile uses a variable to store the name of the compiler:
7981

80-
```makefile
82+
```Makefile
8183

8284
CC = gcc
8385

@@ -86,11 +88,11 @@ main: main.c
8688
```
8789

8890
In this example, the "CC" variable is defined with the value "gcc", which is then used in the command to compile the "main.c" file.
89-
This allows for easy modification of the compiler if needed, as the change only needs to be made in one place, instead of throughout the entire makefile.
91+
This allows for easy modification of the compiler if needed, as the change only needs to be made in one place, instead of throughout the entire Makefile.
9092

9193
Variables can also be used to store values that are generated dynamically, such as the result of a shell command. For example:
9294

93-
```makefile
95+
```Makefile
9496

9597
OBJECTS = $(shell ls *.c | sed s/.c/.o/g)
9698

@@ -102,13 +104,13 @@ In this example, the "OBJECTS" variable is defined as the result of a shell comm
102104
The "OBJECTS" variable can then be used in the dependencies and command of the "main" target.
103105

104106
Variables in "make" can also be overridden on the command line, allowing for easy customization of the build process.
105-
For example, the following command would use a different compiler than the one defined in the makefile:
107+
For example, the following command would use a different compiler than the one defined in the Makefile further above:
106108

107109
```shell
108110
make CC=clang
109111
```
110112

111-
This way, "make" variables provide a flexible and convenient way to manage build configurations and reuse values throughout the makefile.
113+
This way, "make" variables provide a flexible and convenient way to manage build configurations and reuse values throughout the Makefile.
112114

113115
There are many more details about variables in the GNU Make Manual.
114116

docs/source/preseeds.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Preseeds
22

3+
## Introduction
4+
35
It is possible to pass configuration preseeds when creating a new project
46
with `mxmake init`. This is useful if you have recurring default settings
57
when creating projects with `mxmake`.
@@ -33,3 +35,110 @@ Now initialize the project with the preseeds:
3335
```shell
3436
$ mxmake init -p preseeds.yaml
3537
```
38+
39+
## Examples
40+
41+
### Create a simple Python project
42+
43+
mxmake was made for the easy management of Python projects.
44+
45+
This example shows how to create a very minimal project structure to build on.
46+
[mxdev][https://pypi.org/project/mxdev/] is integrated to manage versions, sources and more.
47+
48+
Preconditions for this example:
49+
[uv](https://docs.astral.sh/uv/) is installed in the `PATH`.
50+
51+
Use `uv init hello-world` to generate a minimal skeleton package.
52+
53+
Enter the `hello-world-` directory and create a file `preseed.yaml`:
54+
55+
```yaml
56+
topics:
57+
core:
58+
mxenv:
59+
PYTHON_MIN_VERSION: "3.10"
60+
PYTHON_PACKAGE_INSTALLER: uv
61+
MXENV_UV_GLOBAL: true
62+
sources:
63+
qa:
64+
ruff
65+
mypy
66+
test
67+
68+
mx-ini: true
69+
```
70+
71+
Then run:
72+
73+
```bash
74+
uv mxmake init -p preseed.yaml
75+
```
76+
77+
Edit the `mx.ini` and insert after the first line a new line: `main-package = -e .`.
78+
79+
Now run:
80+
```bash
81+
make install
82+
```
83+
84+
Now you have a basic environment to build on.
85+
`make format` wont work, because it looks in the `./src` directory, but this can be fixed by restrcuturing the code.
86+
You may want to use a different skeleton generator than "uv" here.
87+
88+
89+
### Create a Makefile for a simple Plone backend
90+
91+
[Plone](https://plone.org) is an enterprise CMS written in Python (backend) and Javascript (frontend).
92+
mxmake helps to create the backend.
93+
It helps to develop and manage code for integrations and distributions, Plone-add-ons and the Plone-core-development itself.
94+
95+
Preconditions for this example:
96+
[uv](https://docs.astral.sh/uv/) is installed in the `PATH`.
97+
98+
Go in a fresh directory and create a file `plone-preseed.yaml`:
99+
100+
```yaml
101+
topics:
102+
core:
103+
base:
104+
RUN_TARGET: zope-start
105+
mxenv:
106+
PYTHON_MIN_VERSION: "3.10"
107+
PYTHON_PACKAGE_INSTALLER: uv
108+
MXENV_UV_GLOBAL: true
109+
applications:
110+
zope:
111+
plone:
112+
mx-ini: true
113+
```
114+
115+
Run:
116+
```bash
117+
mxmake init -p plone-preseed.yaml
118+
echo "-c https://dist.plone.org/release/6.1-latest/constraints.txt" >requirements.txt
119+
echo "Plone" >>requirements.txt
120+
```
121+
122+
In the
123+
- 1st line the `Makefile` and the `mx.ini` configuration is generated,
124+
- 2nd line a Python requirements is created with a reference to a Plone release file, pinning the versions,
125+
- 3rd line the Plone package is declared as the main package.
126+
127+
Now "make" is now ready to run.
128+
129+
After the first command watch out for a line with the generated password.
130+
It looks like so:
131+
132+
> Generated password for initial user 'admin' is: SOME-CRYPTIC-PASSWORD
133+
134+
Execute:
135+
136+
```bash
137+
make plone-site-create
138+
make run
139+
```
140+
141+
In your browser go to [localhost:8080](http://localhost:8080).
142+
There runs a Plone with a backend ready for Volto (the frontend application for Plone) installed.
143+
144+
This can be combined with the above example for a Python package to create self-contained reproducible environments for development and deployment.

0 commit comments

Comments
 (0)