# tetris.mk - tetris makefile - rick sladkey

# Select compilation setup of your choice by
# uncommenting the appropriate section below.

# for UNIXpc with normal cc and shared library:

CC = cc
CFLAGS = -O
CCLD = ld
LDFLAGS = -s /lib/crt0s.o /lib/shlib.ifile

# for UNIXpc with gcc and shared library:

# CC = gcc
# CFLAGS = -O
# CCLD = $(CC)
# LDFLAGS = -s -shlib

# for non-UNIXpc system:

# CC = :
# CFLAGS = Go buy a UNIXpc, or better yet, --
# CCLD = :
# LDFLAGS = port z-graphics to your machine. --

# for debugging:

# CC = gcc
# CFLAGS = -g
# CCLD = $(CC)
# LDFLAGS = $(CFLAGS)

ZFILES = hw.c image.c input.c internal.c text.c update.c z.c timing.c
OFILES = $(ZFILES:.c=.o)

####### Dependencies

# tetris demo program

tetris: tetris.o libz.a
	$(CCLD) $(LDFLAGS) tetris.o libz.a -o tetris

# actual z-graphic library

libz.a: $(OFILES)
	ar ru libz.a $?

$(OFILES): z.h

# rule for making a single-source z-graphics programs

.c: libz.a
	$(CC) -c $(CFLAGS) $<
	$(CCLD) $(LDFLAGS) $(<:.c=.o) libz.a -o $*
	rm $(<:.c=.o)

