#
# Makefile for SVGA textmode manipulation program
#
# Author : Koen Gadeyne (kmg@barco.be)
#

CFLAGS = -Wall -O2 -s -N
#CFLAGS = -Wall -O2 -g

# installation path for SVGATextMode
INSTBINDIR = /usr/local/bin

# installation path for TextConfig. This is also the path that will be
# compiled into SVGATextMode.
INSTCONFDIR = /etc

all: SVGATextMode

hack: setVGAreg getVGAreg

messages.o: messages.c messages.h
	$(CC) $(CFLAGS) -c messages.c -o messages.o

vga_prg.o: vga_prg.c vga_prg.h messages.h
	$(CC) $(CFLAGS) -c vga_prg.c -o vga_prg.o

configfile.o: configfile.c configfile.h messages.h
	$(CC) $(CFLAGS) -DCONFIGFILE=\"$(INSTCONFDIR)/TextConfig\" -c configfile.c -o configfile.o

SVGATextMode.o: SVGATextMode.c vga_prg.h configfile.h messages.h
	$(CC) $(CFLAGS) -DCONFIGFILE=\"$(INSTCONFDIR)/TextConfig\" -c SVGATextMode.c -o SVGATextMode.o
	
SVGATextMode: SVGATextMode.o vga_prg.o configfile.o messages.o
	$(CC) $(CFLAGS) SVGATextMode.o vga_prg.o configfile.o messages.o -o SVGATextMode
	
setVGAreg.o: setVGAreg.c vga_prg.h configfile.h messages.h
	$(CC) $(CFLAGS) -DCONFIGFILE=\"$(INSTCONFDIR)/TextConfig\" -c setVGAreg.c -o setVGAreg.o

setVGAreg: setVGAreg.o vga_prg.o configfile.o messages.o
	$(CC) $(CFLAGS) setVGAreg.o vga_prg.o configfile.o messages.o -o setVGAreg
	
getVGAreg: setVGAreg
	ln -sf setVGAreg getVGAreg	
	

clean:
	rm -f *~ *.o *.bak
	
install: all
	install -s -m 755 SVGATextMode $(INSTBINDIR)/SVGATextMode
	install -m 644 TextConfig $(INSTCONFDIR)/TextConfig

pristine: mrproper
mrproper: clean
	rm -f SVGATextMode getVGAreg setVGAreg

distclean: clean
	rm -f getVGAreg setVGAreg DEADJOE 
	