TARGET=funiter

CC=gcc
CFLAGS=-W -Wall -Iinclude
LDFLAGS=
LDLIBS=-lm

ifdef BUILD_WITH_ADIME
CFLAGS += -DBUILD_WITH_ADIME
ifdef DEBUGMODE
LDLIBS += -ladimd
else
LDLIBS += -ladime
endif
endif

ifdef BUILD_WITH_AGUP
CFLAGS += -DBUILD_WITH_AGUP
ifdef DEBUGMODE
LDLIBS += -lagupd
else
LDLIBS += -lagup
endif
endif

ifdef BUILD_WITH_JPGALLEG
CFLAGS += -DBUILD_WITH_JPGALLEG
LDLIBS += -ljpgal
endif

# --- different commands for erasing files and the allegro lib ---

ALLIB=-lalleg
RMFILES=del $(OBJDIR)\*.o
EXE=$(addsuffix .exe, $(TARGET))

ifdef UNIX_PLATFORM
ALLIB=`allegro-config --libs`
RMFILES=rm obj/*.o
EXE=$(TARGET)
endif

ifdef DEBUGMODE
CFLAGS += -g -ggdb -DDEBUGMODE
ifdef UNIX_PLATFORM
ALLIB=`allegro-config --libs debug`
endif
endif

# --- directories for sources and object files ---

OBJDIR=obj
SRCDIR=src

# --- source files ---

SRC=main.c cntmenu.c clsmenus.c estoui.c alconio.c misc.c realexp.c \
cplexp.c settings.c complex.c coords.c menutext.c parser.c help.c \
newmenus.c

# --- object files ---

OBJ=$(addprefix $(OBJDIR)/, $(SRC:.c=.o))

# --- compiling and linking ---

$(OBJDIR)/%.o : $(SRCDIR)/%.c
	$(CC) $(CFLAGS) -c $< -o $@ 

$(TARGET): $(OBJ)
	$(CC) $(OBJ) -o $(EXE) $(LDFLAGS) $(LDLIBS) $(ALLIB)

# --- remove files ---

clean:
	$(RMFILES)
	@echo "all gone!"

