hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/mkproj.1
blob: b416bcc52cbc2a4f6fe1f0cebf770c6633ba8ab3 (plain)
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
.TH MKPROJ 1 "2026-09-12" "mkproj 0.2.0" "User Commands"
.SH NAME
mkproj \- dumb project generator
.SH SYNOPSIS
.B mkproj
.RI [ options ]
.I name
.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
.B src
directory with a stub
.IR main
(or the stub at the root, with
.BR \-\-flat ),
a build file for the chosen build system, a
.B .gitignore
and, unless disabled, an initialized git repository. The stub compiles
cleanly under a strict set of warnings with address and undefined
sanitizers enabled by default.
.SH OPTIONS
.TP
.BR \-l ", " \-\-lang " " \fIlang\fR
Source language:
.BR c ", " cpp ", " objc " or " nasm .
Default
.BR c .
.B nasm
projects are x86\-64 assembly and only support the
.B make
build system (executables only, no language standard).
.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
.B c17
for
.B c
and
.BR objc ,
and
.B c++23
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 or
.B lib
for a static library. A library gets a
.RI < name >.h
/
.RI < name >.c
pair with a stub function instead of a
.IR main .
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 \-\-no\-git
Do not initialize a git repository.
.TP
.B \-\-intermediate
Compile objects into a separate directory (see
.BR \-\-bin\-int ).
Only meaningful for
.B make
and
.BR premake .
.TP
.B \-\-flat
Flat layout: put the sources at the project root instead of in a
.B src
directory. Objects still build into the
.B \-\-bin
directory, so the tree stays a single level deep.
.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
Separate directory for intermediate object files. Implies
.BR \-\-intermediate ,
and applies only to
.B make
and
.BR premake .
Default
.BR bin\-int .
.TP
.B \-\-no\-clangd
Do not generate a
.B compile_flags.txt
for clangd, and do not add the clangd artifacts
.RB ( .clangd ", " compile_commands.json )
to
.BR .gitignore .
By default a
.B compile_flags.txt
with the project's flags is written so an editor's language server works before
the first build.
.TP
.BR \-v ", " \-\-version
Print version and exit.
.TP
.BR \-h ", " \-\-help
Print a usage summary and exit.
.SH "BUILD SYSTEMS"
.B make
and
.B premake
build objects and the executable into
.BR \-\-bin ,
or split objects into
.B \-\-bin\-int
when
.B \-\-intermediate
is given.
.BR cmake ", " meson " and " xmake
use a single out\-of\-source build directory named by
.BR \-\-bin ,
so
.B \-\-intermediate
and
.B \-\-bin\-int
do not apply to them and are rejected if combined with either.
.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 \-\-flat quick
A flat project: the source sits at the root, no
.B src
directory.
.TP
.B mkproj \-k lib \-\-license mit libfoo
A static-library project with an MIT
.BR LICENSE .
.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>