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) |
|
15 |
APP_NAME = client |
|
16 |
|
|
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 need to entry and compile |
|
29 |
SUBDIR=booster sqlite |
|
30 |
|
|
31 |
# sub-directory compiled to a library and need to link |
|
32 |
SRCS=booster |
|
33 |
SRCS_PATH=$(patsubst %,${PRJ_PATH}/%,$(SRCS)) |
|
34 |
CFLAGS+=$(patsubst %,-I%,$(SRCS_PATH)) |
|
35 |
LDFLAGS+=$(patsubst %,-L%,$(SRCS_PATH)) |
|
36 |
LIBS=$(patsubst %,-l%,$(SRCS)) |
|
37 |
LDFLAGS+=${LIBS} |
|
38 |
|
|
39 |
# Open source libraries |
|
40 |
CFLAGS+=-I ${PRJ_PATH}/sqlite/install/include |
|
41 |
LDFLAGS+=-L ${PRJ_PATH}/sqlite/install/lib |
|
42 |
LDFLAGS+=-lsqlite3 |
|
43 |
|
|
44 |
LDFLAGS+=-lpthread |
|
45 |
|
|
46 |
all: entry subdir |
|
47 |
${CROSS_COMPILE}gcc ${CFLAGS} client.c -o client ${LDFLAGS} |
|
48 |
|
|
49 |
entry: |
|
50 |
@echo "Building ${APP_NAME} on ${BUILD_ARCH}" |
|
51 |
|
|
52 |
subdir: |
|
53 |
@for dir in ${SUBDIR} ; do if [ ! -e $${dir} ] ; then ln -s ../$${dir}; fi; done |
|
54 |
@for dir in ${SUBDIR} ; do make -C $${dir} ; done |
|
55 |
|
|
56 |
install: |
|
57 |
cp ${APP_NAME} /tftp |
|
58 |
|
|
59 |
clean: |
|
60 |
@for dir in ${SRCS} ; do if [ -e $${dir} ] ; then make clean -C $${dir}; fi; done |
|
61 |
@rm -f ${APP_NAME} |
|
62 |
|
|
63 |
distclean: |
|
64 |
@for dir in ${SUBDIR} ; do if [ -e $${dir} ] ; then make clean -C $${dir}; fi; done |
|
65 |
@rm -f ${APP_NAME} |
|
66 |
@rm -f cscope.* tags |
|
67 |
|