Commit for Maxim <3
[build.git] / default.build
blobaa2055d1fee2cc862a8b88fb1a600b747b3262a0
2 default target 'default'
4 variable package = 'build'
5 variable version = '0.1'
7 variable prefix = '/usr/local'
9 variable cc = 'gcc'
11 variable cppflags = [
12   '-D_POSIX_C_SOURCE=200809L'
13   '-D_DEFAULT_SOURCE=1'
14   '-DENABLE_NLS=1'
15   '-DPACKAGE="build"'
16   '-DLOCALEDIR="./po/locale"'
19 variable warn_flags = [
20   '-Wabi=2'
21   '-Wall'
22   '-Warith-conversion'
23   '-Warray-bounds=2'
24   '-Wattribute-alias=2'
25   '-Wbad-function-cast'
26   '-Wconversion'
27   '-Wdate-time'
28   '-Wdisabled-optimization'
29   '-Wdouble-promotion'
30   '-Wduplicated-branches'
31   '-Wduplicated-cond'
32   '-Wduplicated-cond'
33   '-Wenum-conversion'
34   '-Wextra'
35   '-Wformat-signedness'
36   '-Wformat-truncation=2'
37   '-Wformat=2'
38   '-Wimplicit-fallthrough=2'
39   '-Winit-self'
40   '-Winvalid-pch'
41   '-Wlogical-op'
42   '-Wmissing-attributes'
43   '-Wmissing-braces'
44   '-Wmissing-declarations'
45   '-Wmissing-format-attribute'
46   '-Wmissing-include-dirs'
47   '-Wmissing-noreturn'
48   '-Wmissing-prototypes'
49   '-Wnested-externs'
50   '-Wnull-dereference'
51   '-Wold-style-definition'
52   '-Wopenmp-simd'
53   '-Wpacked'
54   '-Wpedantic'
55   '-Wpointer-arith'
56   '-Wredundant-decls'
57   '-Wrestrict'
58   '-Wshadow'
59   '-Wshift-overflow=2'
60   '-Wsign-conversion'
61   '-Wstrict-overflow=5'
62   '-Wstrict-prototypes'
63   '-Wstring-compare'
64   '-Wsuggest-attribute=cold'
65   '-Wsuggest-attribute=const'
66   '-Wsuggest-attribute=format'
67   '-Wsuggest-attribute=malloc'
68   '-Wsuggest-attribute=noreturn'
69   '-Wsuggest-attribute=pure'
70   '-Wsuggest-final-methods'
71   '-Wsuggest-final-types'
72   '-Wtrampolines'
73   '-Wundef'
74   '-Wuninitialized'
75   '-Wunknown-pragmas'
76   '-Wunreachable-code'
77   '-Wunused'
78   '-Wunused-const-variable=2'
79   '-Wunused-function'
80   '-Wunused-parameter'
81   '-Wvariadic-macros'
82   '-Wvector-operation-performance'
83   '-Wvla-larger-than=4031'
84   '-Wwrite-strings'
85   '-Wcast-qual'
86   '-Wpadded'
87   '-Wswitch-default'
88   '-Wswitch-enum'
89   '-Wunused-macros'
92 variable sanitize = [
93   '-fsanitize=alignment'
94   '-fsanitize=bool'
95   '-fsanitize=bounds'
96   '-fsanitize=enum'
97   '-fsanitize=float-cast-overflow'
98   '-fsanitize=float-divide-by-zero'
99   '-fsanitize=integer-divide-by-zero'
100   '-fsanitize=nonnull-attribute'
101   '-fsanitize=null'
102   '-fsanitize=object-size'
103   '-fsanitize=pointer-overflow'
104   '-fsanitize=return'
105   '-fsanitize=returns-nonnull-attribute'
106   '-fsanitize=shift'
107   '-fsanitize=signed-integer-overflow'
108   '-fsanitize=thread'
109   '-fsanitize=undefined'
110   '-fsanitize=unreachable'
111   '-fsanitize=vla-bound'
112   '-fsanitize=vptr'
115 variable debug_cflags = [
116   '-D_FORTIFY_SOURCE=2'
117   '-Og'
118   '-g3'
119   '-pg'
120   '-ggdb3'
121 #  '-O3'
122   '-pg'
123   '-fanalyzer'
124   @warn_flags
125   @sanitize
128 variable release_cflags = [
129   '-DNDEBUG=1'
130   '-Ofast'
131   '-Wl,--gc-sections'
132   '-Wl,--strip-all'
133   '-flto=4'
134   '-fno-fat-lto-objects'
135   '-fno-stack-protector'
136   '-fomit-frame-pointer'
137   '-funroll-all-loops'
140 variable cflags = [
141   '-fshort-enums'
142   '-fstrict-aliasing'
143   '-fstrict-overflow'
144   '-pipe'
145   '-std=gnu11'
146   '-MMD'
147   @debug_cflags
150 variable ldflags = [
151   '-Wl,-lpthread'
152   '-Wl,-lgdbm'
153 #PCC  '-Wl,-znoexecstack'
156 rule yacc {
157   description: 'YACC @in'
158   >bison -Wall -Wdangling-alias -Wcounterexamples @in
161 rule lex {
162   description: 'LEX @in'
163   >flex @in
166 rule compile {
167   description: 'CC @in'
168   >@cc @cppflags @cflags -c -o @out @in
171 rule assemble {
172   >as -o @out @in
175 rule link {
176   description: 'LINK @out'
177   >@cc @ldflags @cflags -o @out @in
180 variable potfile = 'po/build.pot'
181 variable pofiles = 'po/ru.po'
182 variable mofiles = 'po/locale/ru/LC_MESSAGES/build.mo'
184 variable xgettext_options = [
185   '--flag=N_:1:pass-c-format'
186   '--flag=S_:1:pass-c-format'
187   '--flag=S_:2:pass-c-format'
188   '--flag=_:1:pass-c-format'
189   '--flag=error:1:c-format'
190   '--flag=error_at:2:c-format'
191   '--flag=fatal:1:c-format'
192   '--flag=info:1:c-format'
193   '--flag=warning:1:c-format'
194   '--flag=warning_at:2:c-format'
195   '--from-code=UTF-8'
196   '--keyword=N_:1'
197   '--keyword=S_:1,2'
198   '--keyword=YY_:1'
199   '--keyword=YY_FATAL_ERROR:1'
200   '--keyword=_:1'
201   '--language=C'
202   '--no-wrap'
203   '-F'
206 rule msgmerge {
207   description: 'MSGMERGE @out'
208   >msgmerge -U @out @in
211 rule xgettext {
212   description: 'XGETTEXT @out'
213   >xgettext @xgettext_options --package-name @package --package-version @version --default-domain @package --output @out @in
216 rule msgfmt {
217   description: 'MSGFMT @in'
218   >msgfmt --check --statistics --verbose --output-file @out @in
221 file target [ 'src/parse.c' 'src/parse.h' ] @ 'src/parse.y' {
222   yacc @files
224 file target [ 'src/scan.c' 'src/scan.h' ] @ 'src/scan.l' {
225   lex @files
227 file target [ 'src/sh-scan.c' 'src/sh-scan.h' ] @ 'src/sh-scan.l' {
228   lex @files
231 file target [ 'src/sh-parse.c' 'src/sh-parse.h' ] @ 'src/sh-parse.y' {
232   yacc @files
235 file target 'src/dep-scan.c' @ 'src/dep-scan.l' {
236   lex @files -> @target
239 variable sources = [
240   'src/blake3/blake3.c'
241   'src/blake3/blake3_dispatch.c'
242   'src/blake3/blake3_portable.c'
243   'src/build.c'
244 #  'src/dep-scan.c'
245   'src/diagnostic.c'
246   'src/graph.c'
247   'src/hash.c'
248   'src/job-server.c'
249   'src/libquote/localcharset.c'
250   'src/libquote/quotearg.c'
251   'src/option.c'
252   'src/parse.c'
253   'src/scan.c'
254   'src/sh-parse.c'
255   'src/sh-scan.c'
256   'src/sh.c'
257   'src/spawn.c'
258   'src/thread.c'
259   'src/uniqstr.c'
260   'src/utils.c'
261   'src/watchdog.c'
262   'src/yy.c'
265 # @sources.filter('%.c')
266 # map @sources ('%.c' -> compile -> '%.o')
267 map compile @sources ('%.c' -> '%.o')
268 variable objects = [ map @sources ('%.c' -> '%.o') ]
270 rule graph {
271   description: 'GRAPH'
272   >./build -g | dot -Tpng -ograph.png
275 target 'graph' {
276   graph
279 file target 'build' @ @objects {
280   link @files -> @target
283 target 'default': 'build' @mofiles
285 file target 'po/ru.po': @potfile {
286   msgmerge @dependencies -> @target
289 file target 'po/build.pot' @ @sources {
290   xgettext @files -> @target
293 file target 'po/locale/ru/LC_MESSAGES/build.mo': 'po/ru.po' {
294   msgfmt @dependencies -> @target
297 rule rm {
298   description: 'CLEAN'
299   >rm -f @in
302 target 'clean' {
303   rm @objects 'src/scan.h' 'src/scan.c' 'src/parse.h' 'src/parse.c' 'src/dep-scan.c' 'src/sh-scan.c' 'src/sh-parse.c' 'src/sh-parse.h'
307 #map @sources ('%.o' @ '%.c' ~ '%.d') { compile @in -> @out }
309 file target 'blake3/blake3.o' @ 'blake3/blake3.c' { compile @files -> @target }
310 file target 'blake3/blake3_dispatch.o' @ 'blake3/blake3_dispatch.c' { compile @files -> @target }
311 file target 'blake3/blake3_portable.o' @ 'blake3/blake3_portable.c' { compile @files -> @target }
312 file target 'build.o' @ 'build.c' { compile @files -> @target }
313 file target 'dep-scan.o' @ 'dep-scan.c' { compile @files -> @target }
314 file target 'diagnostic.o' @ 'diagnostic.c' { compile @files -> @target }
315 file target 'graph.o' @ 'graph.c' { compile @files -> @target }
316 file target 'hash.o' @ 'hash.c' { compile @files -> @target }
317 file target 'job-server.o' @ 'job-server.c' { compile @files -> @target }
318 file target 'libquote/localcharset.o' @ 'libquote/localcharset.c' { compile @files -> @target }
319 file target 'libquote/quotearg.o' @ 'libquote/quotearg.c' { compile @files -> @target }
320 file target 'option.o' @ 'option.c' { compile @files -> @target }
321 file target 'parse.o' @ 'parse.c' { compile @files -> @target }
322 file target 'scan.o' @ 'scan.c' { compile @files -> @target }
323 file target 'sh-parse.o' @ 'sh-parse.c' { compile @files -> @target }
324 file target 'sh-scan.o' @ 'sh-scan.c' { compile @files -> @target }
325 file target 'sh.o' @ 'sh.c' { compile @files -> @target }
326 file target 'spawn.o' @ 'spawn.c' { compile @files -> @target }
327 file target 'thread.o' @ 'thread.c' { compile @files -> @target }
328 file target 'uniqstr.o' @ 'uniqstr.c' { compile @files -> @target }
329 file target 'utils.o' @ 'utils.c' { compile @files -> @target }
330 file target 'watchdog.o' @ 'watchdog.c' { compile @files -> @target }
331 file target 'yy.o' @ 'yy.c' { compile @files -> @target }
334 #file target 'dep-scan.l'
335 #file target 'parse.y'
336 #file target 'scan.l'
337 #file target 'sh-parse.y'
338 #file target 'sh-scan.l'