Feature/makefile add apps library (#218)

* add BACnet stack library at apps/lib

* convert apps to use apps/lib for smaller binary

* fix -DBACDL_ALL=1 build

* fix piface build

* datalink MAX_MPDU and MAX_HEADER cleanup

* add bip6 to git workflow

* fix system library dependency of BACnet library

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
Steve Karg
2022-01-29 15:55:40 -06:00
committed by GitHub
parent 9c72572692
commit 295f127c2b
79 changed files with 917 additions and 1104 deletions
+101 -124
View File
@@ -11,6 +11,12 @@
BACNET_DEFINES ?=
BACNET_LIB ?=
# BACnet Library
BACNET_LIB_DIR = $(realpath lib)
BACNET_LIB_NAME = bacnet
BACNET_LIB_TARGET = $(BACNET_LIB_DIR)/lib$(BACNET_LIB_NAME).a
BACNET_LIB=-L$(BACNET_LIB_DIR),-l$(BACNET_LIB_NAME)
# choose a datalink to build the example applications
# Use BACDL=mstp or BACDL=bip and BBMD=server when invoking make
@@ -113,90 +119,19 @@ BACNET_DEFINES += -DBACNET_PROTOCOL_REVISION=17
# put all the flags together
INCLUDES = -I$(BACNET_SRC_DIR) -I$(BACNET_PORT_DIR)
CFLAGS += $(WARNINGS) $(DEBUGGING) $(OPTIMIZATION) $(BACNET_DEFINES) $(INCLUDES)
LFLAGS += -Wl,$(SYSTEM_LIB)
ifneq (${BACNET_LIB},)
LFLAGS += -Wl,$(BACNET_LIB)
endif
# BACnet library depends on system flags.
# System flags must go after BACnet library flags.
LFLAGS += -Wl,$(SYSTEM_LIB)
# GCC dead code removal
CFLAGS += -ffunction-sections -fdata-sections
LFLAGS += -Wl,--gc-sections
PORT_ARCNET_SRC = \
$(BACNET_PORT_DIR)/arcnet.c
PORT_MSTP_SRC = \
$(BACNET_PORT_DIR)/rs485.c \
$(BACNET_PORT_DIR)/dlmstp.c \
$(BACNET_SRC_DIR)/bacnet/datalink/mstp.c \
$(BACNET_SRC_DIR)/bacnet/datalink/mstptext.c \
$(BACNET_SRC_DIR)/bacnet/datalink/crc.c
PORT_ETHERNET_SRC = \
$(BACNET_PORT_DIR)/ethernet.c
PORT_BIP_SRC = \
$(BACNET_PORT_DIR)/bip-init.c \
$(BACNET_SRC_DIR)/bacnet/datalink/bvlc.c \
$(BACNET_SRC_DIR)/bacnet/basic/bbmd/h_bbmd.c
PORT_BIP6_SRC = \
$(BACNET_PORT_DIR)/bip6.c \
$(BACNET_SRC_DIR)/bacnet/basic/bbmd6/h_bbmd6.c \
$(BACNET_SRC_DIR)/bacnet/basic/bbmd6/vmac.c \
$(BACNET_SRC_DIR)/bacnet/datalink/bvlc6.c
PORT_ALL_SRC = \
$(BACNET_SRC_DIR)/bacnet/datalink/datalink.c \
$(PORT_ARCNET_SRC) \
$(PORT_MSTP_SRC) \
$(PORT_ETHERNET_SRC) \
$(PORT_BIP_SRC) \
$(PORT_BIP6_SRC)
PORT_NONE_SRC = \
$(BACNET_SRC_DIR)/bacnet/datalink/datalink.c
ifeq (${BACDL_DEFINE},-DBACDL_BIP=1)
BACNET_PORT_SRC = ${PORT_BIP_SRC}
endif
ifeq (${BACDL_DEFINE},-DBACDL_BIP6=1)
BACNET_PORT_SRC = ${PORT_BIP6_SRC}
endif
ifeq (${BACDL_DEFINE},-DBACDL_MSTP=1)
BACNET_PORT_SRC = ${PORT_MSTP_SRC}
endif
ifeq (${BACDL_DEFINE},-DBACDL_ARCNET=1)
BACNET_PORT_SRC = ${PORT_ARCNET_SRC}
endif
ifeq (${BACDL_DEFINE},-DBACDL_ETHERNET=1)
BACNET_PORT_SRC = ${PORT_ETHERNET_SRC}
endif
ifeq (${BACDL_DEFINE},-DBACDL_NONE=1)
BACNET_PORT_SRC = ${PORT_NONE_SRC}
endif
ifdef BACDL_ALL
BACNET_PORT_SRC = ${PORT_ALL_SRC}
endif
BACNET_PORT_SRC += \
$(BACNET_SRC_DIR)/bacnet/datalink/dlenv.c \
$(BACNET_PORT_DIR)/mstimer-init.c \
$(BACNET_PORT_DIR)/datetime-init.c \
BACNET_SRC ?= \
$(wildcard $(BACNET_SRC_DIR)/bacnet/*.c) \
BACNET_BASIC_SRC ?= \
$(wildcard $(BACNET_SRC_DIR)/bacnet/basic/*.c) \
$(wildcard $(BACNET_SRC_DIR)/bacnet/basic/binding/*.c) \
$(wildcard $(BACNET_SRC_DIR)/bacnet/basic/sys/*.c) \
$(BACNET_SRC_DIR)/bacnet/basic/npdu/h_npdu.c \
$(BACNET_SRC_DIR)/bacnet/basic/npdu/s_router.c \
$(BACNET_SRC_DIR)/bacnet/basic/tsm/tsm.c
.EXPORT_ALL_VARIABLES:
SUBDIRS = readprop writeprop readfile writefile reinit server dcc \
SUBDIRS = lib readprop writeprop readfile writefile reinit server dcc \
whohas whois iam ucov scov timesync epics readpropm readrange \
writepropm uptransfer getevent uevent abort error event ack-alarm
@@ -225,13 +160,55 @@ $(TARGETS): %: $(patsubst %, %.%, $(SUBDIRS))
$(foreach TGT, $(TARGETS), $(patsubst %, %.$(TGT), $(SUBDIRS))):
$(MAKE) -b -C $(subst ., , $@)
.PHONY: lib
lib: lib/Makefile Makefile $(BACNET_LIB_TARGET)
$(BACNET_LIB_TARGET):
$(MAKE) -b -C lib
.PHONY: gateway
gateway:
gateway: $(BACNET_LIB_TARGET)
$(MAKE) -b -C gateway
.PHONY: server
server:
$(MAKE) -s -b -C $@
.PHONY: abort
abort: $(BACNET_LIB_TARGET)
$(MAKE) -b -C $@
.PHONY: ack-alarm
ack-alarm: $(BACNET_LIB_TARGET)
$(MAKE) -b -C $@
.PHONY: dcc
dcc: $(BACNET_LIB_TARGET)
$(MAKE) -b -C $@
.PHONY: epics
epics: $(BACNET_LIB_TARGET)
$(MAKE) -b -C $@
.PHONY: error
error: $(BACNET_LIB_TARGET)
$(MAKE) -b -C $@
.PHONY: event
event: $(BACNET_LIB_TARGET)
$(MAKE) -b -C $@
.PHONY: getevent
getevent: $(BACNET_LIB_TARGET)
$(MAKE) -b -C $@
.PHONY: iam
iam: $(BACNET_LIB_TARGET)
$(MAKE) -b -C $@
.PHONY: iamrouter
iamrouter: $(BACNET_LIB_TARGET)
$(MAKE) -b -C $@
.PHONY: initrouter
initrouter: $(BACNET_LIB_TARGET)
$(MAKE) -b -C $@
.PHONY: mstpcap
mstpcap:
@@ -241,79 +218,79 @@ mstpcap:
mstpcrc:
$(MAKE) -b -C $@
.PHONY: abort
abort:
.PHONY: ptransfer
ptransfer: $(BACNET_LIB_TARGET)
$(MAKE) -b -C $@
.PHONY: ack-alarm
ack-alarm:
.PHONY: readprop
readprop: $(BACNET_LIB_TARGET)
$(MAKE) -b -C $@
.PHONY: dcc
dcc:
$(MAKE) -b -C $@
.PHONY: epics
epics:
$(MAKE) -b -C $@
.PHONY: error
error:
$(MAKE) -b -C $@
.PHONY: event
event:
$(MAKE) -b -C $@
.PHONY: getevent
getevent:
$(MAKE) -b -C $@
.PHONY: iam
iam:
$(MAKE) -b -C $@
.PHONY: iamrouter
iamrouter:
$(MAKE) -b -C $@
.PHONY: initrouter
initrouter:
.PHONY: readpropm
readpropm: $(BACNET_LIB_TARGET)
$(MAKE) -b -C $@
.PHONY: readbdt
readbdt:
readbdt: $(BACNET_LIB_TARGET)
$(MAKE) -b -C $@
.PHONY: readfdt
readfdt:
readfdt: $(BACNET_LIB_TARGET)
$(MAKE) -b -C $@
.PHONY: readfile
readfile: $(BACNET_LIB_TARGET)
$(MAKE) -b -C $@
.PHONY: readrange
readrange: $(BACNET_LIB_TARGET)
$(MAKE) -b -C $@
.PHONY: reinit
reinit: $(BACNET_LIB_TARGET)
$(MAKE) -b -C $@
.PHONY: scov
scov: $(BACNET_LIB_TARGET)
$(MAKE) -b -C $@
.PHONY: server
server: $(BACNET_LIB_TARGET)
$(MAKE) -s -b -C $@
.PHONY: timesync
timesync: $(BACNET_LIB_TARGET)
$(MAKE) -b -C $@
.PHONY: uevent
uevent:
$(MAKE) -b -C $@
uevent: $(BACNET_LIB_TARGET)
$(MAKE) -C $@
.PHONY: whois
whois:
whois: $(BACNET_LIB_TARGET)
$(MAKE) -b -C $@
.PHONY: writebdt
writebdt:
writebdt: $(BACNET_LIB_TARGET)
$(MAKE) -b -C $@
.PHONY: writefile
writefile: $(BACNET_LIB_TARGET)
$(MAKE) -b -C $@
.PHONY: router
router:
$(MAKE) -s -b -C $@
router: $(BACNET_LIB_TARGET)
$(MAKE) -b -C $@
.PHONY: router-ipv6
router-ipv6:
router-ipv6: $(BACNET_LIB_TARGET)
$(MAKE) -b -C $@
.PHONY: router-mstp
router-mstp:
router-mstp: $(BACNET_LIB_TARGET)
$(MAKE) -b -C $@
.PHONY: writepropm
writepropm:
writepropm: $(BACNET_LIB_TARGET)
$(MAKE) -b -C $@