
COMPILER = macosx
DATA_INSTALLER = cp -f
PROG_INSTALLER = cp -f

UNIX_TOOLS=1

include make/makefile.gcc
include make/makefile.lst


#-------------------------------#
# --- Compiler optimizations ---#

ifdef DEBUGMODE
FLAGS = -DDEBUGMODE -g
ifdef LOGLEVEL
FLAGS += -DLOGLEVEL=$(LOGLEVEL)
endif
else
FLAGS = -W -Wall -Wno-unused -O2 -ffast-math -fomit-frame-pointer
endif

FLAGS += -fno-common -pipe

ifdef STATICALLEGRO
FLAGS += -DALLEGRO_STATICLINK
endif

SRC_DIR_U = $(SRC_DIR)

OBJ_DIR_U = $(OBJ_DIR)

EXAMPLE_DIR_U = $(EXAMPLE_DIR)

LIB_PATH_U = $(LIB_DIR)/lib$(LIB_NAME).a
LIB_PATH = $(LIB_PATH_U)

HEADERS_U = $(HEADERS)
EXT_HEADERS_U = $(EXT_HEADERS)
EXT_HEADERS_PATH_U = $(EXT_HEADERS_PATH)

INCLUDE_PATHS = $(addprefix -I, $(INCLUDE_DIR))

SOURCE = $(C_SOURCE) $(MACOSX_SOURCE)
OBJECTS = $(addprefix $(OBJ_DIR)/, $(addsuffix .o, $(basename $(notdir $(SOURCE)))))
EXAMPLES = $(basename $(addprefix $(EXAMPLE_DIR)/, $(EXAMP_SOURCE)))

COMPILER_LINK_LIB = `allegro-config --libs` -framework Carbon -framework OpenGL


INSTALL_DIR = /usr/local

COMPILER_LIB_DIR_U = $(INSTALL_DIR)/lib
COMPILER_INCLUDE_DIR_U = $(INSTALL_DIR)/include



lib: $(LIB_PATH)
examples: $(EXAMPLES)

#----------------------------#
#---- Various targets -------#

include make/makefile.all


$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(addprefix include/,$(C_DEPEND)) $(EXT_HEADERS)
	gcc -c $< -o $@ $(FLAGS) $(INCLUDE_PATHS)

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.m $(addprefix include/,$(C_DEPEND)) $(EXT_HEADERS)
	gcc -c $< -o $@ $(FLAGS) $(INCLUDE_PATHS)

$(LIB_PATH): $(OBJECTS) $(HEADERS)
	ar rs $@ $(OBJECTS)
	ranlib $@
	
$(EXAMPLE_DIR)/%: $(EXAMPLE_DIR)/%.c $(HEADERS) $(LIB_PATH)
	gcc $< -o $@ $(FLAGS) $(INCLUDE_PATHS) $(LIB_PATH) $(COMPILER_LINK_LIB)

