| #********************************************************************************* | 
| #      Copyright:  (C) 2022 Guo Wenxue | 
| #                  All rights reserved. | 
| # | 
| #       Filename:  Makefile | 
| #    Description:  This Makefile used to compile all the C source code file in current | 
| #                  folder to respective excutable binary files. | 
| # | 
| #        Version:  1.0.0(03/15/2022~) | 
| #                  Author:  Guo Wenxue <guowenxue@gmail.com> | 
| #      ChangeLog:  1, Release initial version on "03/15/2022 01:29:33 PM" | 
| # | 
| #********************************************************************************/ | 
|   | 
| PWD=$(shell pwd) | 
| INSTPATH=/tftp | 
|   | 
| CROSS_COMPILE?=arm-linux-gnueabihf- | 
| CC=${CROSS_COMPILE}gcc | 
|   | 
| LIB_PATH=$(shell dirname ${PWD}) | 
| LIB_NAME=$(shell basename ${LIB_PATH}) | 
|   | 
| SRCS = $(wildcard ${VPATH}/*.c) | 
| OBJS = $(patsubst %.c,%.o,$(SRCS)) | 
|   | 
| SRCFILES = $(wildcard *.c) | 
| BINARIES=$(SRCFILES:%.c=%) | 
|   | 
| CFLAGS+=-I${LIB_PATH} | 
| LDFLAGS+=-L${LIB_PATH} -l${LIB_NAME} | 
|   | 
| all: binaries install | 
|   | 
| binaries:  ${BINARIES} | 
|   | 
| %:  %.c | 
|     $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) | 
|   | 
| install: | 
|     cp $(BINARIES) ${INSTPATH} | 
|   | 
| clean: | 
|     @rm -f *.o *.log $(BINARIES) | 
|   | 
| distclean: clean | 
|     @rm -f  tags cscope* | 
|   | 
| .PHONY: clean entry |