#
# Makefile for the graphics library
#

include ../../.config

INITFLAGS =

ifdef PACKEDMONO
INITFLAGS += -DPMONO
endif

ifdef PACKEDCOLORMONO
INITFLAGS += -DPCOLORMONO
endif

ifdef PACKEDCOLOR
INITFLAGS += -DPCOLOR
endif

ifdef DIRECT8
INITFLAGS += -DDIRECT8
endif

ifdef BMONO
INITFLAGS += -DBMONO
endif


CFLAGS = $(ADDCFLAGS) $(SERVERADDCFLAGS)

OBJS = init.o $(wildcard generic/*.o) $(wildcard packed/*.o) \
	$(wildcard direct8/*.o) $(wildcard monochrome/*.o) $(wildcard svga/*.o)

ifeq ($(ARCH),Linux-m68k)
OBJS += atari.o
endif
ifeq ($(ARCH),Linux-i386)
OBJS += svgalib.o
endif
ifeq ($(ARCH),MiNT)
OBJS += atari.o
endif
ifeq ($(ARCH),SunOS)
OBJS += sun.o
endif
ifeq ($(ARCH),NetBSD)
OBJS += netbsd_amiga.o
endif

all: subdirs
	$(MAKE) libgraph.a

subdirs:
	$(MAKE) -C generic
ifdef DIRECT8
	$(MAKE) -C direct8
endif
ifdef BMONO
	$(MAKE) -C monochrome
endif
ifdef SVGALIB
	$(MAKE) -C svga
endif
ifdef PACKEDMONO
	$(MAKE) -C packed MONO=1
endif
ifdef PACKEDCOLORMONO
	$(MAKE) -C packed COLORMONO=1
endif
ifdef PACKEDCOLOR
	$(MAKE) -C packed COLOR=1
endif

libgraph.a: $(OBJS)
	$(RM) $@
	$(AR) $@ $(OBJS)
ifdef RANLIB
	$(RANLIB) $@
endif

clean:
	find . -name '*[~|.o]' | xargs $(RM)

veryclean: clean
	$(RM) libgraph.a

atari.o: atari.c
	$(CC) $(CFLAGS) $(INITFLAGS) -c atari.c -o atari.o

svgalib.o: svgalib.c
	$(CC) $(CFLAGS) $(INITFLAGS) -c svgalib.c -o svgalib.o
