On Wed, 2016-06-29 at 14:03 -0400, LMH wrote:
> #create build directory if it doesn't exist
> $(BDIR):
>         @mkdir -p $(BDIR)
> 
> all: $(BDIR)/SMD2_i386.exe

Here you've created a target $(BDIR), but your "all" target depends
only on the object file $(BDIR)/SMD2_i386.exe.

Since nothing depends on the actual target $(BDIR), make will never try
to build that target.

In order for this to work you'd need to define the directory as a
prerequisite of the target which needs it, which in this case is
$(BDIR)/SMD2_i386.exe, so you'd need to write:

  $(BDIR)/SMD2_i386.exe : <other prereqs> $(BDIR)

However, you should generally not have targets depend on directories,
because make treats them just like any other file when it checks
modification times; however directories do not act like normal files
when it comes to modification times.

I usually just use:

  $(shell mkdir -p $(BDIR))

but other people prefer order-only prerequisites:

  $(BDIR)/SMD2_i386.exe : <other prereqs> | $(BDIR)

(note the extra "|" there).  Check the GNU make manual for details.

Note these are all specific to GNU make and not portable to other versions of 
make.

_______________________________________________
Help-make mailing list
Help-make@gnu.org
https://lists.gnu.org/mailman/listinfo/help-make

Reply via email to