CC = gcc
CFLAGS = -Wall -O2
LFLAGS = -s

PROG = asm.exe

OBJS =  asm.o \
	parse.o \
	commnd1.o \
	events.o \
	imagwind.o \
	sources.o \
	plotcomm.o \
	plotutil.o \
	windows.o \
	calculat.o \
	transfor.o \
	fft.o \
	fileio.o \
	convcorr.o \
	sound.o \
        util.o

all : $(PROG)


$(PROG) : $(OBJS)
	$(CC) $(LFLAGS) -o $@ $+ -lalleg

asm.o : asm.c asm.h errors.h parse.h image.h
	$(CC) $(CFLAGS) -o $@ -c $<

parse.o : parse.c parse.h asm.h cmd_list.h commnd.h aimhelp.h
	$(CC) $(CFLAGS) -o $@ -c $<

commnd1.o : commnd1.c asm.h parse.h image.h commnd.h fileio.h
	$(CC) $(CFLAGS) -o $@ -c $<

events.o : events.c asm.h
	$(CC) $(CFLAGS) -o $@ -c $<

imagwind.o : imagwind.c asm.h imagwind.h image.h
	$(CC) $(CFLAGS) -o $@ -c $<

sources.o : sources.c imagwind.h errors.h parse.h image.h commnd.h plotutil.h asm.h windows.h
	$(CC) $(CFLAGS) -o $@ -c $<

plotcomm.o : plotcomm.c errors.h parse.h imagwind.h asm.h commnd.h
	$(CC) $(CFLAGS) -o $@ -c $<

plotutil.o : plotutil.c errors.h parse.h imagwind.h asm.h
	$(CC) $(CFLAGS) -o $@ -c $<

windows.o : windows.c windows.h image.h
	$(CC) $(CFLAGS) -o $@ -c $<

calculat.o : calculat.c imagwind.h errors.h parse.h image.h commnd.h plotutil.h asm.h
	$(CC) $(CFLAGS) -o $@ -c $<

transfor.o : transfor.c imagwind.h errors.h parse.h image.h commnd.h plotutil.h asm.h windows.h fft.h
	$(CC) $(CFLAGS) -o $@ -c $<

fft.o : fft.c fft.h
	$(CC) $(CFLAGS) -o $@ -c $<

fileio.o : fileio.c asm.h image.h imagwind.h errors.h fileio.h
	$(CC) $(CFLAGS) -o $@ -c $<


convcorr.o : convcorr.c asm.h image.h imagwind.h errors.h commnd.h windows.h fft.h plotutil.h
	$(CC) $(CFLAGS) -o $@ -c $<

sound.o : sound.c parse.h image.h commnd.h
	$(CC) $(CFLAGS) -o $@ -c $<

util.o: util.c
	$(CC) $(CFLAGS) -o $@ -c $<

clean:
	rm -f *.o
	rm -f *.bak
	rm -f $(PROG)
