########################################################################
# Modify these variables to fit your system.
########################################################################

##################### Serial device
# This should be whatever your display is connected to.
# "make install" will create a link from /dev/lcd to DEVICE
DEVICE = /dev/ttyS0

##################### Operating System
# Uncomment the line for your OS.
OS=-DLINUX
#OS=-DIRIX

##################### Modescreen Options

##### Load Screen
# Max:  Load Avg at which the backlight will start blinking
MISC += -DLOAD_MAX=1.3
# Min:  Load Avg at which the backlight will turn off (asleep) 
MISC += -DLOAD_MIN=0.05

##### Filesystems to display stats for... (comment out ones you don't want)
# NFS (Network File System)
MISC += -DSTAT_NFS
# SMBFS (Samba filesystem -- Windows drives)
MISC += -DSTAT_SMBFS


##################### Drivers
# Comment out each section you don't want.

# Matrix-Orbital displays
DRIVERS += -DMTXORB_DRV
OBJ += MtxOrb.o

# Curses text-based output
DRIVERS += -DCURSES_DRV
OBJ += curses_drv.o
LIB += -lncurses

# Regular text output (ugly)
DRIVERS += -DTEXT_DRV
OBJ += text.o

# Debugging output (very ugly)
DRIVERS += -DDEBUG_DRV
OBJ += debug.o

# HD44780 parallel port lcd displays
#DRIVERS += -DHD44780_DRV
#OBJ += hd44780.o
# Pick one of the following ports to use
#LPTPORT = 0x378
#LPTPORT = 0x278
#LPTPORT = 0x3bc



########################################################################
# You shouldn't need to touch anything below here.
########################################################################

GCC = gcc -Wall -Wp,-lang-c-c++-comments -O6
TARGET = lcdproc
OBJ += main.o mode.o lcd.o sockets.o drv_base.o
SOURCES = Makefile main.c main.h mode.c mode.h lcd.c lcd.h \
	MtxOrb.c MtxOrb.h text.c text.h debug.c debug.h \
	curses_drv.c curses_drv.h sockets.c sockets.h drv_base.c drv_base.h \
	hd44780.c hd44780.h port.h
EXTRAS = change.log lcdproc.1 INSTALL README COPYING
MISC += $(OS) $(DRIVERS)
VERSION = 0.3.4


###################################################################
# Compilation...
#
$(TARGET): $(OBJ) Makefile
	$(GCC) -s $(MISC) -o $(TARGET) $(OBJ) $(LIB)

%.o: %.c %.h Makefile
	$(GCC) -c $(MISC) $<


##################################################################
# Installation
#
install: $(TARGET) lcdproc.1 
	@echo Installing LCDproc...
	gzip -c lcdproc.1 > lcdproc.1.gz
	install -d -m 755 -o root -g root /usr/local/man/cat1/
	install -m 0644 -o root -g root lcdproc.1.gz /usr/local/man/cat1/
	install -m 0755 -o root -g root lcdproc /usr/local/bin/
	if [ ! -e /dev/lcd ]; then ln -s $(DEVICE) /dev/lcd ; chmod a+rw $(DEVICE) ; fi
	@echo "All done -- enjoy!"
	@echo "Be sure to verify that /dev/lcd points to the correct device."
	@ls -l /dev/lcd

# TODO: Have the installer insert lcdproc in system startup scripts?


##################################################################
# Other stuff...
#
clean:
	rm -f $(OBJ) $(TARGET) *~ lcdproc.1.gz

# Distribution file
tardist:
	rm -rf lcdproc-$(VERSION)
	mkdir lcdproc-$(VERSION)
	cp $(SOURCES) $(EXTRAS) lcdproc-$(VERSION)
	tar cfv lcdproc-$(VERSION).tar lcdproc-$(VERSION)
	rm -f lcdproc-$(VERSION).tar.gz
	gzip lcdproc-$(VERSION).tar
	rm -rf lcdproc-$(VERSION)

# This includes source...
tarball:
	tar cfv lcd.tar $(SOURCES) $(EXTRAS)
	gzip lcd.tar

# This includes an executable and source...
bintarball:
	tar cfv lcd.tar $(TARGET) $(SOURCES) $(EXTRAS)
	gzip lcd.tar

edit:
	nedit $(SOURCES) $(EXTRAS) &

todo:
	@echo ---------------===========================================
	@grep TODO $(SOURCES) | grep -v SOURCES
	@grep FIXME $(SOURCES) | grep -v SOURCES
	@echo ---------------===========================================

#TODO: Keep updating the "Thank You's" section of the README.
#TODO: Don't forget about homework!
#TODO: Input object should have PollEvent() and WaitEvent()
#TODO: Input object should check keypad, joystick, and sockets...

