On Tue, 31 Jul 2001, Kelly Morrison wrote:
> 1. Create a little shell script called "buildtime" that contains the
> following lines:
> --------------------- snip here -----------------------------
> export HDR=buildtime.h
> set `date`
> rm -f $HDR
> echo "#ifndef BUILD_TIME_H" > $HDR
> echo "#define BUILD_TIME_H" >> $HDR
> echo "#define BUILD_TIME \""$1 $2 $3 $4 $5"\"" >> $HDR
> echo "#endif // BUILD_TIME_H" >> $HDR
> -------------------- snip here ------------------------------
> Save this shell script in the same directory as your Makefile. When
> executed, this shell script will create a C header file called "buildtime.h"
> that has the build time info in it. Now, we just need to tell the Makefile
> to run it each time you compile...
> 2. Add the following lines to your Makefile.
> -------------------- snip here -----------------------------
> time:
>         ./buildtime
> -------------------- snip here -----------------------------
>    This adds a target called "time" that will run the shell script we
> created in step 1.
> 3. Tell the Makefile to run the shell script whenever you build your Palm
> app. You can do this by just adding the "time" target in the following place
> in your Makefile.
> ------------------------- snip  here --------------------------
> $(PRC):   time grc.stamp bin.stamp;
>         $(BUILDPRC) $(PRC) $(ICONTEXT) $(APPID) *.grc *.bin $(LINKFILES)
>         ls -l *.prc
> ------------------------- snip here ----------------------------
> 4. The last thing you have to do to your Makefile is to tell which of your
> source files depends on the header file. E.g., I use the build info in my
> splash screen (in SplashScreen.c), so I add the following line to the
> Makefile:
> -------------------------- snip here ---------------------------
> SplashScreen.o: time
> -------------------------- snip here ---------------------------
> 5. That's all! Now, just include the buildtime.h file in your program and
> use the BUILD_TIME string to display the build info however you'd like. For
> example, I use the following:
> --------------------------- snip here --------------------------
> #include "buildtime.h"
> ...
> WinPaintChars("Build Info:", 11, 2, 140);
> WinPaintChars(BUILD_TIME, StrLen(BUILD_TIME), 2, 150);
> ---------------------------- snip here --------------------------
> which paints the following lines on my splash screen.
>    Build Info:
>    Tue Jul 31 17:42:30 2001

  thats an aweful load of work for something so small :)

  a few points: - 1. WinPaintChars() -> os 3.5+ only if i recall right
                - 2. why not just use pilrc to do all this?

    VERSION "..."  <-- this is what you have now

  change it to this:

    DATA "tver" ID 0 "time.stamp"

  add time.stamp as a dependancy for the .prc, and, when done
  building, remove the time.stamp file. add the following:

    time.stamp:
      date +%y%m%d-%H%M%S > time.stamp

  done.. 

  now, when someone goes to the os "version" page, it will show the date.
  you could extend this idea to do whatever you want, even store it as
  a string in the .rcp file for reading (instead of using the .h file)

  oh.. the joy of makefiles :)

// az
[EMAIL PROTECTED]
http://www.ardiri.com/


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to