# Makefile for hacked mintlib for Sozobon C (version 2.0 only?)
# This makefile works under GNU make. Any other make I cannot vouch for.

# Where to install libraries.
LIBDIR = /usr/sozobon/lib

CC = /usr/sozobon/bin/cc
AS = /usr/sozobon/bin/jas
AR = /usr/sozobon/bin/ar
TARGET_ARCH =
# Should have -O, but top is utterly crap.
CFLAGS = 
CPPFLAGS = -D__NO_FLOAT__
LDFLAGS = -s
LDLIBS = 

# I use a modified cc; you may want to use the original names for crt0 and
# libc (dstart and dlibs). Should have curses and maybe widget library too.
LIBS = crt0.o libtermcap.a libc.a

TESTS = termcap

.PHONY : all clean realclean install
all : $(LIBS)

# Rule for making objects with optimization
# Need this cos cc is not very clever and gets confused with -o things.
.c.o :
	$(CC) $(TARGET_ARCH) $(CFLAGS) $(CPPFLAGS) -c $<

# These are in alphabetical order to make it easy to find one.
OBJECTS = \
	abort.o abs.o access.o alarm.o alloca.o alphasort.o atol.o \
	bcmp.o bcopy.o binmode.o bsearch.o bzero.o \
	chdir.o chmod.o clock.o close.o console.o crtinit.o ctime.o ctype.o \
	difftime.o dirent.o doprnt.o dup.o \
	exec.o \
	fclose.o fcntl.o fdopen.o fflush.o fgetc.o fgets.o filbuf.o \
	findfile.o fopen.o fopenp.o fork.o fprintf.o fputc.o fputs.o \
	fread.o fscanf.o fseek.o fsetpos.o ftw.o fungetc.o fwrite.o \
	getbuf.o getcwd.o getdtable.o getenv.o getgroup.o gethostname.o \
	getlogin.o getopt.o getpass.o getpid.o getpw.o getrusage.o gets.o \
	getuid.o getw.o grp.o \
	ioctl.o isatty.o \
	kill.o \
	linea.o link.o localtime.o lockf.o lseek.o ltoa.o \
	main.o malloc.o memccpy.o memchr.o memcmp.o memcpy.o memset.o \
	mkdir.o mknod.o mktemp.o \
	nice.o \
	open.o osbind.o \
	pause.o perror.o pipe.o popen.o psignal.o \
	qsort.o \
	raise.o rand.o random.o read.o regexp.o regsup.o \
	rename.o rmdir.o \
	sbrk.o scandir.o scanf.o select.o setbuf.o setjmp.o setlocal.o \
	setrlimit.o setvbuf.o sgtty.o sigblock.o siglist.o signal.o sleep.o \
	sozolong.o spawn.o spawnve.o spawnvp.o sprintf.o sscanf.o stat.o \
	stksiz.o strcat.o strchr.o strcmp.o strcpy.o strcspn.o strdup.o \
	strerror.o strftime.o strlen.o strlwr.o strncat.o strncmp.o strncpy.o \
	strpbrk.o strrchr.o strrev.o strspn.o strstr.o strtok.o strtol.o \
	strtoul.o symlink.o sysconf.o system.o sysvar.o \
	textio.o thread.o time.o timeofday.o tmpfile.o tmpnam.o ttyname.o \
	uname.o unlink.o unx2dos.o utime.o utmp.o \
	vfork.o \
	wait.o wait3.o write.o wtmp.o
#	div.o

libc.a : $(OBJECTS)
	$(AR) r $@ $?

libtermcap.a : termcap.o
	$(AR) r $@ $?

# Test version of termcap.
termcap : termcap.c
	$(CC) $(CPPFLAGS) -DTEST $(CFLAGS) -o $@ $< $(LDLIBS)

clean :
	rm -f *.o

realclean : clean
	rm -f $(LIBS)

install :
	cp $(LIBS) $(LIBDIR)
