Rev 6536 | Rev 6538 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5132 | clevermous | 1 | if tup.getconfig("NO_GCC") ~= "" or tup.getconfig("NO_FASM") ~= "" then return end |
2 | tup.include("../../../../../programs/use_gcc.lua") |
||
6536 | serge | 3 | CFLAGS = CFLAGS_OPTIMIZE_SPEED .. " -c -fno-builtin -DBUILD_LIBC -DMISSING_SYSCALL_NAMES" |
5132 | clevermous | 4 | LDFLAGS = "-shared -s -T libcdll.lds --out-implib $(SDK_DIR)/lib/libc.dll.a --image-base 0" |
5 | -- LDFLAGS = LDFLAGS .. " --output-def libc.orig.def" |
||
6 | |||
7 | SDK_DIR = "../../.." |
||
8 | |||
9 | LIBC_TOPDIR = "." |
||
10 | LIBC_INCLUDES = "include" |
||
11 | NAME = "libc" |
||
5216 | serge | 12 | DEFINES = "-D_IEEE_LIBM -DHAVE_RENAME" |
5132 | clevermous | 13 | INCLUDES = "-Iinclude" |
14 | |||
15 | TOOLCHAIN_LIBPATH = tup.getconfig("TOOLCHAIN_LIBPATH") |
||
16 | -- if not given explicitly in config, try to guess |
||
17 | if TOOLCHAIN_LIBPATH == "" then |
||
18 | if tup.getconfig("TUP_PLATFORM") == "win32" |
||
19 | then TOOLCHAIN_LIBPATH="C:\\MinGW\\msys\\1.0\\home\\autobuild\\tools\\win32\\mingw32\\lib" |
||
20 | else TOOLCHAIN_LIBPATH="/home/autobuild/tools/win32/mingw32/lib" |
||
21 | end |
||
22 | end |
||
23 | LIBPATH = "-L$(SDK_DIR)/lib -L$(TOOLCHAIN_LIBPATH)" |
||
6536 | serge | 24 | STATIC_SRCS = {"crt/start.S", "crt/crt1.c", "crt/crt2.c", "crt/exit.S"} |
25 | LIBDLL_SRCS = {"crt/dllstart.c", "crt/exit.S", "crt/pseudo-reloc.c", "crt/setjmp.S"} |
||
26 | LIBCDLL_SRCS = {"crt/crt2.c", "crt/pseudo-reloc.c", "crt/exit.S"} |
||
5132 | clevermous | 27 | CORE_SRCS = { |
28 | "argz/buf_findstr.c", "argz/envz_get.c", |
||
6536 | serge | 29 | "crt/console.asm", "crt/thread.S", "crt/cpu_features.c", "crt/tls.c", |
5132 | clevermous | 30 | "ctype/ctype_.c", "ctype/isascii.c", "ctype/isblank.c", "ctype/isalnum.c", |
31 | "ctype/isalpha.c", "ctype/iscntrl.c", "ctype/isdigit.c", "ctype/islower.c", |
||
32 | "ctype/isupper.c", "ctype/isprint.c", "ctype/ispunct.c", "ctype/isspace.c", |
||
33 | "ctype/iswctype.c", "ctype/iswalnum.c", "ctype/iswalpha.c", "ctype/iswblank.c", |
||
34 | "ctype/iswcntrl.c", "ctype/iswdigit.c", "ctype/iswgraph.c", "ctype/iswlower.c", |
||
35 | "ctype/iswprint.c", "ctype/iswpunct.c", "ctype/iswspace.c", "ctype/iswupper.c", |
||
36 | "ctype/iswxdigit.c", "ctype/isxdigit.c", "ctype/toascii.c", "ctype/tolower.c", |
||
37 | "ctype/toupper.c", "ctype/towctrans.c", "ctype/towlower.c", "ctype/towupper.c", |
||
38 | "ctype/wctrans.c", "ctype/wctype.c", |
||
39 | "errno/errno.c", |
||
40 | "locale/locale.c", "locale/lctype.c", "locale/ldpart.c", |
||
5216 | serge | 41 | |
42 | "reent/closer.c", "reent/fstatr.c", "reent/getreent.c", "reent/gettimeofdayr.c", |
||
43 | "reent/impure.c", "reent/init_reent.c", "reent/isattyr.c", "reent/linkr.c", |
||
44 | "reent/lseekr.c", "reent/mutex.c", "reent/openr.c", "reent/readr.c", |
||
6536 | serge | 45 | "reent/statr.c", "reent/timesr.c", "reent/unlinkr.c", |
5216 | serge | 46 | "reent/writer.c", |
5132 | clevermous | 47 | "search/qsort.c", "search/bsearch.c", |
48 | "signal/signal.c", |
||
6109 | serge | 49 | "sys/access.c", "sys/clock_gettime.c", "sys/close.c", "sys/conio.c", "sys/create.c", |
50 | "sys/errno.c", "sys/finfo.c", "sys/fsize.c", "sys/fstat.c", "sys/gettod.c", "sys/io.c", |
||
51 | "sys/ioread.c", "sys/iowrite.c", "sys/isatty.c", "sys/lseek.c", "sys/open.c", |
||
52 | "sys/read.c", "sys/_rename.c", "sys/stat.c", "sys/unlink.c", "sys/write.c", |
||
53 | "sys/io_alloc.S", "time/asctime.c", "time/asctime_r.c", "time/clock.c", "time/ctime.c", |
||
5132 | clevermous | 54 | "time/ctime_r.c", "time/difftime.c", "time/gettzinfo.c", "time/gmtime.c", |
6099 | serge | 55 | "time/gmtime_r.c", "time/mktime.c", "time/month_lengths.c", "time/lcltime.c", |
56 | "time/lcltime_r.c", "time/strftime.c", "time/time.c", "time/tzcalc_limits.c", |
||
57 | "time/timelocal.c", "time/tzlock.c", "time/tzset.c", "time/tzset_r.c", "time/tzvars.c" |
||
5132 | clevermous | 58 | } |
59 | STDLIB_SRCS = { |
||
6536 | serge | 60 | "__atexit.c", |
61 | "__call_atexit.c", |
||
62 | "abort.c", |
||
63 | "abs.c", |
||
64 | "assert.c", |
||
65 | "atexit.c", |
||
66 | "atof.c", |
||
67 | "atoi.c", |
||
68 | "atol.c", |
||
69 | "cxa_atexit.c", |
||
70 | "cxa_finalize.c", |
||
71 | "div.c", |
||
72 | "dtoa.c", |
||
73 | "dtoastub.c", |
||
74 | "efgcvt.c", |
||
75 | "ecvtbuf.c", |
||
76 | "eprintf.c", |
||
77 | "erand48.c", |
||
78 | "exit.c", |
||
79 | "gdtoa-gethex.c", |
||
80 | "gdtoa-hexnan.c", |
||
81 | "getenv.c", |
||
82 | "getenv_r.c", |
||
83 | "itoa.c", |
||
6537 | serge | 84 | "labs.c", |
6536 | serge | 85 | "mprec.c", |
86 | "mbtowc.c", |
||
87 | "mbtowc_r.c", |
||
88 | "mbrtowc.c", |
||
89 | "mlock.c", |
||
90 | "calloc.c", |
||
91 | "malloc.c", |
||
92 | "mallocr.c", |
||
93 | "rand.c", |
||
94 | "rand_r.c", |
||
95 | "rand48.c", |
||
96 | "realloc.c", |
||
97 | "seed48.c", |
||
98 | "srand48.c", |
||
99 | "strtod.c", |
||
100 | "strtodg.c", |
||
101 | "strtol.c", |
||
102 | "strtold.c", |
||
103 | "strtoll.c", |
||
104 | "strtoll_r.c", |
||
105 | "strtorx.c", |
||
106 | "strtoul.c", |
||
107 | "strtoull.c", |
||
108 | "strtoull_r.c", |
||
109 | "system.c", |
||
110 | "utoa.c", |
||
111 | "wcrtomb.c", |
||
6099 | serge | 112 | "wctomb_r.c" |
5132 | clevermous | 113 | } |
114 | STRING_SRCS = { |
||
6536 | serge | 115 | "memcpy.c", |
116 | "memcmp.c", |
||
117 | "memmove.c", |
||
118 | "memset.c", |
||
119 | "memchr.c", |
||
120 | "stpcpy.c", |
||
121 | "stpncpy.c", |
||
122 | "strcat.c", |
||
123 | "strchr.c", |
||
124 | "strcmp.c", |
||
125 | "strcoll.c", |
||
126 | "strcasecmp.c", |
||
127 | "strncasecmp.c", |
||
128 | "strncat.c", |
||
129 | "strncmp.c", |
||
130 | "strncpy.c", |
||
131 | "strndup.c", |
||
132 | "strndup_r.c", |
||
133 | "strnlen.c", |
||
134 | "strcasestr.c", |
||
135 | "strdup.c", |
||
136 | "strdup_r.c", |
||
137 | "strerror.c", |
||
138 | "strlen.c", |
||
139 | "strrchr.c", |
||
140 | "strpbrk.c", |
||
141 | "strsep.c", |
||
142 | "strstr.c", |
||
143 | "strtok.c", |
||
144 | "strtok_r.c", |
||
145 | "strupr.c", |
||
146 | "strxfrm.c", |
||
147 | "strcspn.c", |
||
148 | "strspn.c", |
||
149 | "strcpy.c", |
||
5132 | clevermous | 150 | "u_strerr.c" |
151 | } |
||
152 | |||
153 | STDIO_SRCS = { |
||
6536 | serge | 154 | "asiprintf.c", |
155 | "asniprintf.c", |
||
156 | "asnprintf.c", |
||
157 | "asprintf.c", |
||
158 | "clearerr.c", |
||
159 | "diprintf.c", |
||
160 | "dprintf.c", |
||
161 | "fclose.c", |
||
162 | "fcloseall.c", |
||
163 | "fdopen.c", |
||
164 | "feof.c", |
||
165 | "feof_u.c", |
||
166 | "ferror.c", |
||
167 | "ferror_u.c", |
||
168 | "fflush.c", |
||
169 | "fflush_u.c", |
||
170 | "fgetc.c", |
||
171 | "fgetc_u.c", |
||
172 | "fgetpos.c", |
||
173 | "fgets.c", |
||
174 | "fgets_u.c", |
||
175 | "fileno.c", |
||
176 | "fileno_u.c", |
||
177 | "findfp.c", |
||
178 | "fiprintf.c", |
||
179 | "fiscanf.c", |
||
180 | "flags.c", |
||
181 | "fmemopen.c", |
||
182 | "fopen.c", |
||
183 | "fopencookie.c", |
||
184 | "fprintf.c", |
||
185 | "fpurge.c", |
||
186 | "fputc.c", |
||
187 | "fputc_u.c", |
||
188 | "fputs.c", |
||
189 | "fputs_u.c", |
||
190 | "fputwc.c", |
||
191 | "fsetpos.c", |
||
192 | "fread.c", |
||
193 | "fread_u.c", |
||
194 | "freopen.c", |
||
195 | "fscanf.c", |
||
196 | "fseek.c", |
||
197 | "fseeko.c", |
||
198 | "fsetlocking.c", |
||
199 | "ftell.c", |
||
200 | "ftello.c", |
||
201 | "fvwrite.c", |
||
202 | "fwalk.c", |
||
203 | "fwide.c", |
||
204 | "fwrite.c", |
||
205 | "fwrite_u.c", |
||
206 | "getc.c", |
||
207 | "getc_u.c", |
||
208 | "getchar.c", |
||
209 | "getchar_u.c", |
||
210 | "getdelim.c", |
||
211 | "getline.c", |
||
212 | "gets.c", |
||
213 | "iprintf.c", |
||
214 | "iscanf.c", |
||
215 | "makebuf.c", |
||
216 | "mbstowcs.c", |
||
217 | "mktemp.c", |
||
218 | "open_memstream.c", |
||
219 | "perror.c", |
||
220 | "printf.c", |
||
221 | "putc.c", |
||
222 | "putc_u.c", |
||
223 | "putchar.c", |
||
224 | "putchar_u.c", |
||
225 | "puts.c", |
||
226 | "refill.c", |
||
227 | "remove.c", |
||
228 | "rename.c", |
||
229 | "rewind.c", |
||
230 | "rget.c", |
||
231 | "scanf.c", |
||
232 | "sccl.c", |
||
233 | "setbuf.c", |
||
234 | "setbuffer.c", |
||
235 | "setlinebuf.c", |
||
236 | "setvbuf.c", |
||
237 | "siprintf.c", |
||
238 | "siscanf.c", |
||
239 | "sniprintf.c", |
||
240 | "snprintf.c", |
||
241 | "sprintf.c", |
||
242 | "sscanf.c", |
||
243 | "stdio.c", |
||
244 | "stdio_ext.c", |
||
245 | "tmpfile.c", |
||
246 | "tmpnam.c", |
||
247 | "ungetc.c", |
||
248 | "vasiprintf.c", |
||
249 | "vasniprintf.c", |
||
250 | "vasnprintf.c", |
||
251 | "vasprintf.c", |
||
252 | "vdiprintf.c", |
||
253 | "vdprintf.c", |
||
254 | "viprintf.c", |
||
255 | "viscanf.c", |
||
256 | "vprintf.c", |
||
257 | "vscanf.c", |
||
258 | "vsiprintf.c", |
||
259 | "vsiscanf.c", |
||
260 | "vsprintf.c", |
||
261 | "vsniprintf.c", |
||
262 | "vsnprintf.c", |
||
263 | "vsscanf.c", |
||
264 | "wsetup.c", |
||
265 | "wbuf.c" |
||
6537 | serge | 266 | } |
6099 | serge | 267 | |
5132 | clevermous | 268 | |
269 | MATH_SRCS = { |
||
270 | "e_acos.c", "e_acosh.c", "e_asin.c", "e_atan2.c", "e_atanh.c", "e_cosh.c", "e_exp.c", "e_fmod.c", |
||
271 | "e_hypot.c", "e_j0.c", "e_j1.c", "e_jn.c", "e_log.c", "e_log10.c", "e_pow.c", "e_rem_pio2.c", |
||
272 | "e_remainder.c", "e_scalb.c", "e_sinh.c", "e_sqrt.c", "ef_acos.c", "ef_acosh.c", "ef_asin.c", |
||
273 | "ef_atan2.c", "ef_atanh.c", "ef_cosh.c", "ef_exp.c", "ef_fmod.c", "ef_hypot.c", "ef_j0.c", "ef_j1.c", |
||
274 | "ef_jn.c", "ef_log.c", "ef_log10.c", "ef_pow.c", "ef_rem_pio2.c", "ef_remainder.c", "ef_scalb.c", |
||
275 | "ef_sinh.c", "ef_sqrt.c", "er_gamma.c", "er_lgamma.c", "erf_gamma.c", "erf_lgamma.c", "f_exp.c", |
||
276 | "f_expf.c", "f_llrint.c", "f_llrintf.c", "f_llrintl.c", "f_lrint.c", "f_lrintf.c", "f_lrintl.c", |
||
5141 | serge | 277 | "f_pow.c", "f_powf.c", "f_rint.c", "f_rintf.c", "f_rintl.c", "feclearexcept.c", "fetestexcept.c", |
278 | "k_cos.c", "k_rem_pio2.c", "k_sin.c", "k_standard.c", "k_tan.c", "kf_cos.c", "kf_rem_pio2.c", "kf_sin.c", |
||
279 | "kf_tan.c", "s_asinh.c", "s_atan.c", "s_cbrt.c", "s_ceil.c", "s_copysign.c", "s_cos.c", "s_erf.c", "s_exp10.c", "s_expm1.c", |
||
5132 | clevermous | 280 | "s_fabs.c", "s_fdim.c", "s_finite.c", "s_floor.c", "s_fma.c", "s_fmax.c", "s_fmin.c", "s_fpclassify.c", |
281 | "s_frexp.c", "s_ilogb.c", "s_infconst.c", "s_infinity.c", "s_isinf.c", "s_isinfd.c", "s_isnan.c", |
||
282 | "s_isnand.c", "s_ldexp.c", "s_lib_ver.c", "s_llrint.c", "s_llround.c", "s_log1p.c", "s_log2.c", |
||
283 | "s_logb.c", "s_lrint.c", "s_lround.c", "s_matherr.c", "s_modf.c", "s_nan.c", "s_nearbyint.c", |
||
284 | "s_nextafter.c", "s_pow10.c", "s_remquo.c", "s_rint.c", "s_round.c", "s_scalbln.c", "s_scalbn.c", |
||
285 | "s_signbit.c", "s_signif.c", "s_sin.c", "s_tan.c", "s_tanh.c", "s_trunc.c", "scalblnl.c", "scalbnl.c", |
||
286 | "sf_asinh.c", "sf_atan.c", "sf_cbrt.c", "sf_ceil.c", "sf_copysign.c", "sf_cos.c", "sf_erf.c", |
||
287 | "sf_exp10.c", "sf_expm1.c", "sf_fabs.c", "sf_fdim.c", "sf_finite.c", "sf_floor.c", "sf_fma.c", |
||
288 | "sf_fmax.c", "sf_fmin.c", "sf_fpclassify.c", "sf_frexp.c", "sf_ilogb.c", "sf_infinity.c", |
||
289 | "sf_isinf.c", "sf_isinff.c", "sf_isnan.c", "sf_isnanf.c", "sf_ldexp.c", "sf_llrint.c", |
||
290 | "sf_llround.c", "sf_log1p.c", "sf_log2.c", "sf_logb.c", "sf_lrint.c", "sf_lround.c", "sf_modf.c", |
||
291 | "sf_nan.c", "sf_nearbyint.c", "sf_nextafter.c", "sf_pow10.c", "sf_remquo.c", "sf_rint.c", |
||
292 | "sf_round.c", "sf_scalbln.c", "sf_scalbn.c", "sf_signif.c", "sf_sin.c", "sf_tan.c", "sf_tanh.c", |
||
293 | "sf_trunc.c", "w_acos.c", "w_acosh.c", "w_asin.c", "w_atan2.c", "w_atanh.c", "w_cosh.c", "w_drem.c", |
||
294 | "w_exp.c", "w_exp2.c", "w_fmod.c", "w_gamma.c", "w_hypot.c", "w_j0.c", "w_j1.c", "w_jn.c", "w_lgamma.c", |
||
295 | "w_log.c", "w_log10.c", "w_pow.c", "w_remainder.c", "w_scalb.c", "w_sincos.c", "w_sinh.c", "w_sqrt.c", |
||
296 | "w_tgamma.c", "wf_acos.c", "wf_acosh.c", "wf_asin.c", "wf_atan2.c", "wf_atanh.c", "wf_cosh.c", |
||
297 | "wf_drem.c", "wf_exp.c", "wf_exp2.c", "wf_fmod.c", "wf_gamma.c", "wf_hypot.c", "wf_j0.c", "wf_j1.c", |
||
298 | "wf_jn.c", "wf_lgamma.c", "wf_log.c", "wf_log10.c", "wf_pow.c", "wf_remainder.c", "wf_scalb.c", |
||
299 | "wf_sincos.c", "wf_sinh.c", "wf_sqrt.c", "wf_tgamma.c", "wr_gamma.c", "wr_lgamma.c", "wrf_gamma.c", |
||
300 | "wrf_lgamma.c", |
||
301 | "f_atan2.S", "f_atan2f.S", "f_frexp.S", "f_frexpf.S", "f_ldexp.S", "f_ldexpf.S", "f_log.S", |
||
302 | "f_log10.S", "f_log10f.S", "f_logf.S", "f_tan.S", "f_tanf.S" |
||
303 | } |
||
304 | |||
305 | function prepend(what, to) |
||
306 | local result = {} |
||
307 | for i,v in ipairs(to) do |
||
308 | table.insert(result, what .. v) |
||
309 | end |
||
310 | return result |
||
311 | end |
||
312 | |||
313 | -- make shared |
||
314 | LIB_SRCS = LIBCDLL_SRCS |
||
315 | |||
316 | LIB_SRCS += CORE_SRCS |
||
317 | LIB_SRCS += prepend("stdio/", STDIO_SRCS) |
||
318 | LIB_SRCS += prepend("string/", STRING_SRCS) |
||
319 | LIB_SRCS += prepend("stdlib/", STDLIB_SRCS) |
||
320 | LIB_SRCS += prepend("math/", MATH_SRCS) |
||
321 | |||
322 | ALL_OBJS = {} |
||
323 | function compile(list) |
||
324 | local result = {} |
||
325 | for i,v in ipairs(list) do |
||
326 | if ALL_OBJS[v] then |
||
327 | -- already compiled |
||
328 | elseif v:sub(-2) == ".c" or v:sub(-2) == ".S" then |
||
329 | ALL_OBJS[v] = tup.rule(v, "kos32-gcc $(CFLAGS) $(DEFINES) $(INCLUDES) -o %o %f", v:sub(1, -3) .. ".o") |
||
330 | elseif v:sub(-4) == ".asm" then |
||
331 | ALL_OBJS[v] = tup.rule(v, "fasm %f %o", v:sub(1, -5) .. ".obj") |
||
332 | end |
||
333 | result += ALL_OBJS[v] |
||
334 | end |
||
335 | return result |
||
336 | end |
||
337 | |||
338 | LIB_OBJS = compile(LIB_SRCS) |
||
6537 | serge | 339 | LIB_OBJS += tup.rule("crt/crtdll.c", "kos32-gcc $(CFLAGS) $(DEFINES) $(INCLUDES) -fno-delete-null-pointer-checks -c %f -o %o","crt/crtdll.o") |
340 | LIB_OBJS += tup.rule("pe/loader.c", "kos32-gcc $(CFLAGS) $(DEFINES) $(INCLUDES) -fno-delete-null-pointer-checks -c %f -o %o", "pe/loader.o") |
||
341 | LIB_OBJS += tup.rule("reent/renamer.c", "kos32-gcc $(CFLAGS) $(DEFINES) $(INCLUDES) -D_COMPILING_NEWLIB -c %f -o %o", "reent/renamer.o") |
||
6536 | serge | 342 | |
5132 | clevermous | 343 | LIBDLL_OBJS = compile(LIBDLL_SRCS) |
344 | |||
6536 | serge | 345 | |
5132 | clevermous | 346 | vfprintf_extra_objs = { |
6536 | serge | 347 | {"", "stdio/vfprintf.o"}, |
5132 | clevermous | 348 | {"-DINTEGER_ONLY", "stdio/vfiprintf.o"}, |
349 | {"-DSTRING_ONLY", "stdio/svfprintf.o"}, |
||
350 | {"-DINTEGER_ONLY -DSTRING_ONLY", "stdio/svfiprintf.o"}, |
||
351 | } |
||
352 | for i,v in ipairs(vfprintf_extra_objs) do |
||
353 | LIB_OBJS += tup.rule("stdio/vfprintf.c", "kos32-gcc $(CFLAGS) $(DEFINES) $(INCLUDES) -fshort-enums " .. v[1] .. " -c %f -o %o", v[2]) |
||
354 | end |
||
355 | |||
356 | vfscanf_extra_objs = { |
||
357 | {"", "stdio/vfscanf.o"}, |
||
358 | {"-DINTEGER_ONLY", "stdio/vfiscanf.o"}, |
||
359 | {"-DSTRING_ONLY", "stdio/svscanf.o"}, |
||
360 | {"-DINTEGER_ONLY -DSTRING_ONLY", "stdio/svfiscanf.o"}, |
||
361 | } |
||
362 | for i,v in ipairs(vfscanf_extra_objs) do |
||
6536 | serge | 363 | LIB_OBJS += tup.rule("stdio/vfscanf.c", "kos32-gcc $(CFLAGS) $(DEFINES) $(INCLUDES) " .. v[1] .. " -c %f -o %o", v[2]) |
5132 | clevermous | 364 | end |
365 | |||
366 | tup.rule(LIB_OBJS, "kos32-ld " .. LDFLAGS .. " " .. LIBPATH .. " -o %o %f -lgcc --version-script libc.ver " .. tup.getconfig("KPACK_CMD"), |
||
367 | {SDK_DIR .. "/bin/libc.dll", extra_outputs = {SDK_DIR .. "/lib/libc.dll.a", SDK_DIR .. "/lib/ |
||
368 | tup.rule(LIBDLL_OBJS, "kos32-ar rcs %o %f", {SDK_DIR .. "/lib/libdll.a", extra_outputs = {SDK_DIR .. "/lib/ |