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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
|
.TH MKPROJ 1 "2026-09-20" "mkproj 0.4.0" "User Commands"
.SH NAME
mkproj \- dumb project generator
.SH SYNOPSIS
.B mkproj
.RI [ options ]
.I name
.br
.B mkproj \-\-completions
.BR bash | zsh | fish
.br
.B mkproj
.BR \-v | \-h
.SH DESCRIPTION
.B mkproj
generates boilerplate for
.BR make ,
.BR cmake ,
.BR meson ,
.B premake5
or
.B xmake
so you do not have to keep writing build files for small projects.
.PP
It creates a directory
.I name
containing a stub
.I main
at the root and a build file for the chosen build system. With
.B \-\-git
it also writes a
.B .gitignore
and initializes a git repository. The stub compiles
cleanly under a strict set of warnings with address and undefined
sanitizers enabled by default.
.PP
If
.I name
is
.BR . ,
the project is generated into the current directory instead of a new one,
and the project name is taken from that directory's basename. In this mode
.B mkproj
refuses to run if a build file already exists, so it will not clobber an
existing project.
.PP
By default the layout is flat (sources at the root), the executable is
built at the project root, object files go under
.BR bin ,
and the newest language standard is used. Use
.BR \-\-src ", " \-\-no\-root
and
.B \-s
to change these.
.SH OPTIONS
.TP
.BR \-l ", " \-\-lang " " \fIlang\fR
Source language:
.BR c ", " cpp ", " objc ", " nasm ", " swift " or " crust .
Default
.BR c .
.B nasm
projects are x86\-64 assembly.
.B swift
is compiled with
.BR swiftc ,
and
.B crust
is Rust driven straight through
.B rustc
(no cargo), from the crate root
.RB ( main.rs ).
.B nasm ", " swift " and " crust
only support the
.B make
build system, build executables only, and take no language standard;
.B swift
and
.B crust
also have no
.BR \-\-style .
.TP
.BR \-s ", " \-\-std " " \fIstd\fR
Language standard passed to the compiler as
.BI \-std= std\fR,
for example
.B c17
or
.BR c++23 .
Must be valid for the chosen language. Defaults to the newest standard for
the language
.RB ( c2y
for
.B c
and
.BR objc ,
.B c++26
for
.BR cpp ).
.TP
.BR \-b ", " \-\-build " " \fIsystem\fR
Build system to generate:
.BR make ", " cmake ", " meson ", " premake " or " xmake .
Default
.BR make .
.TP
.BR \-k ", " \-\-kind " " \fIkind\fR
What to build:
.B exe
for an executable,
.B lib
for a static library
.RI ( lib < name >.a ),
or
.B shared
for a shared library
.RI ( lib < name >.so
on Linux,
.RI lib < name >.dylib
on macOS). Either library kind gets a
.RI < name >.h
/
.RI < name >.c
pair with a stub function instead of a
.IR main ,
and is built without sanitizers \(em those belong in the executable that
links the library. Default
.BR exe .
.TP
.BR \-\-cc " " \fIcc\fR
Compiler to use. Default
.B clang
for
.B c
and
.BR objc ,
.B clang++
for
.BR cpp .
Applies to the
.BR make ", " premake " and " xmake
backends (for
.B premake
and
.B xmake
it selects the matching toolset);
.B cmake
and
.B meson
pick the compiler from the environment instead.
.TP
.BR \-\-license " " \fIname\fR
Write a
.B LICENSE
file. One of
.BR mit ", " isc ", " bsd-2 ", " bsd-3 " or " unlicense .
The copyright holder is taken from
.B git config user.name
(falling back to
.BR $USER ).
No license is written by default.
.TP
.B \-\-git
Initialize a git repository and write a
.BR .gitignore .
By default neither is created.
.TP
.BR \-\-src " " \fIdir\fR
Put the sources in
.I dir
instead of at the project root. By default the layout is flat, with sources
at the root; objects always build into the
.B \-\-bin
directory.
.TP
.B \-\-docker
Add a
.B Dockerfile
and
.B .dockerignore
that build and run the project in a container. Supported for
.B c
and
.B cpp
(with
.BR make ", " cmake " or " meson )
and for
.BR nasm .
With
.B nasm
the container targets Linux
.RB ( elf64 ),
so you write against Linux syscalls instead of the macOS assembly
conventions the native build uses.
.TP
.B \-\-no\-root
Put the built executable inside
.B \-\-bin
instead of at the project root. By default the executable is built at the
project root
.RI ( ./ name ),
with objects under
.BR \-\-bin .
Applies to
.B make
and
.BR premake ;
.BR cmake ", " meson " and " xmake
always keep the executable in their build directory.
.TP
.B \-\-single
Generate a simplified
.B Makefile
for a project whose sources compile in one step: the sources are built straight
into the executable with no object directory, and
.B clean
removes only the binary. There is no
.B \-\-bin
or
.BR \-\-bin\-int .
Only for
.B make
with
.BR c ", " cpp " or " objc ,
and only for an executable.
.TP
.B \-\-no\-validation
Leave out the
.B check
target (which runs
.BR bear " and " cppcheck )
and the address and undefined sanitizer flags from the generated
.BR Makefile .
.TP
.B \-\-style
Add a
.B .clang-format
and
.B .editorconfig
matching the house style guide
.RB ( hachem.wtf/blabbing/style-guide ).
Only for
.BR c ", " cpp " and " objc .
.TP
.B \-\-ci
Add a
.B .github/workflows/ci.yml
GitHub Actions workflow that builds the project on every push and pull
request. Runs on
.B macOS
for
.BR objc ", " swift " and " nasm ,
and on
.B Linux
otherwise, installing whatever the runner does not already provide.
.TP
.BR \-\-bin " " \fIdir\fR
Build directory. The default depends on the build system:
.B bin
for
.B make
and
.BR premake ,
.B build
for
.BR cmake ,
and
.B builddir
for
.BR meson .
The final executable is written here.
.TP
.BR \-\-bin\-int " " \fIdir\fR
Compile object files into their own directory
.I dir
instead of alongside the executable in
.BR \-\-bin .
Applies only to
.B make
and
.BR premake .
By default objects and the executable share the
.B \-\-bin
directory.
.TP
.BR \-v ", " \-\-version
Print version and exit.
.TP
.BR \-h ", " \-\-help
Print a usage summary and exit.
.TP
.BR \-\-completions " " \fIshell\fR
Print a shell completion script for
.BR bash ", " zsh " or " fish
to standard output, then exit. Source it from the shell's startup file, or
install it where that shell looks for completions.
.SH "BUILD SYSTEMS"
.B make
and
.B premake
build objects into
.BR \-\-bin ,
or into
.B \-\-bin\-int
when it is given, and place the executable at the project root unless
.B \-\-no\-root
is set.
.BR cmake ", " meson " and " xmake
use a single out\-of\-source build directory named by
.BR \-\-bin ,
so
.B \-\-bin\-int
does not apply to them and is rejected if combined with either.
.PP
The generated
.B make
build files have a
.B run
target for executables, so
.B make run
builds and runs the program;
.B xmake
projects use
.B xmake run
instead.
.SH EXAMPLES
.TP
.B mkproj hello
A C project built with make.
.TP
.B mkproj \-l cpp \-s c++20 \-b cmake app
A C++20 project built with cmake.
.TP
.B mkproj \-b make \-\-bin\-int obj tool
A make project with objects compiled into
.BR obj/ .
.TP
.B mkproj \-\-src source quick
A project with its source under
.BR source/ ,
rather than the default flat layout.
.TP
.B mkproj .
Generate the project into the current directory, naming it after that
directory.
.TP
.B mkproj \-l crust hello
A Rust project built straight through
.B rustc
with make, no cargo.
.TP
.B mkproj \-k lib \-\-license mit libfoo
A static-library project with an MIT
.BR LICENSE .
.TP
.B mkproj \-k shared \-b cmake libbar
A shared-library project built with cmake.
.SH ENVIRONMENT
These set defaults that command-line options override:
.BR MKPROJ_LANG ", " MKPROJ_STD ", " MKPROJ_BUILD ", " MKPROJ_CC ", " MKPROJ_KIND
and
.BR MKPROJ_LICENSE .
.SH "EXIT STATUS"
.TP
.B 0
The project was generated.
.TP
.B 1
A usage error, or a file or directory could not be created.
.SH AUTHOR
hachem <im@hachem.wtf>
|