# include Makefile.common found at the root of ossim
# Makefile.common is generated by the configure
#
@INCLUDE_COMMON@

CCSRCS=$(wildcard *.cc)
CPPSRCS=$(wildcard *.cpp)
CSRCS=$(wildcard *.c)
COBJS=$(patsubst %.c,%.o,$(CSRCS))
CCOBJS=$(patsubst %.cc,%.o,$(CCSRCS))
CPPOBJS=$(patsubst %.cpp,%.o,$(CPPSRCS))
OBJS=$(CCOBJS) $(CPPOBJS) $(COBJS) 
DEPEND_FILES = $(wildcard *.d)

# The binary program extension, if any, including dots (e.g. '.exe')
PROGRAM_EXT = $(EXEEXT)
BIN_PROGRAM = $(PROGRAM_PREFIX)$(PROGRAM)$(PROGRAM_EXT)

LIBRARY   = $(LIBTOOL_CORE_LIBS)
DEPLIBS	  = $(OSSIM_CORE_LIBS:-l%=$(LIB_SRC)/.libs/lib%.a)
SRCS      = $(CCSRCS) $(CPPSRCS) $(CSRCS)
INCLUDES  = $(BASE_INCLUDES)

# Pattern rule for objects from .cpp files.
%.$(OBJEXT): %.cpp
	$(CXX) $(CXXFLAGS) $(CDEBUGFLAGS) $(BASE_DEFINES) $(INCLUDES) -c $< -o $@

# Pattern rule for objects from .cc files.
%.$(OBJEXT): %.cc
	$(CXX) $(CXXFLAGS) $(CDEBUGFLAGS) $(BASE_DEFINES) $(INCLUDES) -c $< -o $@

# Pattern rule for object from .c files.
%.$(OBJEXT): %.c
	$(CC) $(CFLAGS) $(CDEBUGFLAGS) $(BASE_DEFINES) $(INCLUDES) -c $< -o $@

%.d: %.cc
	$(SHELL) -ec '$(CXX) -MM $(CXXFLAGS) $(CDEBUGFLAGS) $(BASE_DEFINES) $(INCLUDES) $< >> $@;'

%.d: %.cpp
	$(SHELL) -ec '$(CXX) -MM $(CXXFLAGS) $(CDEBUGFLAGS) $(BASE_DEFINES) $(INCLUDES) $< >> $@;'

%.d: %.c
	$(SHELL) -ec '$(CC) -MM $(CFLAGS) $(CDEBUGFLAGS) $(BASE_DEFINES) $(INCLUDES) $< >> $@;'

all:	$(BIN_PROGRAM)

$(BIN_PROGRAM): $(OBJS)
	$(CXX) $(CXXFLAGS) $(CDEBUGFLAGS) $(BASE_DEFINES) $(LDFLAGS_APP) $(OBJS) $(OSSIM_APP_LINK) -o $@
	$(INSTALL_PROGRAM) $(BIN_PROGRAM) $(OSSIM_TOP)/bin

depends: 	$(CCSRCS:.cc=.d)\
		$(CSRCS:.c=.d)\
		$(CPPSRCS:.cpp=.d)

clean_depends:
	$(RM_NOPROMPT) *.d

clean:
	$(RM_CMD) $(BIN_PROGRAM)



# Only add the depends if they exist
#
ifneq ($(DEPENDS_FILES),)
-include $(DEPENDS_FILES)
endif
