TARGET = patrol pilot test motor_stop
all: $(TARGET)

#include rtl.mk
INCLUDE= 
CFLAGS = -Wall -O2 `pkg-config --cflags opencv`
LIB = -lpthread  -lm
CVLIB = `pkg-config --libs opencv`
CC = gcc
DIRS = ./:number/

vpath %.c $(DIRS)


HEAD=device.h  hardware.h  mirsak.h  direction.h uss.h test.h encoder.h motor.h vel_ctrl.h test.h  run_ctrl.h

OBJS_PILOT = mirsak_patrol.o  pilot.o

#OBJS_BASE=device.o  encoder.o motor.o vel_ctrl.o run_ctrl.o uss.o uss_serial.o distance.o direction.o binarization.o labelling.o number_search.o triming.o get_img.o number_detect.o io.o

OBJS_BASE=device.o  encoder.o motor.o vel_ctrl.o run_ctrl.o uss.o uss_serial.o distance.o direction.o io.o

OBJS_NUM= binarization.o labelling.o number_search.o triming.o get_img.o number_detect.o

OBJS_TEST=test.o test_motor.o test_vel_ctrl.o test_pwm_vel.o test_pwm.o test_encoder.o test_distance.o test_run_ctrl.o test_uss.o test_direction.o test_number.o test_dir_num.o test_io.o 

patrol: patrol_sequence.h mirsak_patrol.c
	$(CC) -c -Wall mirsak_patrol.c

main:$(OBJS_PILOT) $(OBJS_BASE) $(OBJS_NUM) $(HEAD) orifunc.h orifunc.o
	$(CC) ${INCLUDE} $(LIB) $(CVLIB) $(CFLAGS) $(OBJS_PILOT) $(OBJS_BASE) $(OBJS_NUM) orifunc.o -o main

test:$(OBJS_TEST) $(OBJS_BASE) $(OBJS_NUM) $(HEAD) 
	$(CC) ${INCLUDE} $(LIB) $(CVLIB) $(CFLAGS) $(OBJS_TEST) $(OBJS_BASE) $(OBJS_NUM)  -o test

motor_stop: motor_stop.o
	$(CC) ${INCLUDE} $(CFLAGS) motor_stop.o -o motor_stop

number:
	@echo
	@echo "================= making number program"
	(cd number; make)

#%.o:%.c patrol_sequence.h
%.o:%.c
	$(CC) $(INCLUDE)  $(LIB) $(CFLAGS) -c $<

clean:
	rm -f *.o $(TARGET)
	rm -f number/*.o

nclean:
	rm -f binarization.o labelling.o number_search.o triming.o get_img.o number_detect.o
	rm -f number/*.o


