#
# Copyright (C) 2000 by Lineo, inc.
# Copyright (C) 2000,2001 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2004 Manuel Novoa III <mjn3@codepoet.org>
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU Library General Public License as published by the Free
TOPDIR=../../
include $(TOPDIR)Rules.mak
-# Set to true to use the old vfprintf instead of the new. The old is roughly
-# C89 compliant, but doesn't deal with qualifiers on %n and doesn't deal with
-# %h correctly or %hh at all on the interger conversions. But on i386 it is
-# over 1.5k smaller than the new code. Of course, the new code fixes the
-# above mentioned deficiencies and adds custom specifier support similar to
-# glibc, as well as handling positional args. This option is here temporarily
-# until the configuration system gets rewritten. Note also that the old
-# vfprintf code will be rewritten at some point to bring it into at least C89
-# standards compliance.
+# Note: The *64.o objects are empty when compiled without large file support.
-USE_OLD_VFPRINTF = false
+# SUSv3 functions
+CSRC = fclose.c fcloseall.c fdopen.c fgetpos.c fopen.c freopen.c \
+ fseeko.c fsetpos.c ftello.c getdelim.c getline.c gets.c getw.c \
+ perror.c puts.c putw.c remove.c rewind.c setbuf.c setbuffer.c \
+ setlinebuf.c setvbuf.c ungetc.c \
+ printf.c vprintf.c vsprintf.c fprintf.c snprintf.c dprintf.c \
+ asprintf.c sprintf.c vasprintf.c vdprintf.c vsnprintf.c \
+ tmpfile.c tmpnam.c tmpnam_r.c popen.c tempnam.c ctermid.c
+
+# getc -> alias for fgetc
+# putc -> alias for fputc
+# rename is a syscall
+
+# Implementation support functions
+CSRC += _READ.c _WRITE.c _adjust_pos.c _fopen.c _fwrite.c \
+ _rfill.c _stdio.c _trans2r.c _trans2w.c _wcommit.c \
+ _cs_funcs.c _load_inttype.c _store_inttype.c _uintmaxtostr.c
+ifeq ($(UCLIBC_HAS_FLOATS),y)
+CSRC += _fpmaxtostr.c
+endif
-# Note: The *64.o objects are empty when compiled without large file support.
-# To not build them at all, remove the appropriate line from the MOBJ
-# definition and uncomment the DOLFS test below.
-
-# Note: Use the libpthreads of: flockfile.o ftrylockfile.o funlockfile.o
-# Also, maybe move __fsetlocking.o as well?
-
-MSRC = stdio.c
-MOBJ = fclose.o fflush.o fopen.o freopen.o perror.o remove.o \
- setbuf.o setvbuf.o fgetc.o fgets.o fputc.o fputs.o \
- getc.o getchar.o gets.o putc.o putchar.o puts.o \
- ungetc.o fread.o fwrite.o fgetpos.o fseek.o fsetpos.o ftell.o \
- rewind.o clearerr.o feof.o ferror.o \
- fileno.o fdopen.o getw.o putw.o setbuffer.o setlinebuf.o fcloseall.o \
- fopen64.o freopen64.o ftello64.o fseeko64.o fsetpos64.o fgetpos64.o \
- __fbufsize.o __freading.o __fwriting.o __freadable.o __fwritable.o \
- __flbf.o __fpurge.o __fpending.o _flushlbf.o \
- fopencookie.o fmemopen.o open_memstream.o \
- __fsetlocking.o \
- _stdio_fopen.o _stdio_fread.o _stdio_fwrite.o _stdio_adjpos.o \
- _stdio_lseek.o _stdio_init.o \
- _stdio_fsfopen.o _stdio_fdout.o _uintmaxtostr.o
-
-# ifeq ($(DOLFS),true)
-# MOBJ += fopen64.o freopen64.o ftello64.o fseeko64.o fsetpos64.o fgetpos64.o
-# endif
-
-MSRC2= printf.c
-MOBJ2= vsnprintf.o vdprintf.o vasprintf.o vprintf.o vsprintf.o \
- fprintf.o snprintf.o dprintf.o asprintf.o printf.o sprintf.o
-
-ifneq ($(USE_OLD_VFPRINTF),true)
- MOBJ2 += _ppfs_init.o _ppfs_prepargs.o _ppfs_setargs.o \
- _ppfs_parsespec.o _do_one_spec.o vfprintf.o \
- _store_inttype.o _load_inttype.o \
- register_printf_function.o parse_printf_format.o
+# stdio_ext.h functions
+CSRC += __fbufsize.c __flbf.c __fpending.c __fpurge.c __freadable.c \
+ __freading.c __fsetlocking.c __fwritable.c __fwriting.c _flushlbf.c
+
+# Other glibc extensions
+ifeq ($(UCLIBC_HAS_GLIBC_CUSTOM_STREAMS),y)
+CSRC += fopencookie.c fmemopen.c open_memstream.c
endif
+# pthread functions
+CSRC += flockfile.c ftrylockfile.c funlockfile.c
+
+# Functions with unlocked versions
+CUSRC = clearerr.c feof.c ferror.c fflush.c fgetc.c fgets.c fileno.c \
+ fputc.c fputs.c fread.c fwrite.c getchar.c putchar.c
+# getc_unlocked -> alias for fgetc_unlocked
+# putc_unlocked -> alias for fputc_unlocked
+
+# Largefile functions
+CLOBJS = fgetpos64.o fopen64.o freopen64.o fseeko64.o fsetpos64.o ftello64.o
+# tmpfile64.o
+
+# vfprintf and support functions
+MSRC2= vfprintf.c
+ifneq ($(USE_OLD_VFPRINTF),y)
+MOBJ2= vfprintf.o \
+ _ppfs_init.o _ppfs_prepargs.o _ppfs_setargs.o _ppfs_parsespec.o \
+ register_printf_function.o parse_printf_format.o
+else
+MOBJ2=
+CSRC += old_vfprintf.c
+endif
+# vfscanf and support functions plus other *scanf funcs
+MSRC3= scanf.c
+MOBJ3= vfscanf.o __scan_cookie.o __psfs_parse_spec.o __psfs_do_numeric.o \
+ scanf.o sscanf.o fscanf.o vscanf.o vsscanf.o
+
+MWSRC= wstdio.c
+MWOBJ=
+
+CWSRC =
+ifeq ($(UCLIBC_HAS_WCHAR),y)
+CWSRC += _wfwrite.c fwprintf.c swprintf.c vswprintf.c vwprintf.c wprintf.c \
+ fwide.c ungetwc.c
+CUSRC += fgetwc.c getwchar.c fgetws.c fputwc.c putwchar.c fputws.c
+# getwc (fgetwc alias) getwc_unlocked (fgetwc_unlocked alias)
+# putwc (fputwc alias) putwc_unlocked (fputwc_unlocked alias)
+MOBJ2 += vfwprintf.o
+MOBJ3 += wscanf.o swscanf.o fwscanf.o vwscanf.o vswscanf.o vfwscanf.o
+endif
+
+CSRC += $(CUSRC)
-ifeq ($(HAS_FLOATING_POINT),true)
- MOBJ2 += _dtostr.o
+COBJ = $(patsubst %.c,%.o, $(CSRC))
+CUOBJS = $(patsubst %.c,%_unlocked.o, $(CUSRC))
+CWOBJS = $(patsubst %.c,%.o, $(CWSRC))
+
+ifeq ($(UCLIBC_HAS_WCHAR),y)
+COBJ += $(CWOBJS)
endif
-MSRC3=scanf.c
-MOBJ3=scanf.o sscanf.o fscanf.o vscanf.o vsscanf.o vfscanf.o
+OBJS = $(COBJ) $(CUOBJS) $(MOBJ2) $(MOBJ3) $(MWOBJ)
-CSRC=popen.c getdelim.c getline.c tmpfile.c tmpnam.c \
- tmpnam_r.c tempnam.c ctermid.c
-ifeq ($(USE_OLD_VFPRINTF),true)
- CSRC += old_vfprintf.c
+ifeq ($(UCLIBC_HAS_LFS),y)
+OBJS += $(CLOBJS)
endif
-COBJS=$(patsubst %.c,%.o, $(CSRC))
-OBJS=$(MOBJ) $(MOBJ2) $(MOBJ3) $(COBJS)
+ifeq ($(UCLIBC_HAS_THREADS),y)
+CFLAGS += $(PTINC)
+endif
-all: $(OBJS) $(LIBC)
+OBJ_LIST := ../obj.stdio
-$(LIBC): ar-target
+all: $(OBJ_LIST)
-ar-target: $(OBJS)
- $(AR) $(ARFLAGS) $(LIBC) $(OBJS)
+$(OBJ_LIST): $(OBJS)
+ $(STRIPTOOL) -x -R .note -R .comment $^
+ echo $(patsubst %, stdio/%, $^) > $@
-$(MOBJ): $(MSRC)
- $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
- $(STRIPTOOL) -x -R .note -R .comment $*.o
+$(COBJ): %.o : %.c
+ $(CC) $(CFLAGS) -c $< -o $@
+
+%_unlocked.o : %.c
+ $(CC) $(CFLAGS) -D__DO_UNLOCKED -c $< -o $@
+
+%64.o : %.c
+ $(CC) $(CFLAGS) -D__DO_LARGEFILE -c $< -o $@
$(MOBJ2): $(MSRC2)
$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
- $(STRIPTOOL) -x -R .note -R .comment $*.o
$(MOBJ3): $(MSRC3)
$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
- $(STRIPTOOL) -x -R .note -R .comment $*.o
-$(COBJS): %.o : %.c
- $(CC) $(CFLAGS) -c $< -o $@
- $(STRIPTOOL) -x -R .note -R .comment $*.o
-
-$(OBJ): Makefile
+$(MWOBJ): $(MWSRC)
+ $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
clean:
- rm -f *.[oa] *~ core
-
+ $(RM) *.o *~ core