LingYun IoT Studio NB-IoT research project
Guo Wenxue
2018-11-20 67f8a597480e9951ea40e84997011660d09eeb84
src/cp_library/makefile
@@ -1,5 +1,5 @@
#*********************************************************************************
#      Copyright:  (C) 2012 Guo Wenxue <guowenxue@gmail.com>
#      Copyright:  (C) 2018 LingYun IoT Studio
#                  All rights reserved.
#
#       Filename:  Makefile
@@ -8,63 +8,37 @@
#                  static library named lib$(FOLDER_NAME).a orlib $(FOLDER_NAME).so,
#                  which depends on the variable $LINK_MODE.
#                      
#        Version:  1.0.0(10/08/2011~)
#        Version:  1.0.0
#                  Author:  Guo Wenxue <guowenxue@gmail.com>
#      ChangeLog:  1, Release initial version on "10/08/2011 01:29:33 AM"
#      ChangeLog:  1, Release initial version on "11/20/2018 11:29:33 AM"
#                       
#********************************************************************************/
PWD=$(shell pwd)
#If wanna compile in the subdir, not called by top makefile, uncomment it
ifneq (${TOP_COMPILE}, YES)
LOCAL_COMPILE=YES
endif
LINK_MODE=STATIC
#MULTHREADS=YES
LIBNAME=$(shell basename ${PWD})
STALIB=lib${LIBNAME}.a
DYNLIB=lib${LIBNAME}.so
CROSS_COMPILE?=/opt/rpi/arm-bcm2708/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-
LINK_MODE=STATIC
VPATH= .
SRCS = $(wildcard ${VPATH}/*.c)
OBJS = $(patsubst %.c,%.o,$(SRCS))
#======================================================
#  ---> Doesn't call by top makefile, compile by local
#======================================================
ifeq (${LOCAL_COMPILE}, YES)
ARCH?=arm
#ARCH?=i386
CFLAGS+=-fPIC
TMP=$(shell echo $(ARCH) | tr "[A-Z]" "[a-z]")
ifneq (,$(filter i386,$(TMP)))
    CROSS_COMPILE=
else
    CROSS_COMPILE=/opt/rpi/arm-bcm2708/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-
endif
PRJDIR?=$(shell dirname ${PWD})
CFLAGS+=-I${PRJDIR} -g -Wall -Werror
CFLAGS+=-I${PRJDIR}
CC = ${CROSS_COMPILE}gcc
AR = ${CROSS_COMPILE}ar
endif #End local compile
ifeq ("${LINK_MODE}", "STATIC")
   LIBS = ${STALIB} 
else 
   LIBS=${DYNLIB} ${STALIB}
   LIBS=${DYNLIB}
endif
ifeq ("${MULTHREADS}", "YES")
LDFLAGS+=-lpthread
CFLAGS+=-DMULTHREADS
endif
all: entry clean ${LIBS} install
all: entry ${LIBS} install
entry: 
   @echo " ";
@@ -82,27 +56,18 @@
%.o : %.c
   $(CC) -c $< $(CFLAGS)
test: clean ${LIBS}
   make -C test ARCH=${ARCH}
tag:
   @ctags --c-kinds=+defglmnstuvx --langmap=c:.c.h.ho.hem.het.hec.hev.him.hit.hic.hiv -R .
   @cscope -Rbq
install:
   @if [ ! -z "${LIBS_PATH}" ] ; then \
      mkdir -p ${LIBS_PATH} ; \
      cp ${LIBS} ${LIBS_PATH}; \
   fi;
clean:
   @rm -f *.o *.lo *~
   @rm -f *.o
   @rm -rf *.gdb *.a *.so
   @make clean -C test
   @rm -f *.log
distclean: clean
   @rm -f  tags cscope*
.PHONY: clean entry