guowenxue
2024-07-26 9cf87703eb60e121b47e6d577ea2bc6b63bd4ac4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
 
# 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