# This is the makefile for the main svgalib source.
# Also used to build for the shared library (when DLLFLAGS defined).

# You might want to add -m386 here if you have a recently installed 
# (486 configured) compiler on a 386. The only real difference is the
# generous alignment padding of function entry-points for the 486.
OPTIMIZE = -fomit-frame-pointer -O2
CFLAGS	 = -Wall $(OPTIMIZE)


AR	= ar
CC	= gcc $(DLLFLAGS)
DRIVERS = vgadrv.o cirrus.o et4000.o tvga8900.o oak.o egadrv.o s3.o et3000.o \
	  vgahico.o regextr.o modetab.o mach32.o
MODULES = vga.o \
          vgadraw.o vgaclear.o vgaline.o vgapix.o \
          vgapal.o vgacol.o vgamodesel.o vgamisc.o \
	  vgadump.o vgaconvplanar.o
MOUSE   = mouse/mouse.o
KEYBOARD = keyboard/keyboard.o

.c.o:
	$(CC) $(CFLAGS) -c -o $*.o $<

all:	libvga.a

libvga.a: $(MODULES) $(MOUSE) $(KEYBOARD) $(DRIVERS)
	rm -f libvga.a
	$(AR) rcs libvga.a $(MODULES) $(MOUSE) $(KEYBOARD) $(DRIVERS)

dep:
	rm -f .depend
	make .depend

.depend:
	echo '# Module dependencies' >>.depend
	gcc -MM $(patsubst %.o,%.c,$(MODULES)) >>.depend
	echo '# Mouse dependencies' >>.depend
	gcc -MM $(patsubst %.o,%.c,$(MOUSE)) >.depend.mouse
	sed 's#^#mouse/#g' <.depend.mouse >>.depend
	rm -f .depend.mouse
	echo '# Keyboard dependencies' >>.depend
	gcc -MM $(patsubst %.o,%.c,$(MOUSE)) >.depend.keyboard
	sed 's#^#keyboard/#g' <.depend.keyboard >>.depend
	rm -f .depend.keyboard
	echo '# Driver dependencies' >>.depend
	gcc -MM $(patsubst %.o,%.c,$(DRIVERS)) >>.depend

clean:
	rm -f *~ *.o mouse/*.o keyboard/*.o libvga.a

include .depend


