Jun 2, 2011 at 3:45pm UTC
hi,
I am trying to create subdirectories under my ../objs directory within a make file.
my ../src directory has the following subdirectories:
source-a
source.1.1
so, I want to label the subdirectories under my ../objs directory with the same names as those in the ../src directory, so that I have:
../objs/source-a
../objs/source.1.1
I have written the following code:
SRCDIR = $(shell echo ../src/*)
OBJDIR = ../objs
subdirname :=$(notdir $(basename $(SRCDIR)))
objdirs := $(addprefix $(OBJDIR)/, $(subdirname))
all: makedir
makedir: $(objdirs)
mkdir $^
but that is not working, I get an error message as follows:
make: *** No rule to make target `../objs/source-a', needed by `makedir'. Stop.
How do I fix this?
thanks!
Jun 3, 2011 at 8:18am UTC
You need a tab before mkdir $^ (I think).
Jun 3, 2011 at 1:38pm UTC
I do have a tab...it just didn't show up when I copied and pasted on the post here :-(
Jun 3, 2011 at 2:05pm UTC
thanks kbw, I appreciate the link :-)
Jun 3, 2011 at 8:46pm UTC
hi kbw,
my subdirname variable above returns the following values:
source-a
source.1.1
if I wanted the second value to be source instead of source.1.1, do I need to use sed or is there a more straightforward and simple way of extracting the info.
thanks!