cc=g++
cflag=-Wall -std=c++0x -pg -rdynamic

inc_path=./
bin_dir=../bin/
src_dir=./
incs=-I$(inc_path)
clib=

objects=

# ls *.cpp  | sed 's/.cpp/.o/g' | sed 's/^/objects+=/'
objects+=ines_header.o
objects+=instruction_map.o
objects+=instruction_output.o
objects+=instruction_scanner.o
objects+=main.o
objects+=opcode_info.o
objects+=operand_info.o


build: $(bin_dir) $(bin_dir)sau

$(bin_dir)sau: $(objects:%=$(bin_dir)%)
	$(cc) $(cflag) $(incs) -o $@ $^ $(clib)


$(bin_dir)%.o: $(src_dir)%.cpp $(bin_dir)
	$(cc) $(cflag) $(incs) -o $@ -c $< $(clib)

$(bin_dir):
	mkdir $@
clean:
	rm -r $(bin_dir)

# Dependencies
# g++ -MM -I. *.cpp

ines_header.o: ines_header.cpp ines_header.hpp \
 chocolat/string/number_format.hpp chocolat/string/string_aligner.hpp \
 chocolat/string/string_repeat.hpp
instruction_map.o: instruction_map.cpp instruction_map.hpp \
 binary_data.hpp opcode_info.hpp operand_info.hpp opcode_utility.hpp \
 debug_macro.hpp
instruction_output.o: instruction_output.cpp instruction_output.hpp \
 instruction_map.hpp binary_data.hpp opcode_info.hpp operand_info.hpp \
 opcode_utility.hpp chocolat/string/number_format.hpp \
 chocolat/string/string_aligner.hpp chocolat/string/string_repeat.hpp
instruction_scanner.o: instruction_scanner.cpp instruction_scanner.hpp \
 instruction_map.hpp binary_data.hpp opcode_info.hpp operand_info.hpp \
 debug_macro.hpp
main.o: main.cpp application_option.hpp chocolat/system/option_parser.hpp \
 chocolat/list/word_stream.hpp \
 chocolat/system/invalid_option_exception.hpp debug_macro.hpp \
 chocolat/system/file_path.hpp chocolat/string/number_format.hpp \
 nes_program_image.hpp binary_data.hpp ines_header.hpp \
 chocolat/system/stream_measure.hpp \
 chocolat/system/file_not_found_exception.hpp instruction_map.hpp \
 opcode_info.hpp operand_info.hpp instruction_scanner.hpp \
 instruction_output.hpp control_point.hpp address_list.hpp marker.hpp \
 worklist.hpp opcode_utility.hpp basic_block.hpp \
 chocolat/string/string_aligner.hpp chocolat/string/string_repeat.hpp \
 routine_list.hpp container_utility.hpp dominator_list.hpp \
 loop_structure.hpp
opcode_info.o: opcode_info.cpp opcode_info.hpp
operand_info.o: operand_info.cpp operand_info.hpp opcode_info.hpp
