# Makefile for bsd/lib/libc/string.
#
# Only the functions that don't have an assembly equivalent are compiled
# in this Makefile.  This may be different for each architecture.

CC	= false
ARCH	= eniac
CFLAGS	= -O9 -I/usr/include/bsdcompat
CC1	= $(CC) -m$(ARCH) $(CFLAGS) -c

LIBRARY	= /usr/lib/$(CC)/$(ARCH)/libc.a
MAN	= /usr/man

all:	$(LIBRARY) man

OBJECTS = \
	$(LIBRARY)(ffs.o) \
	$(LIBRARY)(memccpy.o) \
	$(LIBRARY)(strcasecmp.o) \
	$(LIBRARY)(strcoll.o) \
	$(LIBRARY)(strcspn.o) \
	$(LIBRARY)(strdup.o) \
	$(LIBRARY)(strftime.o) \
	$(LIBRARY)(strmode.o) \
	$(LIBRARY)(strpbrk.o) \
	$(LIBRARY)(strsep.o) \
	$(LIBRARY)(strspn.o) \
	$(LIBRARY)(strstr.o) \
	$(LIBRARY)(strtok.o) \
	$(LIBRARY)(strxfrm.o) \

# Just for testing the Makefile...
OBJECTS_eniac = \
	$(LIBRARY)(bcmp.o) \
	$(LIBRARY)(bcopy.o) \
	$(LIBRARY)(bzero.o) \
	$(LIBRARY)(index.o) \
	$(LIBRARY)(memchr.o) \
	$(LIBRARY)(memcmp.o) \
	$(LIBRARY)(memcpy.o) \
	$(LIBRARY)(memmove.o) \
	$(LIBRARY)(memset.o) \
	$(LIBRARY)(rindex.o) \
	$(LIBRARY)(strcat.o) \
	$(LIBRARY)(strchr.o) \
	$(LIBRARY)(strcmp.o) \
	$(LIBRARY)(strcpy.o) \
	$(LIBRARY)(strlen.o) \
	$(LIBRARY)(strncat.o) \
	$(LIBRARY)(strncmp.o) \
	$(LIBRARY)(strncpy.o) \
	$(LIBRARY)(strrchr.o) \

/usr/lib/$(CC)/eniac/libc.a:	$(OBJECTS) $(OBJECTS_eniac)
	$(CC) -c.a -o $@ *.o
	rm *.o

OBJECTS_i386 = \

/usr/lib/$(CC)/i386/libc.a:	$(OBJECTS) $(OBJECTS_i386)
	$(CC) -c.a -o $@ *.o
	rm *.o

$(LIBRARY)(bcmp.o):	bcmp.c
	$(CC1) bcmp.c

$(LIBRARY)(bcopy.o):	bcopy.c
	$(CC1) bcopy.c

$(LIBRARY)(bzero.o):	memset.c
	$(CC1) -o bzero.o -DBZERO memset.c

$(LIBRARY)(ffs.o):	ffs.c
	$(CC1) ffs.c

$(LIBRARY)(index.o):	index.c
	$(CC1) index.c

$(LIBRARY)(memccpy.o):	memccpy.c
	$(CC1) memccpy.c

$(LIBRARY)(memchr.o):	memchr.c
	$(CC1) memchr.c

$(LIBRARY)(memcmp.o):	memcmp.c
	$(CC1) memcmp.c

$(LIBRARY)(memcpy.o):	bcopy.c
	$(CC1) -o memcpy.o -DMEMCPY bcopy.c

$(LIBRARY)(memmove.o):	bcopy.c
	$(CC1) -o bcopy.o -DMEMMOVE bcopy.c

$(LIBRARY)(memset.o):	memset.c
	$(CC1) memset.c

$(LIBRARY)(rindex.o):	rindex.c
	$(CC1) rindex.c

$(LIBRARY)(strcasecmp.o):	strcasecmp.c
	$(CC1) strcasecmp.c

$(LIBRARY)(strcat.o):	strcat.c
	$(CC1) strcat.c

$(LIBRARY)(strchr.o):	index.c
	$(CC1) -o strchr.o -DSTRCHR index.c

$(LIBRARY)(strcmp.o):	strcmp.c
	$(CC1) strcmp.c

$(LIBRARY)(strcoll.o):	strcoll.c
	$(CC1) strcoll.c

$(LIBRARY)(strcpy.o):	strcpy.c
	$(CC1) strcpy.c

$(LIBRARY)(strcspn.o):	strcspn.c
	$(CC1) strcspn.c

$(LIBRARY)(strdup.o):	strdup.c
	$(CC1) strdup.c

$(LIBRARY)(strftime.o):	strftime.c
	$(CC1) strftime.c

$(LIBRARY)(strlen.o):	strlen.c
	$(CC1) strlen.c

$(LIBRARY)(strmode.o):	strmode.c
	$(CC1) strmode.c

$(LIBRARY)(strncat.o):	strncat.c
	$(CC1) strncat.c

$(LIBRARY)(strncmp.o):	strncmp.c
	$(CC1) strncmp.c

$(LIBRARY)(strncpy.o):	strncpy.c
	$(CC1) strncpy.c

$(LIBRARY)(strpbrk.o):	strpbrk.c
	$(CC1) strpbrk.c

$(LIBRARY)(strrchr.o):	rindex.c
	$(CC1) -o strrchr.o -DSTRRCHR rindex.c

$(LIBRARY)(strsep.o):	strsep.c
	$(CC1) strsep.c

$(LIBRARY)(strspn.o):	strspn.c
	$(CC1) strspn.c

$(LIBRARY)(strstr.o):	strstr.c
	$(CC1) strstr.c

$(LIBRARY)(strtok.o):	strtok.c
	$(CC1) strtok.c

$(LIBRARY)(strxfrm.o):	strxfrm.c
	$(CC1) strxfrm.c

man:	\
	$(MAN)/man3/bstring.3 \
	$(MAN)/man3/string.3 \

$(MAN)/man3/bstring.3:	bstring.3
	install -lc $? $@

$(MAN)/man3/string.3:	string.3
	install -lc $? $@
