date coding executables

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi

when I run make (external makefile) in avr studio i want the target to have the date in the filename, so i get something like targetname04072007.hex
I know there is a windows environment variable called %date%, but how to incorporate it into gnu makefile?
Does anyone know if this can be done?
thanks in advance for any help

rob carter

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I just have something like this in the .c source:

const uint8_t help[] PROGMEM = { 
"Program version "__DATE__" "__TIME__"\r\n\n\
1 - toggle LED1\r\n\
2 - toggle LED2\r\n\
3 - toggle LED3\r\n\

Then when I display this help menu it has the date/time embedded and in the hex/binary I also have it embedded:

:1000F0006865723E200050726F6772616D20766590
:100100007273696F6E204D61722020322032303060
:10011000372031353A31373A35340D0A0A31202D3E
etc...

(one thing I did do in the makefile was have it always 'touch' the .c file that this __DATE__ and __TIME__ is included in to ensure that file was always recompiled and a new date/time version embedded)

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In *nix systems, environment variables can be directly referenced in makefiles, so you can easily construct a name if you have an environment variable that already has a correctly formatted piece of the name that you want. I presume that it is the same for gnu make in Windows, but I only boot Windows once every 6 weeks or so, and never to development there any more, so I'll have to point you at the make documentation.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

robcarter wrote:
when I run make (external makefile) in avr studio i want the target to have the date in the filename, so i get something like targetname04072007.hex
I know there is a windows environment variable called %date%, but how to incorporate it into gnu makefile?
Does anyone know if this can be done?
If make regards date as an environment variable,
you can use targetname$(date).hex as your file name.
If not, do something like this first:
date=$(shell date_emitter)

BTW when I want the link time in the executable,
my link sequence recompiles a file named linktime.c
before invoking avr-gcc to link.
That way, I get a fresh copy of linktime.o
without making linktime.c artificially newer.

Iluvatar is the better part of Valar.