1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
|
# This makefile builds both uni-threaded and multi-threaded versions
# of the libraries. It can be used as:
# 1. make install
# building both versions
# 2. make install_ut
# building the uni-threaded version only
# 3. make install_mt
# building the multi-threaded version only
#
# Written by Kiem-Phong Vo
all : install_ut
ROOT=../..
include $(ROOT)/Config.mk
include $(ROOT)/makearch/$(ARCH)
DEFINES=
LIBTYPE=
LOC_INCDIR= ../include
LOC_LIBDIR= ../lib
INCS = -I. $(LIBTYPE)
# sfio
SRCS= sfclose.c sfclrlock.c sfcvt.c sfdisc.c sfdlen.c sfexcept.c \
sfextern.c sffilbuf.c sfflsbuf.c sfprints.c sfgetd.c sfgetl.c \
sfgetr.c sfgetu.c sfllen.c sfmode.c sfmove.c sfnew.c \
sfnotify.c sfnputc.c sfopen.c sfpkrd.c sfpool.c sfpopen.c \
sfprintf.c sfputd.c sfputl.c sfputr.c sfputu.c sfrd.c sfread.c \
sfscanf.c sfseek.c sfset.c sfsetbuf.c sfsetfd.c sfsize.c sfsk.c \
sfstack.c sfstrtod.c sfsync.c sftable.c sftell.c sftmp.c \
sfungetc.c sfvprintf.c sfvscanf.c sfwr.c sfwrite.c sfexit.c \
sfpurge.c sfpoll.c sfreserve.c sfswap.c sfraise.c sfmutex.c \
sfgetm.c sfputm.c sfresize.c
OBJS= sfclose.o sfclrlock.o sfcvt.o sfdisc.o sfdlen.o sfexcept.o \
sfextern.o sffilbuf.o sfflsbuf.o sfprints.o sfgetd.o sfgetl.o \
sfgetr.o sfgetu.o sfllen.o sfmode.o sfmove.o sfnew.o \
sfnotify.o sfnputc.o sfopen.o sfpkrd.o sfpool.o sfpopen.o \
sfprintf.o sfputd.o sfputl.o sfputr.o sfputu.o sfrd.o sfread.o \
sfscanf.o sfseek.o sfset.o sfsetbuf.o sfsetfd.o sfsize.o sfsk.o \
sfstack.o sfstrtod.o sfsync.o sftable.o sftell.o sftmp.o \
sfungetc.o sfvprintf.o sfvscanf.o sfwr.o sfwrite.o sfexit.o \
sfpurge.o sfpoll.o sfreserve.o sfswap.o sfraise.o sfmutex.o \
sfgetm.o sfputm.o sfresize.o
# function versions of macros
SFIO_F= Sfio_f/_sfclrerr.o Sfio_f/_sfdlen.o Sfio_f/_sfeof.o \
Sfio_f/_sferror.o Sfio_f/_sffileno.o Sfio_f/_sfgetc.o \
Sfio_f/_sfllen.o Sfio_f/_sfputc.o Sfio_f/_sfputd.o \
Sfio_f/_sfputl.o Sfio_f/_sfputm.o Sfio_f/_sfputu.o \
Sfio_f/_sfslen.o Sfio_f/_sfstacked.o Sfio_f/_sfulen.o \
Sfio_f/_sfvalue.o
# stdio-source compatibility code
STDIO_S=Stdio_s/stdfgetc.o Stdio_s/stdfprintf.o Stdio_s/stdfputc.o \
Stdio_s/stdfscanf.o Stdio_s/stdgetc.o Stdio_s/stdgets.o \
Stdio_s/stdgetw.o Stdio_s/stdfdopen.o Stdio_s/stdprintf.o \
Stdio_s/stdputc.o Stdio_s/stdputw.o Stdio_s/stdscanf.o \
Stdio_s/stdsprintf.o Stdio_s/stdsetvbuf.o Stdio_s/stdtmpfile.o \
Stdio_s/stdfopen.o Stdio_s/stdpopen.o Stdio_s/stdfreopen.o \
Stdio_s/stdfwrite.o Stdio_s/stdfread.o Stdio_s/stdfflush.o
# Thread-safety
MTSAFE= ../vthread/vtextern.o ../vthread/vtmtxclrlock.o \
../vthread/vtmtxclose.o ../vthread/vtmtxlock.o \
../vthread/vtmtxopen.o ../vthread/vtmtxtrylock.o \
../vthread/vtmtxunlock.o ../vthread/vtonce.o
# IO disciplines
SFIO_DC=Sfio_dc/sfdcdio.o Sfio_dc/sfdcdos.o Sfio_dc/sfdcfilter.o \
Sfio_dc/sfdclzw.o Sfio_dc/sfdcseekable.o Sfio_dc/sfdcslow.o \
Sfio_dc/sfdcsubstream.o Sfio_dc/sfdctee.o Sfio_dc/sfdcunion.o
# only one of the below install targets should be uncommented
#install:
install: install_ut
#install: vthread install_mt
#install: vthread install_mt install_ut
# this target builds the Vthread library
vthread:
cd ../vthread; $(MAKE) SHELL="$(SHELL)" CC="$(CC)" \
CCMODE="$(CCMODE)" CXFLAGS="$(CXFLAGS)" install
# this target builds the uni-threaded version of Sfio
install_ut:
# echo""; echo "BUILDING UNI-THREADED libsfio.a"
# $(SHELL) ./Makestate.sh unithreaded
$(MAKE) LIBTYPE="-Dvt_threaded=0" SHELL="$(SHELL)" CC="$(CC)" \
CCMODE="$(CCMODE)" CXFLAGS="$(CXFLAGS)" install_unithreaded
# this target builds the multi-threaded version of Sfio
install_mt:
echo""; echo "BUILDING MULTI-THREADED libsfio-mt.a";
$(SHELL) ./Makestate.sh multithreaded
$(MAKE) LIBTYPE="-Dvt_threaded=1" SHELL="$(SHELL)" CC="$(CC)" \
CCMODE="$(CCMODE)" CXFLAGS="$(CXFLAGS)" install_multithreaded
install_unithreaded: libsfio.a
$(MKPATH) $(LOC_INCDIR)
$(MKPATH) $(LOC_LIBDIR)
cp sfio.h ast_common.h sfio_t.h Sfio_dc/sfdisc.h $(LOC_INCDIR)
cp libsfio.a $(LOC_LIBDIR)
-(ranlib $(LOC_LIBDIR)/libsfio.a; exit 0) >/dev/null 2>&1
libsfio.a: ast_common.h FEATURE/sfio $(OBJS) mksfio_f
$(AR) cr libsfio.a $(OBJS) $(SFIO_F)
-(ranlib libsfio.a; exit 0) >/dev/null 2>&1
libstdio.a:
cd Stdio_b; $(MAKE) LIBTYPE="$(LIBTYPE)" SHELL="$(SHELL)" CC="$(CC)" \
CCMODE="$(CCMODE)" CXFLAGS="$(CXFLAGS)" libstdio.a
install_multithreaded: libsfio-mt.a libstdio-mt.a
cp sfio.h ast_common.h sfio_t.h Stdio_s/stdio.h Sfio_dc/sfdisc.h $(LOC_INCDIR)
cp libsfio-mt.a $(LOC_LIBDIR)
-(ranlib $(LOC_LIBDIR)/libsfio-mt.a; exit 0) >/dev/null 2>&1
cp Stdio_b/libstdio-mt.a $(LOC_LIBDIR)
-(ranlib $(LOC_LIBDIR)/libstdio-mt.a; exit 0) >/dev/null 2>&1
libsfio-mt.a: ast_common.h FEATURE/sfio $(OBJS) mksfio_f mkstdio_s mksfio_dc
$(AR) cr libsfio-mt.a $(OBJS) $(SFIO_F) $(STDIO_S) $(SFIO_DC) $(MTSAFE)
-(ranlib libsfio-mt.a; exit 0) >/dev/null 2>&1
libstdio-mt.a:
cd Stdio_b; $(MAKE) LIBTYPE="$(LIBTYPE)" SHELL="$(SHELL)" CC="$(CC)" \
CCMODE="$(CCMODE)" CXFLAGS="$(CXFLAGS)" libstdio-mt.a
$(OBJS) : ast_common.h
# the make goals below are common to both uni&multi-threaded versions
FEATURE/sfio: features/sfio
$(ROOT)/iffe set cc $(CC) $(CCFLAGS) : run features/sfio
ast_common.h : ../cdt/ast_common.h
rm -f ast_common.h
$(LN) ../cdt/ast_common.h .
../cdt/ast_common.h : ../cdt/features/common
(cd ../cdt; make ast_common.h)
#ast_common.h: features/common
# ../iffe - set cc $(CC) $(CCFLAGS) : run features/common > ast_common.h
mksfio_f:
cd Sfio_f; $(MAKE) LIBTYPE="$(LIBTYPE)" SHELL="$(SHELL)" CC="$(CC)" \
CCMODE="$(CCMODE)" CXFLAGS="$(CCFLAGS)"
mkstdio_s:
cd Stdio_s; $(MAKE) LIBTYPE="$(LIBTYPE)" SHELL="$(SHELL)" CC="$(CC)" \
CCMODE="$(CCMODE)" CXFLAGS="$(CXFLAGS)"
mksfio_dc:
cd Sfio_dc; $(MAKE) LIBTYPE="$(LIBTYPE)" SHELL="$(SHELL)" CC="$(CC)" \
CCMODE="$(CCMODE)" CXFLAGS="$(CXFLAGS)"
clean:
-(rm -rf FEATURE $(OBJS) ast_common.h Makefile.state; exit 0) >/dev/null 2>&1
-(rm libsfio.a libstdio.a libsfio-mt.a libstdio-mt.a; exit 0) >/dev/null 2>&1
cd Sfio_f; $(MAKE) SHELL="$(SHELL)" clean
cd Sfio_dc; $(MAKE) SHELL="$(SHELL)" clean
distclean : clean
|