WARNING: This server is unstable and will be retired in the next days. If you want to keep this forum available, please request immediately a migration on the Nabble Support forum. Forums that don't receive any migration request will be deleted forever.

 « Return to Thread: Need a make guru; embedding web pages

Re: Need a make guru; embedding web pages

by Rick Mann :: Rate this Message:

| View in Thread

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, dkelly@...
> ========================================================================
> Whom computers would destroy, they must first drive mad.
>
>
>


_______________________________________________
AVR-chat mailing list
AVR-chat@...
https://lists.nongnu.org/mailman/listinfo/avr-chat

 « Return to Thread: Need a make guru; embedding web pages