ant instead of make?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
aggieben

Re:ant instead of make?

Post by aggieben »

Answer to question B): Jam is just a ***** to use. It's more automagic than make, but you have to beat it into submission first.

Answer to question A): Ant is a really fabulous tool, but when you step outside the Java world, you start to lose a lot of the fabulousness. You have to be much more explicit about target dependencies, and it generally just doesn't work as well for non-Java projects. I'd like to see a more general-purpose clone of ant, and then I'd be sold.

Ant does support a C++ plugin, but even with that the non-Java support just isn't as good.

I've been through this gauntlet a number of times, and every time I try to come up with something better than make, I end up hating jam, wishing ant was fully functional for non-Java, and viewing scons as a gimp - leading me right back to make. *sigh*.
guest

Re:ant instead of make?

Post by guest »

@Candy: ok, for that you will need to be a little tricky:

./a/Makefile:

Code: Select all

# if build is started here instead of top level, then fill SRCDIR here to be the root directory
SRCDIR ?= $(shell pwd)/..

all2: all3
    @echo '"all2" ran successfully'

include $(SRCDIR)/a/b/Makefile
There is potentially a problem given that all source files must be built using their absolute paths from the root source directory (ie. gcc -c $(SRCDIR)/a/b/file.c -o $(SRCDIR)/a/b/file.o), you may want to consider recursive makefiles instead.
User avatar
Candy
Member
Member
Posts: 3883
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:ant instead of make?

Post by Candy »

guest wrote: @Candy: ok, for that you will need to be a little tricky:

./a/Makefile:

Code: Select all

# if build is started here instead of top level, then fill SRCDIR here to be the root directory
SRCDIR ?= $(shell pwd)/..

all2: all3
    @echo '"all2" ran successfully'

include $(SRCDIR)/a/b/Makefile
There is potentially a problem given that all source files must be built using their absolute paths from the root source directory (ie. gcc -c $(SRCDIR)/a/b/file.c -o $(SRCDIR)/a/b/file.o), you may want to consider recursive makefiles instead.
Now for the $1000000 question:

How do I make it so that you
- Do not use recursive make (make should think first, then act)
- Can use make in any given directory

- And you can move any directory anywhere, adjusting only the parent of the directory (old & new parent).

Why would I want that? I'm trying to figure this out once & for all, if I can get it to work like that I can restructure programs and my whole OS in a jiffy so I don't have to focus really hard on getting it right the first time. In other words, it'll allow me to try a bunch of different setups quickly, move functionality from one place to another, create a master makefile for the entire project or any such thing. Without messing about with the nitty-gritty of figuring out how to make THIS again work, I'd just make it work once, then make that into a personal guideline.

Same with headerfile inclusions. For all my personal projects, I follow a given doctrine which works in all cases. No circular inclusions, no extreme compile times (except for the overly-templatized bits of the code), no compile errors due to inclusions and everything without even requiring further thought. If you can optimize something to 0, do it.
guest

Re:ant instead of make?

Post by guest »

Ok, I think this is what you want, it probably won't look pretty but it should do it:

./Makefile

Code: Select all

SRCDIR := .
SRCDIR_base := $(SRCDIR)

all: all_a all_d all_e
     @echo "All ran successfully"
     @echo $(SRCDIR_base)
     #gcc -c $(SRCDIR_base)/file.c -o $(SRCDIR_base)/file.o

include $(SRCDIR)/a/Makefile
SRCDIR := $(SRCDIR_base)
include $(SRCDIR)/d/Makefile
SRCDIR := $(SRCDIR_base)
include $(SRCDIR)/e/Makefile
./a/Makefile:

Code: Select all

ifdef SRCDIR
SRCDIR := $(SRCDIR)/a
else
SRCDIR := .
endif
SRCDIR_a := $(SRCDIR)

all_a: all_b all_c
       @echo "All2 ran successfully"
       @echo $(SRCDIR_a)
       #gcc -c $(SRCDIR_a)/file.c -o $(SRCDIR_a)/file.o

include $(SRCDIR)/b/Makefile
SRCDIR := $(SRCDIR_a)
 include $(SRCDIR)/c/Makefile
./a/b/Makefile:

Code: Select all

ifdef SRCDIR
SRCDIR := $(SRCDIR)/b
else
SRCDIR := .
endif
SRCDIR_b := $(SRCDIR)

all_b:
      @echo "All3 ran successfully"
      @echo $(SRCDIR_b)
      #gcc -c $(SRCDIR_b)/file.c -o $(SRCDIR_b)/file.o
It should be simple enough to decouple and recouple a Makefile, just remove the include line from the parent and add it to whatever Makefile parents it afterwards then adjust the "all"s dependencies.
User avatar
Candy
Member
Member
Posts: 3883
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:ant instead of make?

Post by Candy »

Just a small brainfart that I'd want to work:

makefile
relinclude a/makefile
relinclude b/makefile

output: a/a.o b/b.o
gcc -o $@ $^
a/makefile
relinclude b/makefile

a.o: x.o b/b.o
gcc -o $@ $^
a/b/makefile
b.o: y.o z.o
gcc $@ $^

Wouldn't this be just one hell of a lot simpler? Effectively, this would require adding one command variation to make (which I've checked, in gmake this is near impossible... imo...) rather than making illegible makefiles. relinclude changes all file references in the given included makefile to the directory the makefile is in, instead of the directory the topmost makefile is in. This also works for including makefiles again, where this'd work repeatedly... in the end, I'd even say that this allows you to put everything in a single makefile effectively...

Must admit, I hadn't thought about doing this solution in the makefile implementation itself. It does look a little bit ugly, requires unique identifiers across all directories (which could become a bit of a pain, if you retain the requirement of moving directories all logical solutions kind of fade, except for plain numbering) but it works quite the same. There's just one unsolved thing I have left, but that's pretty easy to solve. You'd need to include a default makefile of definitions in each, where you'd only include this once. You'd also need to point to a given directory you can't find, but you can describe. Say, add another type of include and I'd be completely happy.

Anyway, just ignore me from now on, I'm done :). Got a solution.
Post Reply