#*********************************************************************************
|
# Copyright: (C) 2022 Avnet. All rights reserved.
|
# Author: Guo Wenxue<wenxue.guo@avnet.com>
|
#
|
# Filename: Makefile
|
# Description: This Makefile used to compile all the C source code file in
|
# current folder to a excutable binary file.
|
#
|
#********************************************************************************/
|
|
PRJ_PATH=$(shell pwd)
|
APP_NAME = gpsd
|
INST_PATH= /tftp
|
|
BUILD_ARCH=$(shell uname -m)
|
|
ifneq ($(findstring $(BUILD_ARCH), "x86_64" "i386"),)
|
CROSSTOOL=arm-linux-gnueabi-
|
endif
|
|
# C source files in top-level directory
|
SRCFILES = $(wildcard *.c)
|
|
# common CFLAGS for our source code
|
CFLAGS = -Wall -Wshadow -Wundef -Wmaybe-uninitialized -D_GNU_SOURCE
|
|
# C source file in sub-directory
|
DIRS= booster
|
DIRS_PATH=$(patsubst %,${PRJ_PATH}/%,$(DIRS))
|
CFLAGS+=$(patsubst %,-I%,$(DIRS_PATH))
|
LDFLAGS+=$(patsubst %,-L%,$(DIRS_PATH))
|
LIBS=$(patsubst %,-l%,$(DIRS))
|
|
LDFLAGS+=-lpthread
|
|
.PHONY:libs
|
all: entry modules binary
|
|
entry:
|
@echo "Building ${APP_NAME} on ${BUILD_ARCH}"
|
|
modules:
|
@set -e; for d in ${DIRS}; do $(MAKE) CROSSTOOL=${CROSSTOOL} CFLAGS="${CFLAGS}" -C $${d}; done
|
|
binary: ${SRCFILES}
|
$(CROSSTOOL)gcc $(CFLAGS) -o ${APP_NAME} $^ ${LDFLAGS} ${LIBS}
|
@echo " Compile over"
|
|
clean:
|
set -e; for d in ${DIRS}; do $(MAKE) clean -C $${d}; done
|
@rm -f *.o $(APP_NAME)
|
|
distclean: clean
|
@rm -rf cscope* tags
|
|
install:
|
cp ${APP_NAME} ${INST_PATH}
|