diff --git a/bacnet-stack/Makefile b/bacnet-stack/Makefile index 097266be..9f1b2b05 100644 --- a/bacnet-stack/Makefile +++ b/bacnet-stack/Makefile @@ -17,9 +17,6 @@ MY_BACNET_DEFINES += -DBACFILE MY_BACNET_DEFINES += -DINTRINSIC_REPORTING BACNET_DEFINES ?= $(MY_BACNET_DEFINES) -# un-comment the next line to build the routing demo application -#BACNET_DEFINES += -DBAC_ROUTING - #BACDL_DEFINE=-DBACDL_ETHERNET=1 #BACDL_DEFINE=-DBACDL_ARCNET=1 #BACDL_DEFINE=-DBACDL_MSTP=1 @@ -37,19 +34,10 @@ MAKE_DEFINE ?= DEFINES = $(BACNET_DEFINES) $(BACDL_DEFINE) $(BBMD_DEFINE) -DWEAK_FUNC= DEFINES += $(MAKE_DEFINE) -# directories +# BACnet Ports Directory BACNET_PORT ?= linux -BACNET_PORT_DIR = ../ports/${BACNET_PORT} -BACNET_OBJECT = ../demo/object -BACNET_HANDLER = ../demo/handler -BACNET_CORE = ../src -BACNET_INCLUDE = ../include -# compiler configuration -#STANDARDS = -std=c99 -INCLUDE1 = -I$(BACNET_PORT_DIR) -I$(BACNET_OBJECT) -I$(BACNET_HANDLER) -INCLUDE2 = -I$(BACNET_INCLUDE) -INCLUDES = $(INCLUDE1) $(INCLUDE2) +# Default compiler settings OPTIMIZATION = -Os DEBUGGING = WARNINGS = -Wall -Wmissing-prototypes @@ -75,6 +63,9 @@ library: demos: $(MAKE) -s -C demo all +gateway: + $(MAKE) -B -s -C demo gateway + router: $(MAKE) -s -C demo router diff --git a/bacnet-stack/demo/Makefile b/bacnet-stack/demo/Makefile index 8e17135b..2f9550a9 100644 --- a/bacnet-stack/demo/Makefile +++ b/bacnet-stack/demo/Makefile @@ -21,25 +21,20 @@ BACNET_LIB_TARGET = $(BACNET_LIB_DIR)/lib$(BACNET_LIB_NAME).a INCLUDE1 = -I$(BACNET_PORT_DIR) -I$(BACNET_OBJECT) -I$(BACNET_HANDLER) INCLUDE2 = -I$(BACNET_INCLUDE) INCLUDES = $(INCLUDE1) $(INCLUDE2) +BACNET_LIB=-L$(BACNET_LIB_DIR),-l$(BACNET_LIB_NAME) ifeq (${BACNET_PORT},linux) PFLAGS = -pthread TARGET_EXT = -LIBRARY1=-L$(BACNET_LIB_DIR),-l$(BACNET_LIB_NAME) -LIBRARY2=-lc,-lgcc,-lrt,-lm -LIBRARIES=$(LIBRARY1),$(LIBRARY2) +SYSTEM_LIB=-lc,-lgcc,-lrt,-lm endif ifeq (${BACNET_PORT},bsd) PFLAGS = -pthread TARGET_EXT = -LIBRARY1=-L$(BACNET_LIB_DIR),-l$(BACNET_LIB_NAME) -LIBRARY2=-lc,-lgcc,-lm -LIBRARIES=$(LIBRARY1),$(LIBRARY2) +SYSTEM_LIB=-lc,-lgcc,-lm endif ifeq (${BACNET_PORT},win32) TARGET_EXT = .exe -LIBRARY1=-L$(BACNET_LIB_DIR),-l$(BACNET_LIB_NAME) -LIBRARY2=-lws2_32,-lgcc,-lm,-liphlpapi,-lwinmm -LIBRARIES=$(LIBRARY1),$(LIBRARY2) +SYSTEM_LIB=-lws2_32,-lgcc,-lm,-liphlpapi,-lwinmm endif #build for release (default) or debug DEBUGGING = @@ -49,8 +44,8 @@ OPTIMIZATION = -O0 DEBUGGING = -g endif # put all the flags together -CFLAGS = -Wall $(DEBUGGING) $(OPTIMIZATION) $(INCLUDES) $(DEFINES) -LFLAGS = -Wl,$(LIBRARIES) +CFLAGS := -Wall $(DEBUGGING) $(OPTIMIZATION) $(INCLUDES) $(DEFINES) +LFLAGS := -Wl,$(BACNET_LIB),$(SYSTEM_LIB) .EXPORT_ALL_VARIABLES: @@ -70,11 +65,7 @@ ifeq (${BACNET_PORT},win32) SUBDIRS += ptransfer mstpcap mstpcrc endif -ifneq (,$(findstring -DBAC_ROUTING,$(BACNET_DEFINES))) - SUBDIRS += gateway -endif - -.PHONY : all router clean +.PHONY : all gateway router clean TARGETS = all clean @@ -83,5 +74,11 @@ $(TARGETS): %: $(patsubst %, %.%, $(SUBDIRS)) $(foreach TGT, $(TARGETS), $(patsubst %, %.$(TGT), $(SUBDIRS))): $(MAKE) -s -b -C $(subst ., , $@) +gateway: + $(MAKE) -s -b -C gateway + router: $(MAKE) -s -b -C router + + + diff --git a/bacnet-stack/demo/gateway/Makefile b/bacnet-stack/demo/gateway/Makefile index d97d2862..f74446e1 100644 --- a/bacnet-stack/demo/gateway/Makefile +++ b/bacnet-stack/demo/gateway/Makefile @@ -9,21 +9,22 @@ TARGET = bacgateway TARGET_BIN = ${TARGET}$(TARGET_EXT) +# put any overloaded or special built src files here, +# so the linker uses these instead of the functions in the library SRCS = main.c \ $(BACNET_OBJECT)/gw_device.c \ - ${CORE_SRC} \ - ${PORT_SRC} \ - ${HANDLER_SRC} \ - ${OBJECT_SRC} \ - ${ROUTING_SRC} + $(BACNET_HANDLER)/h_routed_npdu.c \ + $(BACNET_HANDLER)/s_router.c OBJS = ${SRCS:.c=.o} DEFINES += -DBAC_ROUTING +CFLAGS = $(WARNINGS) $(DEBUGGING) $(OPTIMIZATION) $(STANDARDS) $(INCLUDES) $(DEFINES) + all: ${BACNET_LIB_TARGET} Makefile ${TARGET_BIN} -${TARGET_BIN}: ${OBJS} Makefile ${BACNET_LIB_TARGET} +${TARGET_BIN}: ${OBJS} Makefile ${BACNET_LIB_TARGET} ${CC} ${PFLAGS} ${OBJS} ${LFLAGS} -o $@ size $@ cp $@ ../../bin @@ -44,3 +45,4 @@ clean: rm -f core ${TARGET_BIN} ${OBJS} ${BACNET_LIB_TARGET} $(TARGET).map include: .depend + diff --git a/bacnet-stack/demo/object/gw_device.c b/bacnet-stack/demo/object/gw_device.c index 456722d8..84e3109d 100644 --- a/bacnet-stack/demo/object/gw_device.c +++ b/bacnet-stack/demo/object/gw_device.c @@ -410,7 +410,7 @@ bool Routed_Device_Name( pDev->bacObj.Object_Name); } - return FALSE; + return false; } /** Manages ReadProperty service for fields which are different for routed diff --git a/bacnet-stack/lib/Makefile b/bacnet-stack/lib/Makefile index e25e7610..74b9a20a 100644 --- a/bacnet-stack/lib/Makefile +++ b/bacnet-stack/lib/Makefile @@ -9,6 +9,17 @@ # # Assumes rm and cp are available +BACNET_PORT_DIR = ../ports/${BACNET_PORT} +BACNET_OBJECT = ../demo/object +BACNET_HANDLER = ../demo/handler +BACNET_CORE = ../src +BACNET_INCLUDE = ../include +# compiler configuration +#STANDARDS = -std=c99 +INCLUDE1 = -I$(BACNET_PORT_DIR) -I$(BACNET_OBJECT) -I$(BACNET_HANDLER) +INCLUDE2 = -I$(BACNET_INCLUDE) +INCLUDES = $(INCLUDE1) $(INCLUDE2) + # target TARGET = bacnet LIBRARY = lib$(TARGET).a @@ -103,11 +114,11 @@ HANDLER_SRC = \ $(BACNET_HANDLER)/s_cov.c \ $(BACNET_HANDLER)/s_ptransfer.c \ $(BACNET_HANDLER)/s_rd.c \ - $(BACNET_HANDLER)/s_router.c \ $(BACNET_HANDLER)/s_rp.c \ $(BACNET_HANDLER)/s_rpm.c \ $(BACNET_HANDLER)/s_ts.c \ $(BACNET_HANDLER)/s_cevent.c \ + $(BACNET_HANDLER)/s_router.c \ $(BACNET_HANDLER)/s_uevent.c \ $(BACNET_HANDLER)/s_whohas.c \ $(BACNET_HANDLER)/s_whois.c \ @@ -183,20 +194,13 @@ ifdef BACDL_ALL PORT_SRC = ${PORT_ALL_SRC} endif - -ifneq (,$(findstring -DBAC_ROUTING,$(BACNET_DEFINES))) -ROUTING_SRC = \ - $(BACNET_HANDLER)/h_routed_npdu.c \ - $(BACNET_HANDLER)/s_router.c \ - $(BACNET_OBJECT)/gw_device.c -else -ROUTING_SRC = -endif - -SRCS = ${CORE_SRC} ${PORT_SRC} ${HANDLER_SRC} ${OBJECT_SRC} ${ROUTING_SRC} +SRCS = ${CORE_SRC} ${PORT_SRC} ${HANDLER_SRC} ${OBJECT_SRC} OBJS = ${SRCS:.c=.o} +# use local includes, but other values from calling Makefile +CFLAGS = $(WARNINGS) $(DEBUGGING) $(OPTIMIZATION) $(STANDARDS) $(INCLUDES) $(DEFINES) + all: $(LIBRARY) lib: $(LIBRARY)