#
# typespeed makefile
#

CC = gcc 
CFLAGS = -O -D_GNU_SOURCE -Wall
LFLAGS = -lncurses

PROG = typespeed
SRCS = file.c  menu.c  misc.c  network.c
OBJS = file.o  menu.o  misc.o  network.o

local_dir = $(HOME)
install_dir = "/usr/local/bin"
wordfiles = "/usr/local/lib"
man_dir  = "/usr/local/man/man1/"

all: clean $(PROG)


clean:
	rm -f $(PROG) *.o high.*


$(PROG): $(OBJS)
	
	$(CC) $(CFLAGS) $(OBJS) -o $(PROG) $(PROG).c $(LFLAGS)


install: typespeed

	@echo Installing. You need to be root, or have access to install dirs
	@echo ..and we know that everyone can delete the highscores, but
	@echo we did not want to put setuid or setgid to typespeed yet,
	@echo because then we would have to make a user for those..
	@echo If you like to do it in that way, do it yourself. 
	@echo 
	cp typespeed $(install_dir)
	chmod 755 $(install_dir)/typespeed
	if test ! -d $(wordfiles)/typespeed; then mkdir $(wordfiles)/typespeed; fi
	./typespeed --makescores
	cp words.* $(wordfiles)/typespeed
	cp high.* $(wordfiles)/typespeed
	chmod 755 $(wordfiles)/typespeed
	chmod 666 $(wordfiles)/typespeed/high.*
	chmod 644 $(wordfiles)/typespeed/words.*
	echo $(wordfiles)/typespeed/ > /etc/typespeedrc
	cp typespeed.1 $(man_dir)
	chmod 644 $(man_dir)/typespeed.1
	@echo done...

uninstall: distclean

distclean:

	rm -f $(install_dir)/typespeed
	rm -Rf $(wordfiles)/typespeed 
	rm -f /etc/typespeedrc
	rm -f high.*
	rm -f typespeed *.o
	rm -f $(man_dir)/typespeed.1

love: 

	@echo this program does not cum with virtual megababe!
