RaspberrPi project source code
guowenxue
2024-03-12 c5e9e88eb8c6039cd2a4d2b3fdae0b1e3d8aea40
commit | author | age
d6b4a7 1 #********************************************************************************
G 2 #      Copyright:  (C) 2023 LingYun IoT System Studio
3 #                  All rights reserved.
4 #
5 #       Filename:  Makefile
6 #    Description:  This file is the project top Makefie
7 #
8 #        Version:  1.0.0(11/08/23)
9 #         Author:  Guo Wenxue <guowenxue@gmail.com>
10 #      ChangeLog:  1, Release initial version on "11/08/23 16:18:43"
11 #
12 #*******************************************************************************
13
14 PRJ_PATH=$(shell pwd)
15 APP_NAME = gpsd
16 INST_PATH= /tftp
17
18 BUILD_ARCH=$(shell uname -m)
19 ifneq ($(findstring $(BUILD_ARCH), "x86_64" "i386"),)
20     CROSS_COMPILE=arm-linux-gnueabihf-
21 endif
22
23 # C source files in top-level directory
24 SRCFILES = $(wildcard *.c)
25
26 # common CFLAGS for our source code
27 CFLAGS = -Wall -Wshadow -Wundef -Wmaybe-uninitialized -D_GNU_SOURCE
28
29 # C source file in sub-directory
30 DIRS= booster
31 DIRS_PATH=$(patsubst %,${PRJ_PATH}/%,$(DIRS))
32 CFLAGS+=$(patsubst %,-I%,$(DIRS_PATH))
33 LDFLAGS+=$(patsubst %,-L%,$(DIRS_PATH))
34 LIBS=$(patsubst %,-l%,$(DIRS))
35 LDFLAGS+=${LIBS}
36
37 LDFLAGS+=-lpthread
38
39 .PHONY:libs
40 all: entry modules binary
41
42 entry:
43     @echo "Building ${APP_NAME} on ${BUILD_ARCH}"
44     @if [ ! -e booster ] ; then ln -s ../booster; fi
45
46 modules:
47     @set -e; for d in ${DIRS}; do $(MAKE) CROSS_COMPILE=${CROSS_COMPILE} CFLAGS="${CFLAGS}" -C $${d}; done
48
49 binary:  ${SRCFILES}
50     $(CROSS_COMPILE)gcc $(CFLAGS) -o ${APP_NAME} $^ ${LDFLAGS}
51     @echo " Compile over"
52
53 clean:
54     set -e; for d in ${DIRS}; do $(MAKE) clean -C $${d}; done
55     @rm -f *.o $(APP_NAME)
56
57 distclean: clean
58     @rm -rf cscope* tags
59     @rm -f booster
60
61 install:
62     cp ${APP_NAME} ${INST_PATH}