RaspberrPi project source code
guowenxue
2024-03-14 7fa125e56f1de17c2f6aeb9a410ff02ac4e78e85
commit | author | age
13d8a8 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)
29b331 15 APP_NAME = sock_client
13d8a8 16
G 17 BUILD_ARCH=$(shell uname -m)
18 ifneq ($(findstring $(BUILD_ARCH), "x86_64" "i386"),)
19     CROSS_COMPILE=arm-linux-gnueabihf-
20 endif
21
22 # C source files in top-level directory
23 SRCFILES = $(wildcard *.c)
24
25 # common CFLAGS for our source code
26 CFLAGS = -Wall -Wshadow -Wundef -Wmaybe-uninitialized -D_GNU_SOURCE
27
28 # sub-directory compiled to a library and need to link
29 SRCS=booster
30 SRCS_PATH=$(patsubst %,${PRJ_PATH}/%,$(SRCS))
31 CFLAGS+=$(patsubst %,-I%,$(SRCS_PATH))
32 LDFLAGS+=$(patsubst %,-L%,$(SRCS_PATH))
33 LIBS=$(patsubst %,-l%,$(SRCS))
34 LDFLAGS+=${LIBS}
35
36 # Open source libraries
37 CFLAGS+=-I ${PRJ_PATH}/sqlite/install/include
38 LDFLAGS+=-L ${PRJ_PATH}/sqlite/install/lib
39 LDFLAGS+=-lsqlite3
40 LDFLAGS+=-lpthread
41
29b331 42 # sub-directory need to entry and compile
bffa2b 43 SUBDIR=sqlite ${SRCS}
29b331 44
13d8a8 45 all: entry subdir
29b331 46     ${CROSS_COMPILE}gcc ${CFLAGS} sock_client.c -o sock_client ${LDFLAGS}
13d8a8 47
G 48 entry:
49     @echo "Building ${APP_NAME} on ${BUILD_ARCH}"
50
51 subdir:
52     @for dir in ${SUBDIR} ; do if [ ! -e $${dir} ] ; then ln -s ../$${dir}; fi; done
29b331 53     @for dir in ${SUBDIR} ;  do make CFLAGS="${CFLAGS}" -C $${dir} ; done
13d8a8 54
G 55 install:
56     cp ${APP_NAME} /tftp
57
58 clean:
59     @for dir in ${SRCS} ; do if [ -e $${dir} ] ; then make clean -C $${dir}; fi; done
60     @rm -f ${APP_NAME}
61
62 distclean:
63     @for dir in ${SUBDIR} ; do if [ -e $${dir} ] ; then make clean -C $${dir}; fi; done
64     @rm -f ${APP_NAME}
65     @rm -f cscope.* tags
47098a 66     @rm -f *.log *.db
13d8a8 67