.PHONY: build clean

# 头文件
INCS += -I.
INCS += -I../swapi
INCS += -I./include

# 源文件
SRCS += $(filter-out ../swapi/testLib.c, $(wildcard ../swapi/*.c))
SRCS += ../swapi/subjects/serial/serial.c air720u.c

# .o文件
OBJS := $(SRCS:.c=.o)

# 编译器
CC := gcc
CFLAGS := -Wall -fPIC -O2 -g
DEFINS := -D_GNU_SOURCE

target ?= x86_64
ifeq ($(target),armv7hf)
  CC := arm-linux-gnueabihf-gcc
	AR := arm-linux-gnueabihf-ar
endif

# 库文件
LIBS += -Wl,-Bdynamic -lc -lm -ldl -lpthread

# 编译和清理
build : libair720u.a air720u_test.out

%.o : %.c
	$(CC) $(DEFINS) $(CFLAGS) -c $< $(INCS) -o $@

libair720u.a : $(OBJS)
	$(AR) -cr $@ $(OBJS)

air720u_test.out : $(OBJS) air720u_test.c
	$(CC) $(DEFINS) $(CFLAGS) $(OBJS) air720u_test.c $(INCS) $(LIBS) -o $@

clean :
	rm -rf $(OBJS) *.out *.a config/ log/ status/ var/
