##########################################################################
# This makefile was donated to public domain by Chem/Hubris in year 1997 #
##########################################################################

# the objects to be compiled and archived to hub_mp.a
LOADER_OBJS=mod.o s3m.o xm.o voc.o
DEVICE_OBJS=usdev.o sbdev.o nsdev.o mix.o devices.o
OBJS=interfac.o vali.o playing.o $(DEVICE_OBJS) $(LOADER_OBJS)

# optimization switches. OPTIMIZE is used for non-critical code,
# FULL_OPTIMIZE for code requiring as much speed as possible.
# "best" switches are -O2 for OPTIMIZE and -O3 for FULL_OPTIMIZE.
OPTIMIZE=-O2 -m486
FULL_OPTIMIZE=-O3 -m486

# compiler flags
CFLAGS=-Wall -g

# compilers and other tools
CC=@gcc
ASMC=@nasm -f coff
MAKEARC=@ar rs
PRINT=@echo

# after hub_mp.a and hmp.exe the compilation is finished
all: hub_mp.a hmp.exe
	$(PRINT) Everything done, have fun :)

# compile the example player
hmp.exe: hub_mp.a hmp.c
	$(PRINT) Please wait, compiling hmp.c ..
	$(CC) $(OPTIMIZE) $(CFLAGS) -o hmp.exe hmp.c hub_mp.a

# compile the tracking code
playing.o: playing.c playing.h ialot.h structs.h
	$(PRINT) Please wait, compiling playing.c ..
	$(CC) $(FULL_OPTIMIZE) $(CFLAGS) -c -o playing.o playing.c

# compile the voc loader
voc.o: voc.c voc.h ialot.h structs.h
	$(PRINT) Please wait, compiling voc.c ..
	$(CC) $(OPTIMIZE) $(CFLAGS) -c -o voc.o voc.c

# compile the xm loader
xm.o: xm.c xm.h ialot.h structs.h
	$(PRINT) Please wait, compiling xm.c ..
	$(CC) $(OPTIMIZE) $(CFLAGS) -c -o xm.o xm.c

# compile the s3m loader
s3m.o: s3m.c s3m.h ialot.h structs.h
	$(PRINT) Please wait, compiling s3m.c ..
	$(CC) $(OPTIMIZE) $(CFLAGS) -c -o s3m.o s3m.c

# compile the mod loader
mod.o: mod.c mod.h ialot.h structs.h
	$(PRINT) Please wait, compiling mod.c ..
	$(CC) $(OPTIMIZE) $(CFLAGS) -c -o mod.o mod.c

# compile the selection bar
vali.o: vali.c vali.h
	$(PRINT) Please wait, compiling vali.c ..
	$(CC) $(OPTIMIZE) $(CFLAGS) -c -o vali.o vali.c

# compile the no sound device
nsdev.o: nsdev.c nsdev.h
	$(PRINT) Please wait, compiling nsdev.c ..
	$(CC) $(OPTIMIZE) $(CFLAGS) -c -o nsdev.o nsdev.c

# compile the ultrasound device
usdev.o: usdev.c usdev.h
	$(PRINT) Please wait, compiling usdev.c ..
	$(CC) $(FULL_OPTIMIZE) $(CFLAGS) -c -o usdev.o usdev.c

# compile the sound blaster device
sbdev.o: sbdev.c sbdev.h vali.c vali.h
	$(PRINT) Please wait, compiling sbdev.c ..
	$(CC) $(FULL_OPTIMIZE) $(CFLAGS) -c -o sbdev.o sbdev.c

# compile the sb's mixing code
mix.o: mix.asm
	$(PRINT) Please wait, compiling mix.asm ..
	$(ASMC) mix.asm

# compile the interface
interfac.o: interfac.c interfac.h ??dev.h devices.c devices.h
	$(PRINT) Please wait, compiling interfac.c ..
	$(CC) $(OPTIMIZE) $(CFLAGS) -c -o interfac.o interfac.c

# compile the device interface
devices.o: devices.c devices.h ??dev.h
	$(PRINT) Please wait, compiling devices.c ..
	$(CC) $(OPTIMIZE) $(CFLAGS) -c -o devices.o devices.c

# archive all objects to hub_mp.a
hub_mp.a: $(OBJS)
	$(PRINT) Please wait, creating hub_mp.a ..
	$(MAKEARC) hub_mp.a $(OBJS)

# end of file
