Subversion Repositories Kolibri OS

Rev

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