# CFLAGS= /Zi /Od /DDEBUG /Fa /GS-
CFLAGS= /Zi /Od /DDEBUG /Fa

# SOURCES = main.c
SOURCES = main.c functions_1.c functions_2.c functions_3.c functions_4.c functions_5.c functions_6.c
OBJETS = $(SOURCES:.c=.obj)
TARGET_EXE = main.exe

all: $(TARGET_EXE)

$(TARGET_EXE): $(OBJETS)
	@$(CC) $(CFLAGS) $** -Fe$@

.c.obj:
	@$(CC) $(CFLAGS) -c $< -Fo$*.obj

clean:
	@del *.pdb
	@del *.obj
	@del *.ilk
	@del *.exe
	@del *.asm
	@del *.html

distclean: clean
	@del *.png
	@del *.svg
	@del *.instrumented
	@del return_info.json

graphs: main_structure_graph main_call_light_graph main_call_graph

main_structure_graph: main.structure.dot
	-dot main.structure.dot -Tpng -o main.structure.png
	-dot main.structure.dot -Tsvg -o main.structure.svg

main_call_graph: main.call.dot
	-twopi main.call.dot -Tpng -o main.call.png
	-twopi main.call.dot -Tsvg -o main.call.svg

main_call_light_graph: main.call_light.dot
	-twopi main.call_light.dot -Tpng -o main.call_light.png
	-twopi main.call_light.dot -Tsvg -o main.call_light.svg

instrument:
	..\..\tools\instrumentator\Release\instrumentator.exe \
	-o return_info.json \
	-I "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include" \
	-D DEBUG \
	-s \
	$(SOURCES)

asm: $(SOURCES:.c=.html)

.asm.html:
	python ..\..\tools\weave_c_in_asm.py $< $*.html