# -----------------------------------------------------------------------------
# This is the makefile for Level-Editor (c) Henrik Stokseth, 1999.

INCLUDE_DIR = include
EXAMPLE_DIR = examples
OBJ_DIR     = obj
SRC_DIR     = src

CFLAGS = -Wall -Wno-unused -m486 -O3 -I$(INCLUDE_DIR)
LFLAGS = -s

default   : editor examples
editor    : leditor.exe
examples  : $(EXAMPLE_DIR)/test1.exe $(EXAMPLE_DIR)/test2.exe $(EXAMPLE_DIR)/test3.exe $(EXAMPLE_DIR)/test4.exe
clean     : remove_obj
veryclean : remove_obj remove_exe

# -----------------------------------------------------------------------------
# This is the dependencies for the editor

$(OBJ_DIR)/leditor.o : $(SRC_DIR)/leditor.c
	@echo making editor ...
	@gcc $(CFLAGS) -o $(OBJ_DIR)/leditor.o -c $(SRC_DIR)/leditor.c

leditor.exe : $(OBJ_DIR)/leditor.o
	@gcc $(LFLAGS) -o leditor.exe $(OBJ_DIR)/leditor.o -lalleg

# -----------------------------------------------------------------------------
# This is the dependencies for the examples

$(OBJ_DIR)/test1.o : $(EXAMPLE_DIR)/test1.c
	@echo making example one ...
	@gcc $(CFLAGS) -o $(OBJ_DIR)/test1.o -c $(EXAMPLE_DIR)/test1.c

$(EXAMPLE_DIR)/test1.exe : $(OBJ_DIR)/test1.o
	@gcc $(LFLAGS) -o $(EXAMPLE_DIR)/test1.exe $(OBJ_DIR)/test1.o -lalleg

$(OBJ_DIR)/test2.o : $(EXAMPLE_DIR)/test2.c
	@echo making example two ...
	@gcc $(CFLAGS) -o $(OBJ_DIR)/test2.o -c $(EXAMPLE_DIR)/test2.c

$(EXAMPLE_DIR)/test2.exe : $(OBJ_DIR)/test2.o
	@gcc $(LFLAGS) -o $(EXAMPLE_DIR)/test2.exe $(OBJ_DIR)/test2.o -lalleg

$(OBJ_DIR)/test3.o : $(EXAMPLE_DIR)/test3.c
	@echo making example three ...
	@gcc $(CFLAGS) -o $(OBJ_DIR)/test3.o -c $(EXAMPLE_DIR)/test3.c

$(EXAMPLE_DIR)/test3.exe : $(OBJ_DIR)/test3.o
	@gcc $(LFLAGS) -o $(EXAMPLE_DIR)/test3.exe $(OBJ_DIR)/test3.o -lalleg

$(OBJ_DIR)/test4.o : $(EXAMPLE_DIR)/test4.c
	@echo making example four ...
	@gcc $(CFLAGS) -o $(OBJ_DIR)/test4.o -c $(EXAMPLE_DIR)/test4.c

$(EXAMPLE_DIR)/test4.exe : $(OBJ_DIR)/test4.o
	@gcc $(LFLAGS) -o $(EXAMPLE_DIR)/test4.exe $(OBJ_DIR)/test4.o -lalleg

# -----------------------------------------------------------------------------
# This is the cleanup section

remove_obj:
	@echo cleaning up (removing object files) ...
	@del $(OBJ_DIR)\*.o

remove_exe:
	@echo cleaning up (removing executables) ...
	@del *.exe
	@del $(EXAMPLE_DIR)\*.exe

# -----------------------------------------------------------------------------
