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

# Output type (use the "-DNOLCD" option for terminal output)
# This should be fine if you have an lcd hooked up.
OUTPUT = 
#OUTPUT = -DNOLCD

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

# Load Threshold
# This sets how high the load average must be before the display
# begins to blink...
LOAD_THRESHOLD = 1.9

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

GCC = gcc -Wall -Wp,-lang-c-c++-comments -O6 $(OUTPUT)
TARGET = lcdproc
OBJ = main.o mode.o lcd.o lock.o
LIB =
SOURCES = Makefile main.c main.h mode.c mode.h lcd.c lcd.h lock.c lock.h
EXTRAS = change.log lcdproc.1 INSTALL README COPYING
MISC = -DLOAD_THRESHOLD=$(LOAD_THRESHOLD)
VERSION = 0.3.1


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

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


##################################################################
# Installation
#
install:
	@echo Installing LCDproc...
	gzip -c lcdproc.1 > lcdproc.1.gz
	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!"

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


##################################################################
# Other stuff...
#
clean:
	rm -f $(OBJ) $(TARGET)

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

# 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 ---------------===========================================

