summaryrefslogtreecommitdiff
path: root/libc/stdio/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'libc/stdio/Makefile')
-rw-r--r--libc/stdio/Makefile144
1 files changed, 94 insertions, 50 deletions
diff --git a/libc/stdio/Makefile b/libc/stdio/Makefile
index b0ba70ba8..59e80a359 100644
--- a/libc/stdio/Makefile
+++ b/libc/stdio/Makefile
@@ -2,6 +2,7 @@
#
# 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
@@ -25,61 +26,96 @@ TOPDIR=../../
include $(TOPDIR)Rules.mak
# Note: The *64.o objects are empty when compiled without large file support.
-#
-# 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 flockfile.o ftrylockfile.o funlockfile.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 _stdio_strerror_r.o \
- getdelim.o getline.o ctermid.o
-
-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 \
- _store_inttype.o _load_inttype.o
-
-MSRC3=scanf.c
-MOBJ3=scanf.o sscanf.o fscanf.o vscanf.o vsscanf.o vfscanf.o \
- __scan_cookie.o __psfs_parse_spec.o __psfs_do_numeric.o
+# 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 \
+ _load_inttype.c _store_inttype.c _uintmaxtostr.c
+ifeq ($(strip $(UCLIBC_HAS_FLOATS)),y)
+CSRC += _fpmaxtostr.c
+endif
-ifeq ($(UCLIBC_HAS_WCHAR),y)
- MOBJ += _wstdio_fwrite.o
- MOBJ2 += fwprintf.o wprintf.o swprintf.o vwprintf.o vswprintf.o \
- vfwprintf.o
- MOBJ3 += wscanf.o swscanf.o fwscanf.o vwscanf.o vswscanf.o vfwscanf.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
+CSRC += fopencookie.c fmemopen.c open_memstream.c _cs_funcs.c
+
+# pthread functions
+ifeq ($(strip $(UCLIBC_HAS_THREADS)),y)
+CSRC += flockfile.c ftrylockfile.c funlockfile.c
endif
+# 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 += _ppfs_init.o _ppfs_prepargs.o _ppfs_setargs.o \
- _ppfs_parsespec.o vfprintf.o \
- register_printf_function.o parse_printf_format.o
+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
-ifeq ($(UCLIBC_HAS_FLOATS),y)
- MOBJ2 += _fpmaxtostr.o
+CSRC += $(CUSRC)
+
+COBJS = $(patsubst %.c,%.o, $(CSRC))
+CUOBJS = $(patsubst %.c,%_unlocked.o, $(CUSRC))
+CWOBJS = $(patsubst %.c,%.o, $(CWSRC))
+
+ifeq ($(strip $(UCLIBC_HAS_WCHAR)),y)
+COBJS += $(CWOBJS)
endif
-CSRC=popen.c tmpfile.c tmpnam.c tmpnam_r.c tempnam.c
-ifeq ($(USE_OLD_VFPRINTF),y)
- CSRC += old_vfprintf.c
+OBJS = $(COBJS) $(CUOBJS) $(MOBJ2) $(MOBJ3) $(MWOBJ)
+
+ifeq ($(strip $(UCLIBC_HAS_LFS)),y)
+OBJS += $(CLOBJS)
endif
-COBJS=$(patsubst %.c,%.o, $(CSRC))
-OBJS=$(MOBJ) $(MOBJ2) $(MOBJ3) $(COBJS)
all: $(OBJS) $(LIBC)
@@ -88,9 +124,17 @@ $(LIBC): ar-target
ar-target: $(OBJS)
$(AR) $(ARFLAGS) $(LIBC) $(OBJS)
-$(MOBJ): $(MSRC)
- $(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 $@
+
+%_unlocked.o : %.c
+ $(CC) $(CFLAGS) -D__DO_UNLOCKED -c $< -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $@
+
+%64.o : %.c
+ $(CC) $(CFLAGS) -D__DO_LARGEFILE -c $< -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $@
$(MOBJ2): $(MSRC2)
$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
@@ -100,12 +144,12 @@ $(MOBJ3): $(MSRC3)
$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
$(STRIPTOOL) -x -R .note -R .comment $*.o
-$(COBJS): %.o : %.c
- $(CC) $(CFLAGS) -c $< -o $@
+$(MWOBJ): $(MWSRC)
+ $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
$(STRIPTOOL) -x -R .note -R .comment $*.o
$(OBJ): Makefile
clean:
- $(RM) *.[oa] *~ core
+ rm -f *.[oa] *~ core