guowenxue
2023-07-10 c13c9806f957ebc675462737f4b328d3ab89e028
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
51
52
53
54
55
56
57
#*********************************************************************************
#      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}