#================================------------------ ---- ---  ---   --   -
#
# HYPER-LOGiN v.1.0.1 MAKEFILE
# Written by MiCRO^[[ of LiE
#
#================================------------------ ---- ---  ---   --   -
# targets recognized by this makefile:
#   all         	- compiles hlogin
#   install		- installs hlogin and all welcomes and config files
#   clean               - remove core and binary
#   restore             - restore /bin/login, remove hlogin files
#   tar                 - re-create the hlogin-1.0.1.tgz file
#================================------------------ ---- ---  ---   --   -

# 'c' compiler you want to use
CC = gcc

# Set this to -g if you want to be able to debug the client, otherwise
# use -O to have the compiler do some optimization instead.
CCOPTS = -O6

# Set this to -s if you want the binary to be striped.
LDFLAGS = 

# There are no important defines nor libraries right now.
DEFS = 
LIBS = 

# The directory into which the welcome and configuration files will
# be installed.  NOTE: hard-coded as /etc, for now...
CONFIG_DIR = /etc

# The directory into which the new binary should be installed.
# NOTE: hard-coded as /bin, for now...
INSTALL_DIR = /bin

# The directory into which man page(s) should be installed. (NOT IMPLEMENTED)
MAN_DIR = /usr/local/man/man1

#================================------------------ ---- ---  ---   --   -
## You probably don't need to change anything below this line

default: all

all: hyper

hyper:
	$(CC) $(CCOPTS) hlogin.c -o hlogin

install:
	install -o root -g root -m 755 ./hyper.cfg /etc/
	install -o root -g root -m 755 ./welcomes/wel.* /etc/
	install -o root -g bin -m 755 ./hlogin /bin/
	install -o root -g root -m 444 ./hlogin.1 /usr/local/man/man1/
	
	@-if test -f /bin/login; then mv /bin/login /bin/login_old; fi
	ln -s /bin/hlogin /bin/login

clean:
	@-if test -f ./hlogin; then rm ./hlogin; fi
	@-if test -f ./core; then rm ./core; fi

restore:
	@-if test -f /etc/hyper.cfg; then rm /etc/hyper.cfg; fi
	@-if test -f /bin/hlogin; then rm /bin/hlogin; fi
	@-if test -f /bin/login_old; then mv /bin/login_old /bin/login; fi
	rm /etc/wel.*

tar: clean
	@-if test -f ./hlogin-1.0.1.tgz; then rm ./hlogin-1.0.1.tgz; fi
	tar -czvvf hlogin-1.0.1.tgz *

#================================------------------ ---- ---  ---   --   -
