Rev 5132 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5132 | Rev 6549 | ||
---|---|---|---|
1 | CFLAGS_GENERIC = "-fno-ident -fomit-frame-pointer -fno-stack-check -fno-stack-protector -mno-stack-arg-probe -fno-exceptions -fno-asynchronous-unwind-tables -ffast-math -mno-ms-bitfields -march=pentium-mmx" |
1 | CFLAGS_GENERIC = "-fno-ident -fomit-frame-pointer -fno-stack-check -fno-stack-protector -mno-stack-arg-probe -fno-exceptions -fno-asynchronous-unwind-tables -ffast-math -mno-ms-bitfields -march=pentium-mmx" |
2 | CFLAGS_OPTIMIZE_SIZE = "-Os -mpreferred-stack-boundary=2 " .. CFLAGS_GENERIC |
2 | CFLAGS_OPTIMIZE_SIZE = "-Os -mpreferred-stack-boundary=2 " .. CFLAGS_GENERIC |
3 | CFLAGS_OPTIMIZE_SPEED = "-O2 -mpush-args -mno-accumulate-outgoing-args " .. CFLAGS_GENERIC |
3 | CFLAGS_OPTIMIZE_SPEED = "-O2 -mpush-args -mno-accumulate-outgoing-args " .. CFLAGS_GENERIC |
4 | -- The following could in specific cases be marginally faster CFLAGS_OPTIMIZE_SPEED, |
4 | -- The following could in specific cases be marginally faster CFLAGS_OPTIMIZE_SPEED, |
5 | -- and in all cases gives a notable overhead in size. |
5 | -- and in all cases gives a notable overhead in size. |
6 | CFLAGS_OPTIMIZE_SPEED_INSANE = "-O2 " .. CFLAGS_GENERIC |
6 | CFLAGS_OPTIMIZE_SPEED_INSANE = "-O2 " .. CFLAGS_GENERIC |
7 | -- Default is optimizing by size. Override on per-project or per-file basis. |
7 | -- Default is optimizing by size. Override on per-project or per-file basis. |
8 | CFLAGS = CFLAGS_OPTIMIZE_SIZE |
8 | CFLAGS = CFLAGS_OPTIMIZE_SIZE |
9 | 9 | ||
10 | CFLAGS_c = "" -- extra flags for *.c |
10 | CFLAGS_c = "" -- extra flags for *.c |
11 | CFLAGS_cpp = " -fno-rtti" -- extra flags for *.cpp |
11 | CFLAGS_cpp = " -fno-rtti" -- extra flags for *.cpp |
12 | LDFLAGS = "-nostdlib -n --file-alignment=16 --section-alignment=16" |
12 | LDFLAGS = "-static -nostdlib -n --file-alignment=16 --section-alignment=16" |
13 | INCLUDES = "" |
13 | INCLUDES = "" |
14 | LIBS = "" |
14 | LIBS = "" |
15 | LIBDEPS = {} |
15 | LIBDEPS = {} |
16 | OBJS = {} |
16 | OBJS = {} |
17 | 17 | ||
18 | function compile_gcc(input, output) |
18 | function compile_gcc(input, output) |
19 | if not output then output = '%B.o' end |
19 | if not output then output = '%B.o' end |
20 | tup.append_table(OBJS, |
20 | tup.append_table(OBJS, |
21 | tup.foreach_rule(input, "kos32-gcc -c " .. CFLAGS .. "$(CFLAGS_%e) " .. INCLUDES .. " -o %o %f", output) |
21 | tup.foreach_rule(input, "kos32-gcc -c " .. CFLAGS .. "$(CFLAGS_%e) " .. INCLUDES .. " -o %o %f", output) |
22 | ) |
22 | ) |
23 | end |
23 | end |
24 | 24 | ||
25 | function link_gcc(input, output) |
25 | function link_gcc(input, output) |
26 | if not output then input,output = OBJS,input end |
26 | if not output then input,output = OBJS,input end |
27 | if STARTUP then |
27 | if STARTUP then |
28 | table.insert(LIBDEPS, STARTUP) |
28 | table.insert(LIBDEPS, STARTUP) |
29 | LDFLAGS = LDFLAGS .. " " .. STARTUP |
29 | LDFLAGS = LDFLAGS .. " " .. STARTUP |
30 | end |
30 | end |
31 | if tup.getconfig("HELPERDIR") == "" and #LIBDEPS then |
31 | if tup.getconfig("HELPERDIR") == "" and #LIBDEPS then |
32 | if type(input) == "string" then input = {input} end |
32 | if type(input) == "string" then input = {input} end |
33 | if not input.extra_inputs then input.extra_inputs = {} end |
33 | if not input.extra_inputs then input.extra_inputs = {} end |
34 | tup.append_table(input.extra_inputs, LIBDEPS) |
34 | tup.append_table(input.extra_inputs, LIBDEPS) |
35 | end |
35 | end |
36 | 36 | ||
37 | if type(output) == "string" then output = {output} end |
37 | if type(output) == "string" then output = {output} end |
38 | if not output.extra_outputs then output.extra_outputs = {} end |
38 | if not output.extra_outputs then output.extra_outputs = {} end |
39 | table.insert(output.extra_outputs, output[1] .. ".map") |
39 | table.insert(output.extra_outputs, output[1] .. ".map") |
40 | 40 | ||
41 | tup.rule(input, |
41 | tup.rule(input, |
42 | "kos32-ld " .. LDFLAGS .. " -o %o %f -Map %o.map " .. LIBS .. " && kos32-objcopy %o -O binary " .. tup.getconfig("KPACK_CMD"), |
42 | "kos32-ld " .. LDFLAGS .. " -o %o %f -Map %o.map " .. LIBS .. " && kos32-objcopy %o -O binary " .. tup.getconfig("KPACK_CMD"), |
43 | output) |
43 | output) |
44 | end |
44 | end |