
# tools

LINK		= gcc
CC		= gcc
CXX		= gcc

LEX		= flex
YACC		= bison
FSMGENERATOR	= fsmgenerator

ECHO		= echo
MAKE		= make

CP		= cp
INSTALL		= install

# flags

RCFLAGS		=
RLFLAGS		= -L/usr/lib
RINCFLAGS	= -I../../api/Cpp
RLIBRARIES	= -lstdc++

DCFLAGS		= -g
DLFLAGS		= -L/usr/lib
DINCFLAGS	= -I../../api/Cpp
DLIBRARIES	= /usr/lib/libstdc++.a

# status

ifndef STATUS
STATUS		= Release
endif

ifeq ($(STATUS),Release)
CFLAGS		= $(RCFLAGS)
LFLAGS		= $(RLFLAGS)
INCFLAGS	= $(RINCFLAGS)
LIBRARIES	= $(RLIBRARIES)
endif

ifeq ($(STATUS),Debug)
CFLAGS		= $(DCFLAGS)
LFLAGS		= $(DLFLAGS)
INCFLAGS	= $(DINCFLAGS)
LIBRARIES	= $(DLIBRARIES)
endif

# variables

MODULES		= 

SOURCES		= main_FSMIsEven.cpp \
			FSMIsEven/FSMIsEven.cpp \
			main_FSMRing.cpp \
			FSMRing/FSMRing.cpp
OBJECTS		= main_FSMIsEven.o \
			FSMIsEven/FSMIsEven.o \
			main_FSMRing.o \
			FSMRing/FSMRing.o
TARGETS		= test_FSMIsEven \
			test_FSMRing
OUTPUTS		= FSMIsEven FSMRing

#rules

all:	$(TARGETS)

#################

test_FSMIsEven: FSMIsEven main_FSMIsEven.o FSMIsEven/FSMIsEven.o
	$(LINK) $(LFLAGS) -o $@ main_FSMIsEven.o FSMIsEven/FSMIsEven.o $(LIBRARIES)

FSMIsEven:
	-$(FSMGENERATOR) ../FSM/FSMIsEven.fsm Cpp .

main_FSMIsEven.o: main_FSMIsEven.cpp
	$(CC) -c $(CFLAGS) $(INCFLAGS) -IFSMIsEven -o $@ $?
	
FSMIsEven/FSMIsEven.o: FSMIsEven/FSMIsEven.cpp
	$(CC) -c $(CFLAGS) $(INCFLAGS) -I. -o $@ $?
	
test_FSMRing: FSMRing main_FSMRing.o FSMRing/FSMRing.o
	$(LINK) $(LFLAGS) -o $@ main_FSMRing.o FSMRing/FSMRing.o $(LIBRARIES)

FSMRing:
	-$(FSMGENERATOR) ../FSM/FSMRing.fsm Cpp .

main_FSMRing.o: main_FSMRing.cpp
	$(CC) -c $(CFLAGS) $(INCFLAGS) -IFSMRing -o $@ $?
	
FSMRing/FSMRing.o: FSMRing/FSMRing.cpp
	$(CC) -c $(CFLAGS) $(INCFLAGS) -I. -o $@ $?
	
###########

clean:
	rm -rf core $(OBJECTS) *~

cleanall:
	rm -rf $(TARGETS) $(OUTPUTS) core $(OBJECTS) *~

help:
	@echo "To compile, please, run: 'make all'"

PHONY-TARGETS = all \
		clean \
		cleanall \
		help
.PHONY: $(PHONY-TARGETS)
