Coder Social home page Coder Social logo

Comments (4)

aostruszka avatar aostruszka commented on May 20, 2024

Could you take a look at Rules.mk of example 2 in repository?
I think this answers your problem - just take a look at directory structure of this example and what it's Rules.mk is trying to achieve.

Best regards
Andrzej

from nonrec-make.

torpesco avatar torpesco commented on May 20, 2024

Hmm. Yes, using $(call subtree_tgts,$(d)/b2) from a/Rules.mk seems to work. However, that seems even less intuitive to me, so I think I'll stick with what I got. My goal is to keep the Rules.mk files as clean-looking and hopefully as easy to understand as possible.

Thanks,
James

from nonrec-make.

aostruszka avatar aostruszka commented on May 20, 2024

I'm not sure I fully understand your need. My guess that in 'a' you want to have a library with all object files from 'a' and all its subdirectories (recursively) - then in a/Rules.mk I would simply put (I'm guessing that .o extension in your example is not intentional and you wanted to collect all objects into archive):

SUBDIRS = b1 b2 b3
# Just in case there are *.c in 'a'
SRCS := *.c
LIB_A := $(OBJPATH)/liba.a
$(LIB_A)_DEPS = $(call get_subtree,OBJS,$(d))
TARGETS := $(LIB_A)

Then all Rules.mk under 'a' could be simple SRCS = *.c with additional SUBDIRS in case of a/b2/Rules.mk. I would say that this is even more readable since you can nearly read _DEPS line in English but they say that "beauty is in the eye of beholder" so you may very well disagree :).

from nonrec-make.

torpesco avatar torpesco commented on May 20, 2024

Finally catching up on this after a gap of a few months. :-\

Regarding the library vs. object thing... This is an old codebase, and I'm trying to drop in nonrec-make as transparently as possible. Yes, it actually is liba.o. In this case, the files in each subdirectory were built into b1.o, b2.o (containing c1.o and c2.o) and b3.o, and the b*.o files were combined into liba.o. Out of those, my structure got rid of all but b2.o.

The $(LIB_A)_DEPS = $(call get_subtree,OBJS,$(d)) works nicely, and I think I've convinced myself the extra perceived complexity is fine (calling get_subtree once rather than the three times I thought I'd have to), so I've switched to that for now. I agree with you about it being more readable... I'm just trying to think about what problems I'll encounter when people without a good understanding of Make have to add or modify a Rules.mk file.

Thanks.

from nonrec-make.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.