# Makefile for sysline (Version 0.5 Linux)

##############################################################################

# Changing the name has zero effect on other compiling options;
# sysline will however in case of errors report itself with this name.
# Take your pick.

PROGNAME	= sysline.termcap
#PROGNAME	= sysline.terminfo
#PROGNAME	= sysline


# Uncomment TERMINFO to use terminfo; you can ignore the following
# LIBCURSES define then, since it will automatically be set to ncurses
# farther below.

#TERMINFO	= -DTERMINFO


# If TERMINFO is defined you can ignore LIBCURSES here, since it will
# automatically always be set to ncurses farther below.
# If TERMINFO is not defined (i.e. termcap is used), your choice is between
# ncurses or standard curses.
# When using standard curses, you must not have the ncurses headers
# installed, for gcc will find them before the standard headers and it will
# result in compiler errors (/usr/local/include is searched by gcc before
# /usr/include).

LIBCURSES	= curses
#LIBCURSES	= ncurses


# if using ncurses and its headers are not in /usr/include, specify the 
# their location here (gcc 2.6.0 in its default installation doesn't 
# look in /usr/local/include anymore, it appears)
# might as well specify the [n]curses library location too, though not
# really necessary.

CURSES_INCDIR	= /usr/include
#CURSES_INCDIR	= /usr/local/include

CURSES_LIBDIR	= /usr/lib
#CURSES_LIBDIR	= /usr/local/lib


# for more customization, refer to config.h

##############################################################################

########### do not change this #############
ifdef TERMINFO
	LIBCURSES = ncurses
	CURSDEF	  = -DNCURSES
else
	ifeq ($(strip $(LIBCURSES)),ncurses)
		CURSDEF = -DNCURSES
	endif
endif
############################################

CC		= gcc #-v
OPT		= -O2 -Wall -m486
#OPT		= -g
CFLAGS		= $(strip $(OPT)) $(strip $(TERMINFO)) $(strip $(CURSDEF)) -I$(strip $(CURSES_INCDIR))
LDFLAGS		= -L$(strip $(CURSES_LIBDIR))
LIBS		= -ltermcap -l$(LIBCURSES)
OFILES		= sysline.o getloadavg.o

PROG		= $(strip $(PROGNAME))
PROGS_DIR	= /usr/bin
PROGS		= $(PROG)  # cs cls
PROGS_MODE	= 555
MANPG_DIR	= /usr/man/man1
MANP		= sysline.1
MANPG_MODE	= 644
INSTALL		= install


$(PROG):	$(OFILES)
		$(CC) $(strip $(CFLAGS)) -o $(PROG) $(OFILES) $(LDFLAGS) $(LIBS)

sysline.o:	sysline.c config.h Makefile
		$(CC) $(strip $(CFLAGS)) -DMYNAME=\"$(PROG)\" -c sysline.c

getloadavg.o:	getloadavg.c
		$(CC) $(OPT) -DHAVE_UNISTD_H -c getloadavg.c

config.h:
		touch config.h

pathnames.h:
		touch pathnames.h

rwhod.h:
		touch rwhod.h

clean:
		rm -f sysline sysline.termcap sysline.terminfo a.out
		rm -f sysline.o getloadavg.o
		rm -f core

install:	$(PROG)
		$(INSTALL) -s -m $(PROGS_MODE) $(PROG) $(PROGS_DIR)
		$(INSTALL)    -m $(MANPG_MODE) $(MANP) $(MANPG_DIR)
