[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Simpler way to run Make in selected directories
From: |
Eli Zaretskii |
Subject: |
Re: Simpler way to run Make in selected directories |
Date: |
Sat, 14 Jan 2006 11:42:04 +0200 |
> Date: Fri, 13 Jan 2006 17:23:57 -0500
> From: Bob Stark <address@hidden>
>
> I built the following test makefile to descend into those directories and
> issue "make all". But I have violated Paul D. Smith's "rule #4" (never
> write filenames more than once).
>
> In the makefile shown below, I have targets COURSE1, COURSE2, etc. which
> are virtually identical, and I need to create another one each time I add a
> new directory. I really want it to be generic. Can someone suggest how to
> simplify this makefile? I tried several things, but I need a 2nd pair of
> eyeballs.
>
> # Makefile for building the student workbook
> COURSE1 =..\..\Java_Programming_Essentials_Eclipse\PT3610
> COURSE2 =..\..\Java_Programming_Essentials_RAD\PT3846
> COURSE3 =..\..\Java_Programming_Essentials_multiple_IDE\PT3847
> COURSE4 =..\..\Java_Programming_Essentials_WSAD512\PT3848
>
> MAKE=make
>
> # This is the default target
> .PHONY : help
> help :
> @echo make java Build all java courses
>
> .PHONY : JAVA
> JAVA : COURSE1 COURSE2 COURSE3 COURSE4
>
> # % :: $(COURSEDIR) ; :
>
> .PHONY : COURSE1
> COURSE1 : $(COURSE1)
> cd ${<} && $(MAKE) all
>
> .PHONY : COURSE2
> COURSE2 : $(COURSE2)
> cd ${<} && $(MAKE) all
>
> .PHONY : COURSE3
> COURSE3 : $(COURSE3)
> cd ${<} && $(MAKE) all
>
> .PHONY : COURSE4
> COURSE4 : $(COURSE3)
> cd ${<} && $(MAKE) all
Something like this, maybe?
SUBDIRS = $(COURSE1) $(COURSE2) $(COURSE3) $(COURSE4)
JAVA: $(SUBDIRS)
cmd.exe /c for %d in ($(SUBDIRS)) do $(MAKE) -C %d all
Btw, I don't understand why the double indirection: why you define
variables COURSEn and then use them, instead of using the directory
names themselves? Using my suggestion above, I'd simply put the
directory names into the value of SUBDIRS. Then all you need to do
when you add another course is edit the list that is the value of
SUBDIRS.
Is that what you are looking for?