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: Thu, 1 Sep 2011 17:28:50 -0700

I think one problem is that when the dependency analysis runs, it fails to 
compile the file that includes "web.h", because that file doesn't exist. So, no 
dependency on web.h ever gets created, so web.h never gets created.

I added $(WEBHEADER) to the $(CPPOBJS) rule, but now I get

        make: Circular web/index.html.o <- web/index.html dependency dropped.

I don't see the circular dependency, but it must be there.

I've made a simpler test Makefile: http://pastebin.com/SWmS2716

src/Test.cpp contains nothing but:

        #include "web.h"

web/index.html contains nothing but:

        <html></html>


-- 
Rick

On Aug 31, 2011, at 20:58 , David Kelly wrote:

> 
> On Aug 31, 2011, at 9:06 PM, Rick Mann wrote:
> 
>> 
>> 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.
> 
> Its a small change. Just split your (WEBHEADER) target in two like this:
> 
> WEBHEADER = web.h
> WEB_C     = web.c
> 
> $(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 "extern const WebFileTOC sWebTOC; >> $(WEBHEADER);
> 
> $(WEB_C) : $(HTML) $(CSS) $(PNG)
>       echo "#include \"$(WEBHEADER)\"\n" >> $(WEB_C); \
>       echo "WebFileTOC sWebTOC = {" >> $(WEB_C); \
>       for f in $(^F); do \
>               ff=$${f/./_}; \
>               echo "{ \"$${f}\", $${ff}, $${ff}_end }," >> $(WEB_C); \
>       done; \
>       echo "};\n" >> $(WEB_C);
> 
>>> 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?
> 
> Order shouldn't matter to anything but determination of the default target. 
> You don't show your default target but web.h has to be listed as a build 
> dependency.
> 
> Once again I think you need a web.c to hold the memory allocation. Add it to 
> your .c source list so that it will be built. Also add this so that make 
> knows web.o depends on web.h:
> 
> web.o : web.c web.h
> 
> You need similar for anything that uses web.h because they too need to be 
> rebuilt if web.h changes. You might let the compiler build a dependency tree 
> for you in Makefile format. I used this in one of my AVR projects. IIRC it 
> was copied from another project I was doing in FreeBSD where one has BSD make 
> and sometimes GNU make, which differ in how this is handled. Believe this 
> almost finds common ground:
> 
> depend: clean $(SRCS)
>        $(CC) -E -M $(SRCS) > .depend
> 
> # BSD make automatically reads .depend if it exists, but GNU needs to be told.
> # -include fails silently in GNU Make if .depend does not exist
> # -include is not BSD Make compatible and will fail fatally. Comment out, not 
> needed.
> -include .depend
> 
> The .depend file produced lists *all* dependancies tracking every #include 
> recursively through your system to the very end.
> 
> --
> David Kelly N4HHE, address@hidden
> ========================================================================
> Whom computers would destroy, they must first drive mad.
> 
> 
> 




reply via email to

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