avr-chat
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-chat] Need a make guru; embedding web pages


From: Rick Mann
Subject: Re: [avr-chat] Need a make guru; embedding web pages
Date: Wed, 31 Aug 2011 19:06:14 -0700

On Aug 30, 2011, at 12:41 , David Kelly wrote:

> I think I'd put the WebFileTOC in a .c and define an empty extern
> WebFileTOC in the .h. You really don't want memory allocation occurring
> in a .h as you show above.

I agree, and would like to eventually incorporate that change.

> Then in your Makefile add a pattern rule:
> 
> %.html : %.o
>       avr-objcopy -B elf $< $@
> 
> Perhaps rename your files to index_html.html, error_html.html, and
> main_css.html so as to get something close to the names you have used
> above.

I guess I wasn't clear enough. I actually have a rule like that, and the file 
you see was actually generated by my Makefile. The problem is that it doesn't 
properly handle the dependencies. I want a change in a .html to result in the 
web.h being re-built, and then any code that includes web.h being recompiled. 

Maybe I just need to ensure that these rules are the first to execute in the 
Makefile?

> Put index_html.o, error_html.o, and main_css.o in your list of objects
> to link and that should be it.

One of the things I'm trying to avoid is to have to specify the .o files. My 
make rules allow me to specify the source files, and the lists of corresponding 
.o get built automatically.

Unfortunately, I've had a number weird issues, not the least of which is that 
sometimes I've seen the .html replaced by what should've gone into the .o (I 
don't know what steps are required to reproduce this).

Here's a set of rules (I left out some of the CSS and PNG rules for brevity):

WEBHEADER = web.h

HTML = $(WEB)/index.html \
                $(WEB)/error.html

HTMLOBJS = $(HTML:.html=.html.o)

OTHEROBJS = $(HTMLOBJS) $(CSSOBJS) $(PNGOBJS)

$(HTMLOBJS) : %.html.o : %.html
        @echo "Converting $< [$(subst /,_,$*)]"
        $(CP) -I binary -O elf32-littlearm \
                --redefine-sym _binary_$(subst .,_,$(subst 
/,_,$<))_start=$(subst .,_,$(<F)) \
                --redefine-sym _binary_$(subst .,_,$(subst /,_,$<))_end=$(subst 
.,_,$(<F))_end \
                --redefine-sym _binary_$(subst .,_,$(subst 
/,_,$<))_size=$(subst .,_,$(<F))_size \
                $< $@

$(WEBHEADER) : $(HTML) $(CSS) $(PNG) #$(HTMLOBJS) $(CSSOBJS) $(PNGOBJS)
        for f in $(^F); do \
                ff=$${f/./_}; \
                echo "extern const char" $${ff}"[];" >> $(WEBHEADER); \
                echo "extern const char" $${ff}_end"[];" >> $(WEBHEADER); \
        done; \
        echo "WebFileTOC sWebTOC = {" >> $(WEBHEADER); \
        for f in $(^F); do \
                ff=$${f/./_}; \
                echo "{ \"$${f}\", $${ff}, $${ff}_end }," >> $(WEBHEADER); \
        done; \
        echo "};\n" >> $(WEBHEADER);
        




reply via email to

[Prev in Thread] Current Thread [Next in Thread]