Subversion Repositories Kolibri OS

Rev

Rev 1907 | Blame | Last modification | View Log | Download | RSS feed

  1.  
  2. CC = gcc
  3.  
  4. CFLAGS = -c -O2 -fomit-frame-pointer
  5. LDFLAGS = -nostdlib -shared -s -T libcdll.lds --out-implib libcimp.a --image-base 0
  6.  
  7. LIBC_TOPDIR   = .
  8. LIBC_INCLUDES = $(LIBC_TOPDIR)/include
  9.  
  10. NAME:=    libc
  11.  
  12. DEFINES:=  
  13.  
  14. INCLUDES:=  -I $(LIBC_INCLUDES)
  15.  
  16. AMZ_SRCS:=                                      \
  17.                         crt/crt_amz.S           \
  18.                         crt/chkstk.S            \
  19.                         crt/exit.S              \
  20.                         crt/pseudo-reloc.c      \
  21.                         crt/setjmp.S
  22.                        
  23. STATIC_SRCS:=                                   \
  24.                         crt/start.S             \
  25.                         crt/crt1.c              \
  26.                         crt/chkstk.S            \
  27.                         crt/exit.S              \
  28.                         crt/setjmp.S           
  29.  
  30. DLL_SRCS:=                                      \
  31.                         crt/crtdll.c            \
  32.                         crt/chkstk.S            \
  33.                         crt/exit.S              \
  34.                         crt/setjmp.S            \
  35.                         pe/loader.c
  36.  
  37. CORE_SRCS:=                                     \
  38.                         argz/buf_findstr.c      \
  39.                         argz/envz_get.c         \
  40.                         crt/emutls.c            \
  41.                         crt/thread.S            \
  42.                         crt/tls.S               \
  43.                         crt/assert.c            \
  44.                         crt/cpu_features.c      \
  45.                         ctype/ctype_.c          \
  46.                         ctype/isascii.c         \
  47.                         ctype/isblank.c         \
  48.                         ctype/isalnum.c         \
  49.                         ctype/isalpha.c         \
  50.                         ctype/iscntrl.c         \
  51.                         ctype/isdigit.c         \
  52.                         ctype/islower.c         \
  53.                         ctype/isupper.c         \
  54.                         ctype/isprint.c         \
  55.                         ctype/ispunct.c         \
  56.                         ctype/isspace.c         \
  57.                         ctype/iswctype.c        \
  58.                         ctype/iswalnum.c        \
  59.                         ctype/iswalpha.c        \
  60.                         ctype/iswblank.c        \
  61.                         ctype/iswcntrl.c        \
  62.                         ctype/iswdigit.c        \
  63.                         ctype/iswgraph.c        \
  64.                         ctype/iswlower.c        \
  65.                         ctype/iswprint.c        \
  66.                         ctype/iswpunct.c        \
  67.                         ctype/iswspace.c        \
  68.                         ctype/iswupper.c        \
  69.                         ctype/iswxdigit.c       \
  70.                         ctype/isxdigit.c        \
  71.                         ctype/toascii.c         \
  72.                         ctype/tolower.c         \
  73.                         ctype/toupper.c         \
  74.                         ctype/towctrans.c       \
  75.                         ctype/towlower.c        \
  76.                         ctype/towupper.c        \
  77.                         ctype/wctrans.c         \
  78.                         ctype/wctype.c          \
  79.                         errno/errno.c           \
  80.                         locale/locale.c         \
  81.                         locale/lctype.c         \
  82.                         reent/impure.c          \
  83.                         reent/getreent.c        \
  84.                         reent/gettimeofdayr.c   \
  85.                         reent/hdlman.c          \
  86.                         reent/isattyr.c         \
  87.                         reent/openr.c           \
  88.                         reent/closer.c          \
  89.                         reent/readr.c           \
  90.                         reent/lseekr.c          \
  91.                         reent/fstatr.c          \
  92.                         reent/writer.c          \
  93.                         search/qsort.c          \
  94.                         search/bsearch.c        \
  95.                         signal/signal.c         \
  96.                         sys/create.c            \
  97.                         sys/delete.c            \
  98.                         sys/finfo.c             \
  99.                         sys/read.c              \
  100.                         sys/write.c             \
  101.                         sys/fsize.c             \
  102.                         sys/fload.c             \
  103.                         time/asctime.c          \
  104.                         time/asctime_r.c        \
  105.                         time/clock.c            \
  106.                         time/ctime.c            \
  107.                         time/ctime_r.c          \
  108.                         time/difftime.c         \
  109.                         time/gettzinfo.c        \
  110.                         time/gmtime.c           \
  111.                         time/gmtime_r.c         \
  112.                         time/mktime.c           \
  113.                         time/mktm_r.c           \
  114.                         time/lcltime.c          \
  115.                         time/lcltime_r.c        \
  116.                         time/strftime.c         \
  117.                         time/time.c             \
  118.                         time/tzlock.c           \
  119.                         time/tzvars.c           \
  120.                         unpack/unpacker.asm    
  121.  
  122.  
  123. STDLIB_SRCS=                            \
  124.                         __atexit.c      \
  125.                         __call_atexit.c \
  126.                         abort.c         \
  127.                         abs.c           \
  128.                         atof.c          \
  129.                         atoi.c          \
  130.                         div.c           \
  131.                         dtoa.c          \
  132.                         dtoastub.c      \
  133.                         exit.c          \
  134.                         gdtoa-gethex.c  \
  135.                         gdtoa-hexnan.c  \
  136.                         getenv.c        \
  137.                         mprec.c         \
  138.                         mbtowc.c        \
  139.                         mbtowc_r.c      \
  140.                         mbrtowc.c       \
  141.                         mlock.c         \
  142.                         calloc.c        \
  143.                         malloc.c        \
  144.                         mallocr.c       \
  145.                         rand.c          \
  146.                         rand_r.c        \
  147.                         rand48.c        \
  148.                         realloc.c       \
  149.                         seed48.c        \
  150.                         srand48.c       \
  151.                         strtod.c        \
  152.                         strtol.c        \
  153.                         strtold.c       \
  154.                         strtoll.c       \
  155.                         strtoll_r.c     \
  156.                         strtoul.c       \
  157.                         strtoull.c      \
  158.                         strtoull_r.c    \
  159.                         system.c        \
  160.                         wcrtomb.c       \
  161.                         wctomb_r.c     
  162.  
  163.  
  164. STRING_SRCS=            memcpy.c        \
  165.                         memcmp.c        \
  166.                         memmove.c       \
  167.                         memset.c        \
  168.                         memchr.c        \
  169.                         strcat.c        \
  170.                         strchr.c        \
  171.                         strcmp.c        \
  172.                         strcoll.c       \
  173.                         strcasecmp.c    \
  174.                         strncasecmp.c   \
  175.                         strncat.c       \
  176.                         strncmp.c       \
  177.                         strncpy.c       \
  178.                         strndup.c       \
  179.                         strndup_r.c     \
  180.                         strnlen.c       \
  181.                         strcasestr.c    \
  182.                         strdup.c        \
  183.                         strdup_r.c      \
  184.                         strerror.c      \
  185.                         strlen.c        \
  186.                         strrchr.c       \
  187.                         strpbrk.c       \
  188.                         strsep.c        \
  189.                         strstr.c        \
  190.                         strtok.c        \
  191.                         strtok_r.c      \
  192.                         strupr.c        \
  193.                         strcspn.c       \
  194.                         strspn.c        \
  195.                         strcpy.c        \
  196.                         u_strerr.c
  197.  
  198. STDIO_SRCS=                             \
  199.                         printf.c        \
  200.                         putchar.c       \
  201.                         fgets.c         \
  202.                         fopen.c         \
  203.                         fclose.c        \
  204.                         fdopen.c        \
  205.                         fflush.c        \
  206.                         flags.c         \
  207.                         findfp.c        \
  208.                         fiprintf.c      \
  209.                         fiscanf.c       \
  210.                         fprintf.c       \
  211.                         fputc.c         \
  212.                         fputs.c         \
  213.                         fputwc.c        \
  214.                         fread.c         \
  215.                         freopen.c       \
  216.                         fscanf.c        \
  217.                         fseek.c         \
  218.                         fseeko.c        \
  219.                         ftell.c         \
  220.                         ftello.c        \
  221.                         fwrite.c        \
  222.                         fvwrite.c       \
  223.                         fwalk.c         \
  224.                         putc.c          \
  225.                         puts.c          \
  226.                         refill.c        \
  227.                         rget.c          \
  228.                         remove.c        \
  229.                         rename.c        \
  230.                         setvbuf.c       \
  231.                         stdio.c         \
  232.                         tmpfile.c       \
  233.                         tmpnam.c        \
  234.                         ungetc.c        \
  235.                         vscanf.c        \
  236.                         vsprintf.c      \
  237.                         vsnprintf.c     \
  238.                         vsscanf.c       \
  239.                         makebuf.c       \
  240.                         wsetup.c        \
  241.                         wbuf.c          \
  242.                         sccl.c          \
  243.                         snprintf.c      \
  244.                         sprintf.c       \
  245.                         sscanf.c
  246.        
  247.  
  248. MATH_SRCS =     acosf.c acosh.c acoshf.c acoshl.c acosl.c asinf.c asinh.c asinhf.c asinhl.c \
  249.                 asinl.c atan2f.c atan2l.c atanf.c atanh.c atanhf.c atanhl.c atanl.c cbrt.c \
  250.                 cbrtf.c cbrtl.c coshf.c coshl.c erfl.c expf.c expl.c expm1.c expm1f.c expm1l.c\
  251.                 fabs.c fabsf.c fabsl.c fdim.c fdimf.c fdiml.c fmal.c fmax.c fmaxf.c fmaxl.c\
  252.                 fmin.c fminf.c fminl.c fmodf.c fmodl.c fp_consts.c fp_constsf.c fp_constsl.c\
  253.                 fpclassify.c fpclassifyf.c fpclassifyl.c frexpf.c fucom.c hypotf.c isnan.c \
  254.                 isnanf.c isnanl.c ldexp.c ldexpf.c ldexpl.c lgamma.c lgammaf.c lgammal.c \
  255.                 llrint.c llrintf.c llrintl.c logb.c logbf.c logbl.c lrint.c lrintf.c lrintl.c\
  256.                 lround_generic.c modff.c modfl.c nextafterf.c nextafterl.c nexttoward.c \
  257.                 nexttowardf.c pow.c powf.c powi.c powif.c powil.c powl.c rint.c rintf.c \
  258.                 rintl.c round_generic.c s_erf.c sf_erf.c signbit.c signbitf.c signbitl.c \
  259.                 sinhf.c sinhl.c sqrtf.c sqrtl.c tanhf.c tanhl.c tgamma.c tgammaf.c tgammal.c \
  260.                 trunc.c truncf.c truncl.c e_sqrt.c e_sinh.c e_cosh.c e_hypot.c s_tanh.c \
  261.                 s_roundf.c s_fpclassify.c s_isnand.c w_hypot.c s_modf.c e_atan2.c w_atan2.c\
  262.                 ceil.S ceilf.S ceill.S copysign.S copysignf.S copysignl.S cos.S cosf.S cosl.S exp.S exp2.S \
  263.                 exp2f.S exp2l.S floor.S floorf.S floorl.S fma.S fmaf.S frexp.S frexpl.S ilogb.S ilogbf.S \
  264.                 ilogbl.S log10.S log10f.S log10l.S log1p.S log1pf.S log1pl.S log2.S log2f.S log2l.S \
  265.                 log.S logf.S logl.S nearbyint.S nearbyintf.S nearbyintl.S remainder.S remainderf.S \
  266.                 remainderl.S remquo.S remquof.S remquol.S scalbn.S scalbnf.S scalbnl.S sin.S \
  267.                 sinf.S sinl.S tan.S tanf.S tanl.S s_expm1.S
  268.  
  269.  
  270. AMZ_OBJS =  $(patsubst %.S, %.o, $(patsubst %.c, %.o, $(AMZ_SRCS)))
  271.  
  272. STATIC_OBJS =  $(patsubst %.S, %.o, $(patsubst %.c, %.o, $(STATIC_SRCS)))
  273.  
  274. DLL_OBJS =  $(patsubst %.S, %.o, $(patsubst %.c, %.o, $(DLL_SRCS)))
  275.  
  276. CORE_OBJS =  $(patsubst %.S, %.o, $(patsubst %.asm, %.obj,\
  277.             $(patsubst %.c, %.o, $(CORE_SRCS))))
  278.  
  279. STDIO_OBJS =  $(patsubst %.c, stdio/%.o,$(STDIO_SRCS))
  280.  
  281.  
  282. STRING_OBJS =  $(patsubst %.S, string/%.o, $(patsubst %.asm, string/%.o,\
  283.                $(patsubst %.c, string/%.o, $(STRING_SRCS))))
  284.  
  285. STDLIB_OBJS =  $(patsubst %.S, stdlib/%.o, $(patsubst %.asm, stdlib/%.o,\
  286.                $(patsubst %.c, stdlib/%.o, $(STDLIB_SRCS))))
  287.  
  288.  
  289. MATH_OBJS =  $(patsubst %.S, math/%.o, $(patsubst %.asm, math/%.o,\
  290.                $(patsubst %.c, math/%.o, $(MATH_SRCS))))
  291.  
  292.  
  293. PRINTF_OBJS=    stdio/vfprintf.o        \
  294.                 stdio/vfiprintf.o       \
  295.                 stdio/svfprintf.o       \
  296.                 stdio/svfiprintf.o      \
  297.                 stdio/vfscanf.o         \
  298.                 stdio/vfiscanf.o        \
  299.                 stdio/svscanf.o         \
  300.                 stdio/svfiscanf.o
  301.  
  302. ifeq ($(findstring static,$(MAKECMDGOALS)),static)
  303.  
  304. LIB_SRCS:=      $(STATIC_SRCS)
  305. LIB_OBJS:=      $(STATIC_OBJS)
  306.  
  307. else
  308.  
  309. LIB_SRCS:=      $(DLL_SRCS)
  310. LIB_OBJS:=      $(DLL_OBJS)
  311.  
  312. endif
  313.  
  314. LIB_SRCS+=                              \
  315.                 $(CORE_SRCS)            \
  316.                 $(STDIO_SRCS)           \
  317.                 $(STRING_SRCS)          \
  318.                 $(STDLIB_SRCS)
  319.  
  320. LIB_OBJS+=                              \
  321.                 $(CORE_OBJS)            \
  322.                 $(STRING_OBJS)          \
  323.                 $(STDLIB_OBJS)          \
  324.                 $(STDIO_OBJS)           \
  325.                 $(PRINTF_OBJS)          \
  326.                 $(MATH_OBJS)
  327.  
  328.  
  329.  
  330. shared: $(NAME).dll libamz.a libc.obj
  331.  
  332.  
  333. $(NAME).dll: $(LIB_OBJS) $(SRC_DEP) Makefile
  334.         ld $(LDFLAGS) -L. -o $@ $(LIB_OBJS) -lgcc
  335.  
  336.  
  337. libamz.a: $(AMZ_OBJS) Makefile
  338.         ar rc libamz.a $(AMZ_OBJS)
  339.  
  340. libc.obj: $(NAME).dll
  341.         fasm pe/libc.asm ./libc.obj
  342.  
  343.  
  344. static: $(NAME).a
  345.  
  346. $(NAME).a: $(LIB_OBJS) $(SRC_DEP) Makefile
  347.         ar rc $(NAME).a $(LIB_OBJS)
  348.  
  349.  
  350.  
  351. stdio/vfprintf.o: stdio/vfprintf.c
  352.         $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -fshort-enums -DFLOATING_POINT -c stdio/vfprintf.c -o $@
  353.  
  354. stdio/vfiprintf.o: stdio/vfprintf.c
  355.         $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -fshort-enums -DINTEGER_ONLY -c stdio/vfprintf.c -o $@
  356.  
  357. stdio/svfprintf.o: stdio/vfprintf.c
  358.         $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -fshort-enums -DSTRING_ONLY -c stdio/vfprintf.c -o $@
  359.  
  360. stdio/svfiprintf.o: stdio/vfprintf.c
  361.         $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -fshort-enums -DINTEGER_ONLY -DSTRING_ONLY -c stdio/vfprintf.c -o $@
  362.  
  363.  
  364. stdio/vfscanf.o: stdio/vfscanf.c
  365.         $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES)  stdio/vfscanf.c -o $@
  366.  
  367. stdio/vfiscanf.o: stdio/vfscanf.c
  368.         $(CC) $(CFLAGS) $(DEFINES) -DINTEGER_ONLY $(INCLUDES) stdio/vfscanf.c -o $@
  369.  
  370. stdio/svscanf.o: stdio/vfscanf.c
  371.         $(CC) $(CFLAGS) $(DEFINES) -DSTRING_ONLY $(INCLUDES) stdio/vfscanf.c -o $@
  372.  
  373.  
  374. stdio/svfiscanf.o: stdio/vfscanf.c
  375.         $(CC) $(CFLAGS) $(DEFINES) -DINTEGER_ONLY -DSTRING_ONLY $(INCLUDES) stdio/vfscanf.c -o $@
  376.  
  377.  
  378.  
  379. %.obj : %.asm Makefile
  380.         fasm $< $@
  381.  
  382. %.o : %.c Makefile
  383.         $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o $@ $<
  384.  
  385.  
  386. clean:
  387.         -rm -f */*.o
  388.  
  389.  
  390.