From 15d1603639ed73ae7bf849f3fabf60a0ba63090b Mon Sep 17 00:00:00 2001 From: Yakun Xu Date: Wed, 30 Jan 2019 00:54:09 +0800 Subject: [PATCH] [build] clean up switches for POSIX platform (#3517) --- examples/Makefile-posix | 106 +++++++++++++++++--------------- examples/common-switches.mk | 12 ++-- src/posix/Makefile-posix | 116 +++++++++++++++++------------------- 3 files changed, 121 insertions(+), 113 deletions(-) diff --git a/examples/Makefile-posix b/examples/Makefile-posix index f7aad647c..74e940e4b 100644 --- a/examples/Makefile-posix +++ b/examples/Makefile-posix @@ -33,61 +33,56 @@ COVERAGE ?= 0 DEBUG ?= 0 -ECHO := @echo -MAKE := make -MKDIR_P := mkdir -p -LN_S := ln -s -RM_F := rm -f +# Enable most features by default to cover most code -BuildJobs ?= 10 +BORDER_AGENT ?= 1 +BORDER_ROUTER ?= 1 +CERT_LOG ?= 1 +COAP ?= 1 +COAPS ?= 1 +COMMISSIONER ?= 1 +CHANNEL_MANAGER ?= 1 +CHANNEL_MONITOR ?= 1 +CHILD_SUPERVISION ?= 1 +DHCP6_CLIENT ?= 1 +DHCP6_SERVER ?= 1 +DIAGNOSTIC ?= 1 +DNS_CLIENT ?= 1 +ECDSA ?= 1 +JAM_DETECTION ?= 1 +JOINER ?= 1 +LEGACY ?= 1 +LINK_RAW ?= 1 +MAC_FILTER ?= 1 +MTD_NETDIAG ?= 1 +SERVICE ?= 1 +SNTP_CLIENT ?= 1 +UDP_FORWARD ?= 1 + +COMMONCFLAGS := \ + $(NULL) # If the user has asserted COVERAGE, alter the configuration options # accordingly. -configure_OPTIONS = \ - --enable-application-coap \ - --enable-application-coap-secure \ - --enable-border-agent \ - --enable-border-router \ - --enable-cert-log \ - --enable-child-supervision \ - --enable-cli \ - --enable-commissioner \ - --enable-dhcp6-client \ - --enable-dhcp6-server \ - --enable-diag \ - --enable-dns-client \ - --enable-ftd \ - --enable-jam-detection \ - --enable-joiner \ - --enable-legacy \ - --enable-mac-filter \ - --enable-mtd \ - --enable-mtd-network-diagnostic \ - --enable-ncp \ - --with-ncp-bus=uart \ - --enable-radio-only \ - --enable-raw-link-api \ - --enable-service \ - --enable-sntp-client \ - --enable-udp-forward \ - --with-examples=posix \ +configure_OPTIONS = \ + --enable-cli \ + --enable-ftd \ + --enable-mtd \ + --enable-ncp \ + --enable-radio-only \ + --with-examples=posix \ + --with-ncp-bus=uart \ $(NULL) -TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST)))).. -AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST)))).. +# Platform specific switches -CONFIG_FILE = OPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-posix-config.h\"' -CONFIG_FILE_PATH = $(AbsTopSourceDir)/examples/platforms/posix/ - -COMMONCFLAGS := \ - -O1 \ +ifneq ($(DEBUG),1) +COMMONCFLAGS += \ + -O2 \ -g \ - -D$(CONFIG_FILE) \ - -I$(CONFIG_FILE_PATH) \ $(NULL) - -include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk +endif ifeq ($(VIRTUAL_TIME),1) COMMONCFLAGS += -DOPENTHREAD_POSIX_VIRTUAL_TIME=1 @@ -97,6 +92,17 @@ ifeq ($(VIRTUAL_TIME_UART),1) COMMONCFLAGS += -DOPENTHREAD_POSIX_VIRTUAL_TIME_UART=1 endif +include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk + +TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST)))).. +AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST)))).. + +CONFIG_FILE = OPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-posix-config.h\"' +CONFIG_FILE_PATH = $(AbsTopSourceDir)/examples/platforms/posix/ +COMMONCFLAGS += \ + -D$(CONFIG_FILE) \ + -I$(CONFIG_FILE_PATH) \ + CPPFLAGS += \ $(COMMONCFLAGS) \ $(NULL) @@ -113,9 +119,15 @@ LDFLAGS += \ $(COMMONCFLAGS) \ $(NULL) -INSTALL := /usr/bin/install -INSTALLFLAGS := -p +ECHO := @echo +INSTALL := /usr/bin/install +INSTALLFLAGS := -p +LN_S := ln -s +MAKE := make +MKDIR_P := mkdir -p +RM_F := rm -f +BuildJobs ?= 10 BuildPath = build TopBuildDir = $(BuildPath) AbsTopBuildDir = $(PWD)/$(TopBuildDir) diff --git a/examples/common-switches.mk b/examples/common-switches.mk index 41c4d1bb4..fb680f932 100644 --- a/examples/common-switches.mk +++ b/examples/common-switches.mk @@ -68,7 +68,7 @@ configure_OPTIONS += --enable-child-supervision endif ifeq ($(DEBUG),1) -configure_OPTIONS += --enable-debug --enable-optimization=no +configure_OPTIONS += --enable-debug --disable-optimization endif ifeq ($(DHCP6_CLIENT),1) @@ -79,6 +79,10 @@ ifeq ($(DHCP6_SERVER),1) configure_OPTIONS += --enable-dhcp6-server endif +ifeq ($(DIAGNOSTIC),1) +configure_OPTIONS += --enable-diag +endif + ifeq ($(DISABLE_DOC),1) configure_OPTIONS += --disable-docs endif @@ -115,7 +119,7 @@ ifeq ($(MTD_NETDIAG),1) configure_OPTIONS += --enable-mtd-network-diagnostic endif -ifeq ($(PLATFORM_UDP), 1) +ifeq ($(PLATFORM_UDP),1) configure_OPTIONS += --enable-platform-udp endif @@ -131,11 +135,11 @@ ifeq ($(UDP_FORWARD),1) configure_OPTIONS += --enable-udp-forward endif -ifeq ($(DISABLE_BUILTIN_MBEDTLS), 1) +ifeq ($(DISABLE_BUILTIN_MBEDTLS),1) configure_OPTIONS += --disable-builtin-mbedtls endif -ifeq ($(DISABLE_EXECUTABLE), 1) +ifeq ($(DISABLE_EXECUTABLE),1) configure_OPTIONS += --enable-executable=no endif diff --git a/src/posix/Makefile-posix b/src/posix/Makefile-posix index 3b102c620..bf439166f 100644 --- a/src/posix/Makefile-posix +++ b/src/posix/Makefile-posix @@ -30,91 +30,68 @@ .NOTPARALLEL: -COVERAGE ?= 0 -DEBUG ?= 0 -DISABLE_BUILTIN_MBEDTLS ?= 0 -DISABLE_EXECUTABLE ?= 0 -SNTP_CLIENT ?= 0 +COVERAGE ?= 0 +DEBUG ?= 0 -ECHO := @echo -MAKE := make -MKDIR_P := mkdir -p -LN_S := ln -s -RM_F := rm -f +# Enable most features by default to cover most code -BuildJobs ?= 10 +BORDER_AGENT ?= 1 +BORDER_ROUTER ?= 1 +CERT_LOG ?= 1 +COAP ?= 1 +COAPS ?= 1 +COMMISSIONER ?= 1 +CHANNEL_MANAGER ?= 1 +CHANNEL_MONITOR ?= 1 +CHILD_SUPERVISION ?= 1 +DHCP6_CLIENT ?= 1 +DHCP6_SERVER ?= 1 +DIAGNOSTIC ?= 1 +DNS_CLIENT ?= 1 +ECDSA ?= 1 +JAM_DETECTION ?= 1 +JOINER ?= 1 +LEGACY ?= 1 +LINK_RAW ?= 0 +MAC_FILTER ?= 1 +MTD_NETDIAG ?= 1 +SERVICE ?= 1 +SNTP_CLIENT ?= 1 +UDP_FORWARD ?= 1 + +COMMONCFLAGS := \ + -DOPENTHREAD_CONFIG_UART_CLI_RAW=1 \ + $(NULL) # If the user has asserted COVERAGE, alter the configuration options # accordingly. configure_OPTIONS = \ - --enable-application-coap \ - --enable-application-coap-secure \ - --enable-border-agent \ - --enable-border-router \ - --enable-cert-log \ - --enable-child-supervision \ --enable-cli \ - --enable-commissioner \ - --enable-dhcp6-client \ - --enable-dhcp6-server \ - --enable-diag \ - --enable-dns-client \ --enable-ftd \ - --enable-jam-detection \ - --enable-joiner \ --enable-ncp \ - --enable-legacy \ - --enable-mac-filter \ --enable-posix-app \ - --enable-service \ - --enable-udp-forward \ --with-ncp-bus=uart \ $(NULL) -ifeq ($(COVERAGE),1) -configure_OPTIONS += --enable-coverage -endif +# Platform specific switches -ifeq ($(DISABLE_BUILTIN_MBEDTLS), 1) -configure_OPTIONS += --disable-builtin-mbedtls -endif - -ifeq ($(DISABLE_EXECUTABLE), 1) -configure_OPTIONS += --enable-executable=no +ifneq ($(DEBUG),1) +COMMONCFLAGS += \ + -O2 \ + -g \ + $(NULL) endif ifeq ($(PLATFORM_NETIF),1) configure_OPTIONS += --enable-platform-netif endif -ifeq (${SNTP_CLIENT}, 1) -configure_OPTIONS += --enable-sntp-client -endif - -TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))../.. -AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))../.. - -CONFIG_FILE = OPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-posix-config.h\"' -CONFIG_FILE_PATH = $(AbsTopSourceDir)/src/posix/platform - -COMMONCFLAGS := \ - -O2 \ - -g \ - -D$(CONFIG_FILE) \ - -I$(CONFIG_FILE_PATH) \ - -DOPENTHREAD_CONFIG_UART_CLI_RAW=1 \ - $(NULL) - ifeq ($(VIRTUAL_TIME),1) COMMONCFLAGS += -DOPENTHREAD_POSIX_VIRTUAL_TIME=1 endif -ifeq ($(PLATFORM_UDP),1) -configure_OPTIONS += \ - --enable-platform-udp \ - $(NULL) -endif +include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/../../examples/common-switches.mk CPPFLAGS += \ $(COMMONCFLAGS) \ @@ -132,9 +109,24 @@ LDFLAGS += \ $(COMMONCFLAGS) \ $(NULL) -INSTALL := /usr/bin/install -INSTALLFLAGS := -p +TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))../.. +AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))../.. +CONFIG_FILE = OPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-posix-config.h\"' +CONFIG_FILE_PATH = $(AbsTopSourceDir)/src/posix/platform +COMMONCFLAGS += \ + -D$(CONFIG_FILE) \ + -I$(CONFIG_FILE_PATH) \ + +ECHO := @echo +INSTALL := /usr/bin/install +INSTALLFLAGS := -p +LN_S := ln -s +MAKE := make +MKDIR_P := mkdir -p +RM_F := rm -f + +BuildJobs ?= 10 BuildPath = build/posix TopBuildDir = $(BuildPath) AbsTopBuildDir = $(PWD)/$(TopBuildDir)