# Project: libmatroska
# Makefile created by Dev-C++ 4.9.7.0

# Uncomment this if you want a static library.
# ATTENTION: Your app has to define MATROSKA_DLL !
SHARED = yes

# Compile with debug information?
#DEBUG = yes

# Where libebml resides
EBML_DIR = ../../../libebml

# Has libebml been compiled as a DLL?
EBML_DLL = yes

#
# Don't change anything below this line.
#
ifeq (yes,$(DEBUG))
DEBUGFLAGS=-g -DDEBUG
endif
CXX  = g++.exe
LD = g++.exe
WINDRES = windres.exe
RES  = 
SRC  = $(wildcard ../../src/*.cpp)
OBJ  = $(patsubst %.cpp,%.o,$(SRC))
ifeq (yes,$(SHARED))
LIBS = libmatroska.dll
CXXFLAGS = -DMATROSKA_DLL
DLLFLAGS = -DMATROSKA_DLL_EXPORT
else
LIBS = libmatroska.a
endif
ifeq (yes,$(EBML_DLL))
CXXFLAGS += -DEBML_DLL
endif
INCS = -I../.. -I$(EBML_DIR)
LDFLAGS = -L. -L$(EBML_DIR)/make/mingw32
CXXFLAGS += $(DEBUGFLAGS) $(INCS) 
TESTS = test6 test8 test9

.PHONY: all all-before all-after clean clean-custom

.cpp.o:
	$(CXX) $(DLLFLAGS) $(CXXFLAGS) -c -o $@ $<

all: lib tests

lib: $(LIBS)

tests: $(TESTS)

clean:
	rm -f $(OBJ) libmatroska.* *.exe ../../test/mux/*.o ../../test/tags/*.o

libmatroska.a: $(OBJ)
	ar r $@ $(OBJ)
	ranlib $@

libmatroska.dll: $(OBJ)
	$(CXX) -shared -Wl,--export-all -Wl,--out-implib=$@.a -o $@ $(OBJ) \
		$(LDFLAGS) -lebml

# Explicitely list these object files because for them
# MATROSKA_DLL_EXPORT must NOT be defined.
../../test/mux/test6.o: ../../test/mux/test6.cpp
	$(CXX) $(CXXFLAGS) -c -o $@ $<

test6:	../../test/mux/test6.o $(LIBS)
	$(LD) -o $@ $(LDFLAGS) $< -lmatroska -lebml

../../test/mux/test8.o: ../../test/mux/test8.cpp
	$(CXX) $(CXXFLAGS) -c -o $@ $<

test8:	../../test/mux/test8.o $(LIBS)
	$(LD) -o $@ $(LDFLAGS) $< -lmatroska -lebml

../../test/tags/test9.o: ../../test/tags/test9.cpp
	$(CXX) $(CXXFLAGS) -c -o $@ $<

test9:	../../test/tags/test9.o $(LIBS)
	$(LD) -o $@ $(LDFLAGS) $< -lmatroska -lebml

depend:
	$(CXX) $(CXXFLAGS) -MM $(SRC) > .depend

#
# include dependency files if they exist
#
ifneq ($(wildcard .depend),)
include .depend
endif
