
# Cross compiler
CROSS_COMPILE=arm-linux-gnueabihf-
CC=${CROSS_COMPILE}gcc
AR=${CROSS_COMPILE}ar

# libgpiod compile install path
LIBGPIOD_PATH=libgpiod/install

# compile flags and link flags
CFLAGS+=-I ${LIBGPIOD_PATH}/include
LDFLAGS+=-L ${LIBGPIOD_PATH}/lib -lgpiod

INSTALL_BINS=can_test

all: libs
	${CC} hello.c -o hello
	${CC} ${CFLAGS} leds.c -o leds ${LDFLAGS}
	${CC} keypad.c -o keypad
	${CC} ds18b20.c -o ds18b20
	${CC} pwm.c -o pwm
	${CC} pwm_play.c -o pwm_play
	${CC} sht20_fops.c -o sht20_fops
	${CC} sht20_ioctl.c -o sht20_ioctl
	${CC} spi_test.c -o spi_test
	${CC} ttyS_test.c -o ttyS_test -lpthread
	${CC} can_test.c -o can_test
	@make install

libs:
	make -C libgpiod CROSS_COMPILE=${CROSS_COMPILE}

clean:
	@rm -f hello
	@rm -f leds 
	@rm -f keypad
	@rm -f ds18b20
	@rm -f pwm 
	@rm -f pwm_play
	@rm -f sht20_fops
	@rm -f sht20_ioctl
	@rm -f spi_test
	@rm -f ttyS_test
	@rm -f can_test

distclean: clean
	make clean -C libgpiod

install:
	cp ${INSTALL_BINS} /tftp
