Skip to content

Commit

Permalink
Dev make cleanup (nodemcu#2842)
Browse files Browse the repository at this point in the history
  • Loading branch information
TerryE authored Jul 23, 2019
1 parent f7a545b commit 98c2c05
Show file tree
Hide file tree
Showing 56 changed files with 135 additions and 286 deletions.
130 changes: 65 additions & 65 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ else
endif
SDK_REL_DIR := sdk/esp_iot_sdk_v$(SDK_VER)
SDK_DIR := $(TOP_DIR)/$(SDK_REL_DIR)
APP_DIR := $(TOP_DIR)/app

ESPTOOL_VER := 2.6

# Ensure that the Espresif SDK is searched before the tool-chain's SDK (if any)
# Also, prevent the SDK's c_types.h from being included from anywhere, by
# predefining its include-guard.
CCFLAGS:= -I$(TOP_DIR)/sdk-overrides/include -I$(TOP_DIR)/app/include/lwip/app -I$(SDK_DIR)/include -D_C_TYPES_H_
LDFLAGS:= -L$(SDK_DIR)/lib -L$(SDK_DIR)/ld $(LDFLAGS)
# Ensure that the Espresif SDK is search before application paths and also prevent
# the SDK's c_types.h from being included from anywhere, by predefining its include-guard.

CCFLAGS := $(CCFLAGS) -I $(PDIR)sdk-overrides/include -I $(SDK_DIR)/include -D_C_TYPES_H_
LDFLAGS := -L$(SDK_DIR)/lib -L$(SDK_DIR)/ld $(LDFLAGS)

ifdef DEBUG
CCFLAGS += -ggdb -O0
Expand All @@ -61,26 +62,26 @@ else
endif # $(V)==1

ifndef BAUDRATE
BAUDRATE=115200
BAUDRATE=115200
endif

#############################################################
# Select compile
#
# ** HEALTH WARNING ** This section is largely legacy directives left over from
# ** HEALTH WARNING ** This section is largely legacy directives left over from
# an Espressif template. As far as I (TerrryE) know, we've only used the Linux
# Path. I have successfully build AMD and Intel (both x86, AMD64) and RPi ARM6
# all under Ubuntu. Our docker container runs on Windows in an Ubuntu VM.
# Johny Mattson maintains a prebuild AMD64 xtensa cross-compile gcc v4.8.5
# toolchain which is compatible with the non-OS SDK and can be used on any recent
# toolchain which is compatible with the non-OS SDK and can be used on any recent
# Ubuntu version including the Docker and Travis build environments.
#
# You have the option to build your own toolchain and specify a TOOLCHAIN_ROOT
# environment variable (see https://github.com/pfalcon/esp-open-sdk). If your
# architecture is compatable then you can omit this variable and the make will
# download and use this prebuilt toolchain.
#
# If any developers wish to develop, test and support alternative environments
# If any developers wish to develop, test and support alternative environments
# then please raise a GitHub issue on this work.
#

Expand All @@ -95,39 +96,39 @@ endif

ifneq (,$(findstring indows,$(OS)))
#------------ BEGIN UNTESTED ------------ We are not under Linux, e.g.under windows.
ifeq ($(XTENSA_CORE),lx106)
# It is xcc
AR = xt-ar
CC = xt-xcc
CXX = xt-xcc
NM = xt-nm
CPP = xt-cpp
OBJCOPY = xt-objcopy
#MAKE = xt-make
CCFLAGS += --rename-section .text=.irom0.text --rename-section .literal=.irom0.literal
else
# It is gcc, may be cygwin
# Can we use -fdata-sections?
CCFLAGS += -ffunction-sections -fno-jump-tables -fdata-sections
AR = xtensa-lx106-elf-ar
CC = xtensa-lx106-elf-gcc
CXX = xtensa-lx106-elf-g++
NM = xtensa-lx106-elf-nm
CPP = xtensa-lx106-elf-cpp
OBJCOPY = xtensa-lx106-elf-objcopy
endif
FIRMWAREDIR = ..\\bin\\
ifndef COMPORT
ESPPORT = com1
else
ESPPORT = $(COMPORT)
endif
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
ifeq ($(XTENSA_CORE),lx106)
# It is xcc
AR = xt-ar
CC = xt-xcc
CXX = xt-xcc
NM = xt-nm
CPP = xt-cpp
OBJCOPY = xt-objcopy
#MAKE = xt-make
CCFLAGS += --rename-section .text=.irom0.text --rename-section .literal=.irom0.literal
else
# It is gcc, may be cygwin
# Can we use -fdata-sections?
CCFLAGS += -ffunction-sections -fno-jump-tables -fdata-sections
AR = xtensa-lx106-elf-ar
CC = xtensa-lx106-elf-gcc
CXX = xtensa-lx106-elf-g++
NM = xtensa-lx106-elf-nm
CPP = xtensa-lx106-elf-cpp
OBJCOPY = xtensa-lx106-elf-objcopy
endif
FIRMWAREDIR = ..\\bin\\
ifndef COMPORT
ESPPORT = com1
else
ESPPORT = $(COMPORT)
endif
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
# ->AMD64
endif
ifeq ($(PROCESSOR_ARCHITECTURE),x86)
endif
ifeq ($(PROCESSOR_ARCHITECTURE),x86)
# ->IA32
endif
endif
#---------------- END UNTESTED ---------------- We are under windows.
else
# We are under other system, may be Linux. Assume using gcc.
Expand All @@ -141,23 +142,23 @@ else
TOOLCHAIN_ROOT = $(TOP_DIR)/tools/toolchains/esp8266-$(GCCTOOLCHAIN)
GITHUB_TOOLCHAIN = https://github.com/jmattsson/esp-toolchains
export PATH:=$(PATH):$(TOOLCHAIN_ROOT)/bin
endif
endif
ifndef COMPORT
ESPPORT = /dev/ttyUSB0
else
ESPPORT = $(COMPORT)
endif

CCFLAGS += -ffunction-sections -fno-jump-tables -fdata-sections
AR = xtensa-lx106-elf-ar
CC = $(WRAPCC) xtensa-lx106-elf-gcc
CXX = $(WRAPCC) xtensa-lx106-elf-g++
NM = xtensa-lx106-elf-nm
CPP = $(WRAPCC) xtensa-lx106-elf-gcc -E
OBJCOPY = xtensa-lx106-elf-objcopy
FIRMWAREDIR = ../bin/
endif
endif

ifndef COMPORT
ESPPORT = /dev/ttyUSB0
else
ESPPORT = $(COMPORT)
endif

CCFLAGS += -ffunction-sections -fno-jump-tables -fdata-sections
AR = xtensa-lx106-elf-ar
CC = $(WRAPCC) xtensa-lx106-elf-gcc
CXX = $(WRAPCC) xtensa-lx106-elf-g++
NM = xtensa-lx106-elf-nm
CPP = $(WRAPCC) xtensa-lx106-elf-gcc -E
OBJCOPY = xtensa-lx106-elf-objcopy
FIRMWAREDIR = ../bin/
WGET = wget --tries=10 --timeout=15 --waitretry=30 --read-timeout=20 --retry-connrefused
endif

Expand Down Expand Up @@ -221,7 +222,7 @@ CCFLAGS += \
-fno-inline-functions \
-nostdlib \
-mlongcalls \
-mtext-section-literals
-mtext-section-literals \
# -Wall

CFLAGS = $(CCFLAGS) $(DEFINES) $(EXTRA_CCFLAGS) $(STD_CFLAGS) $(INCLUDES)
Expand Down Expand Up @@ -370,7 +371,7 @@ flash1m-dout:

flashinternal:
ifndef PDIR
$(MAKE) -C ./app flashinternal
$(MAKE) -C $(APP_DIR) flashinternal
else
$(ESPTOOL) --port $(ESPPORT) --baud $(BAUDRATE) write_flash $(FLASHOPTIONS) 0x00000 $(FIRMWAREDIR)0x00000.bin 0x10000 $(FIRMWAREDIR)0x10000.bin
endif
Expand All @@ -395,20 +396,20 @@ spiffs-image-remove:

spiffs-image: bin/0x10000.bin
$(MAKE) -C tools

############ Note: this target needs moving into app/modules make ############
.PHONY: pre_build

ifneq ($(wildcard $(TOP_DIR)/server-ca.crt),)
pre_build: $(TOP_DIR)/app/modules/server-ca.crt.h
pre_build: $(APP_DIR)/modules/server-ca.crt.h

$(TOP_DIR)/app/modules/server-ca.crt.h: $(TOP_DIR)/server-ca.crt
$(APP_DIR)/modules/server-ca.crt.h: $(TOP_DIR)/server-ca.crt
$(summary) MKCERT $(patsubst $(TOP_DIR)/%,%,$<)
python $(TOP_DIR)/tools/make_server_cert.py $(TOP_DIR)/server-ca.crt > $(TOP_DIR)/app/modules/server-ca.crt.h
python $(TOP_DIR)/tools/make_server_cert.py $(TOP_DIR)/server-ca.crt > $(APP_DIR)/modules/server-ca.crt.h

DEFINES += -DHAVE_SSL_SERVER_CRT=\"server-ca.crt.h\"
else
pre_build:
@-rm -f $(TOP_DIR)/app/modules/server-ca.crt.h
@-rm -f $(APP_DIR)/modules/server-ca.crt.h
endif

ifdef TARGET
Expand Down Expand Up @@ -484,6 +485,5 @@ endif # TARGET
# Required for each makefile to inherit from the parent
#

INCLUDES := $(INCLUDES) -I $(PDIR)include -I $(PDIR)include/$(TARGET)
PDIR := ../$(PDIR)
sinclude $(PDIR)Makefile
55 changes: 20 additions & 35 deletions app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ TARGET = eagle
#FLAVOR = release
FLAVOR = debug

#EXTRA_CCFLAGS += -u

ifndef PDIR # {
GEN_IMAGES= eagle.app.v6.out
GEN_BINS= eagle.app.v6.bin
Expand All @@ -42,10 +40,10 @@ SUBDIRS= \
smart \
modules \
spiffs \
net \
net \
fatfs \
esp-gdbstub \
pm \
pm \
uzlib \
$(OPT_SEL_MKTARGETS)

Expand All @@ -54,36 +52,35 @@ endif # } PDIR
APPDIR = .
LDDIR = ../ld

TARGET_LDFLAGS = \
TARGET_LDFLAGS = \
-nostdlib \
-Wl,-EL \
--longcalls \
--longcalls \
--text-section-literals

LD_FILE = $(LDDIR)/nodemcu.ld

COMPONENTS_eagle.app.v6 = \
COMPONENTS_eagle.app.v6 = \
user/libuser.a \
crypto/libcrypto.a \
driver/libdriver.a \
platform/libplatform.a \
platform/libplatform.a \
task/libtask.a \
libc/liblibc.a \
lua/liblua.a \
lwip/liblwip.a \
smart/smart.a \
spiffs/spiffs.a \
fatfs/libfatfs.a \
pm/libpm.a \
esp-gdbstub/libgdbstub.a \
net/libnodemcu_net.a \
mbedtls/libmbedtls.a \
modules/libmodules.a \
pm/libpm.a \
esp-gdbstub/libgdbstub.a \
net/libnodemcu_net.a \
mbedtls/libmbedtls.a \
modules/libmodules.a \
smart/smart.a \
uzlib/libuzlib.a \
$(OPT_SEL_COMPONENTS)


# Inspect the modules library and work out which modules need to be linked.
# For each enabled module, a symbol name of the form XYZ_module_selected is
# returned. At link time those names are declared undefined, so those (and
Expand Down Expand Up @@ -134,27 +131,15 @@ DEPENDS_eagle.app.v6 = \

#UNIVERSAL_TARGET_DEFINES = \
# Other potential configuration flags include:
# -DTXRX_TXBUF_DEBUG
# -DTXRX_RXBUF_DEBUG
# -DWLAN_CONFIG_CCX
CONFIGURATION_DEFINES = -D__ets__ \
-DICACHE_FLASH \
-DLWIP_OPEN_SRC \
-DPBUF_RSV_FOR_WLAN \
-DEBUF_LWIP \
-DUSE_OPTIMIZE_PRINTF \
-DMBEDTLS_USER_CONFIG_FILE=\"user_mbedtls.h\" \
-DMEM_DEFAULT_USE_DRAM

DEFINES += \
$(UNIVERSAL_TARGET_DEFINES) \
$(CONFIGURATION_DEFINES)
CONFIGURATION_DEFINES += -DLWIP_OPEN_SRC

DDEFINES += \
$(UNIVERSAL_TARGET_DEFINES) \
DEFINES += \
$(UNIVERSAL_TARGET_DEFINES) \
$(CONFIGURATION_DEFINES)

DDEFINES += \
$(UNIVERSAL_TARGET_DEFINES) \
$(CONFIGURATION_DEFINES)

#############################################################
# Recursion Magic - Don't touch this!!
Expand All @@ -167,10 +152,10 @@ DDEFINES += \
#
# Required for each makefile to inherit from the parent
#

INCLUDES := $(INCLUDES) -I $(PDIR)include
INCLUDES += -I ./
INCLUDES := -I $(PDIR)libc -I $(PDIR)lua -I $(PDIR)platform \
$(INCLUDES) -I $(PDIR) -I $(PDIR)include
PDIR := ../$(PDIR)

sinclude $(PDIR)Makefile

.PHONY: FORCE
Expand Down
4 changes: 0 additions & 4 deletions app/coap/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ endif
# Required for each makefile to inherit from the parent
#

INCLUDES := $(INCLUDES) -I $(PDIR)include
INCLUDES += -I ./
INCLUDES += -I ../libc
INCLUDES += -I ../lua
PDIR := ../$(PDIR)
sinclude $(PDIR)Makefile

4 changes: 0 additions & 4 deletions app/crypto/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ STD_CFLAGS=-std=gnu11 -Wimplicit
# Required for each makefile to inherit from the parent
#

INCLUDES := $(INCLUDES) -I $(PDIR)include
INCLUDES += -I ./
INCLUDES += -I ../libc
INCLUDES += -I ../platform
PDIR := ../$(PDIR)
sinclude $(PDIR)Makefile

7 changes: 0 additions & 7 deletions app/dht/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ endif
# Required for each makefile to inherit from the parent
#

INCLUDES := $(INCLUDES) -I $(PDIR)include
INCLUDES += -I ./
INCLUDES += -I ./include
INCLUDES += -I ../include
INCLUDES += -I ../../include
INCLUDES += -I ../libc
INCLUDES += -I ../platform
PDIR := ../$(PDIR)
sinclude $(PDIR)Makefile

3 changes: 0 additions & 3 deletions app/driver/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ STD_CFLAGS=-std=gnu11 -Wimplicit
# Required for each makefile to inherit from the parent
#

INCLUDES := $(INCLUDES) -I $(PDIR)include
INCLUDES += -I ./
INCLUDES += -I ../platform
PDIR := ../$(PDIR)
sinclude $(PDIR)Makefile

2 changes: 0 additions & 2 deletions app/esp-gdbstub/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ endif
# Required for each makefile to inherit from the parent
#

INCLUDES += -I $(PDIR)include
INCLUDES += -I ./
INCLUDES += -I ../../include/ets
PDIR := ../$(PDIR)
sinclude $(PDIR)Makefile
Expand Down
5 changes: 0 additions & 5 deletions app/fatfs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ STD_CFLAGS=-std=gnu11 -Wimplicit -imacros $(FATFS_INC_DIR)fatfs_prefix_lib.h
# Required for each makefile to inherit from the parent
#

INCLUDES := $(INCLUDES) -I $(PDIR)include
INCLUDES += -I ./
INCLUDES += -I ../platform
INCLUDES += -I ../libc
INCLUDES += -I ../lua
PDIR := ../$(PDIR)
sinclude $(PDIR)Makefile

Loading

0 comments on commit 98c2c05

Please sign in to comment.