ROOT = .
odir = $(ROOT)/.o/
SYM := -sym full
#USEPRECOMIPLED = -prefix BeHeaders
CFLAGS := 	-c $(SYM) -RTTI -ansi strict -w full -maxerrors 10 \
			$(USEPRECOMIPLED) \
			$(USER_DEBUG_C_FLAGS) \
#

ifeq ($(PLATFORM), intel)
	LDFLAGS := $(SYM) -msg nodup -imagebase 0x80000000 -nodefaults
else
	LDFLAGS := $(SYM) -msg nodup -export pragma 
endif

ifeq ($(PLATFORM), intel)
	CC := mwccx86
	LD := mwldx86
#	CR := addres.x86.beos
	CR := mergeres
else
	LD := mwld
	CC := mwcc
	CR := mergeres
endif

APPLIBS = \
	$(BELIBRARIES)/glue-noinit.a \
	$(BELIBRARIES)/init_term_dyn.o \
	$(BELIBRARIES)/start_dyn.o \
	$(BELIBRARIES)/libroot.so \
	$(BELIBRARIES)/libbe.so \
	$(BELIBRARIES)/libnet.so \
	$(BELIBRARIES)/libnetdev.so \
	$(BELIBRARIES)/libmail.so \
	$(BELIBRARIES)/libtracker.so \
	$(BELIBRARIES)/libdevice.so \
	$(BELIBRARIES)/libgame.so \
	$(BELIBRARIES)/libmedia.so \
	$(BELIBRARIES)/libmidi.so


SRCS = \
	CDEngine.cpp \
	CDButton.cpp \
	CDPanel.cpp \
	TypedList.cpp \
	FunctionObjectMessage.cpp \
	Observer.cpp \
#

ifeq ($(PLATFORM), intel)
	RESOURCES = CDButton_x86.rsrc
else
	RESOURCES = CDButton_ppc.rsrc
endif
OBJS := $(foreach source, ${SRCS}, $(odir)${source}.o)

TARGET = CDButton

.PHONY: all
all: odirs $(TARGET)

$(TARGET): $(OBJS)
	$(LD) -o $@ $(OBJS) $(APPLIBS) $(LDFLAGS) -map $@.xMAP
	$(CR) $(RESOURCES) $@
	mimeset -f $@

.PHONY: odirs
odirs: $(odir)

$(odir):
	mkdir -p $@

$(odir)%.cpp.o: %.cpp
	@echo "	Compiling $(<F)";
	$(CC) $(CFLAGS) $(INCLUDES) $< -o $@

.PHONY: clean
clean:
	rm -rf $(odir)
