Sming - Open Source framework for high efficiency native ESP8266 development

User avatar
By piperpilot
#30266 Hey make experts,

I'm trying to extend the standard Sming makefile without modifying it. My thought is I would like to add some "stuff" to the makefile-user.mk and have it picked up. In particular, I'm trying to add an application version. I can easily add a variable:

VERSION = 1.0.18

Now I want two things to happen.

1. I would like to add that version to the compiler flags so it gets passed to my application
Code: Select all-DVERSION=$(VERSION)


2. I would like to write out a text file in the out/firmware directory so that I can upload it to my webserver for OTA update checking.
Code: Select allversion:
   $(vecho) "Setting Version $(VERSION)"
   echo "$(VERSION)" > $(FW_BASE)/version.txt


Is there any way for me to extend makefile-user to do this without editing the makefile in Sming core?

thanks,
Curtis
aka Piperpilot
User avatar
By piperpilot
#30278 OK, I'll answer my own question here...looks like it will require a minor change to SmingCore makefiles.

First off, if we change the CFLAGS def from:

Code: Select allCFLAGS      = -Os -g -Wpointer-arith -Wundef -Werror ...(more stuff)


to

Code: Select allCFLAGS      += -Os -g -Wpointer-arith -Wundef -Werror ...(more stuff)


It will allow appending user defined CFLAGS in the Makefile-user. I also added a make target to Makefile-user and then updated my "all" target to be "all version"

Code: Select allVERSION = 1.0.19
SMOBOTVERSION = \"$(VERSION)\"

version:
   $(vecho) "Setting SmoBoT Version $(VERSION)"
   echo "$(VERSION)" > $(FW_BASE)/version.txt   

CFLAGS      += -DSMOBOTVERSION=$(SMOBOTVERSION)


Seems to all work fine. I'll open an issue and make a simple PR for the makefile change to allow appending.