I have an executable that I am currently running through a batch script. But due to certain requirements, I need to be able to run the batch script through a makefile. My batch script for reference:
@echo off
start name.exe
I have tried the following:
run:
@cmd /C "$(CURDIR)\name.bat"
Command used:
make run
This ran as expected and created a log file, so I tried to run the following:
run:
@cmd /C "@cmd /C "$(CURDIR)\name.bat"
MOVE:=run
.PHONY: all
all: $(MOVE)
Command used:
make all
The above ran just fine and generated the log file and moved some object files that were present to the appropriate locations, which is the desired output. When I tried to extend this logic to the main make file that I need to work with, of which below is a watered-down version:
run:
@cmd /C "$(CURDIR)/move.bat"
FILE_LIST = BASE_SW
MOVE:= run
FILE_LIST:= BASE_SW (directory containing files)
LIB_FILE:= $(FILE_LIST).a
$(LIB_FILE): $(MOVE) $(other dependency)
@mkdir-mingw -p $(dir name)
@$(AR) cr $(LIB_FILE_APP) $(ALL_OBJS_APP)
.PHONY:all
all: $(LIB_FILE)
make all
When this is executed, it is all rosy till the Variable for the batch script is encountered at which point the batch script is not being run.
My main aim is to be able to run the batch script when the make file has a structure like below:
run:
@cmd /C "$(CURDIR)/move.bat
MOVE:= run
LIB_FILE:= $(FILE).a
$(LIB_FILE): $(MOVE) $(Other dependencies)
recipe
.PHONY: all
all: $(LIB_FILE)
You still haven't shown (via cut and paste) the results you get. I'll make a few points:
First, you should absolutely remove the @
prefix on your recipes. By adding these you are throwing away your most useful debugging output since make doesn't show you what it's doing.
Second, assuming you have a new-enough version of GNU Make you should use the --trace
option to see what make is doing.
Third, note that by adding $(LIB_FILE): $(MOVE) ...
you're saying that you want the MOVE
target to run before the LIB_FILE
target (prerequisites are always completely built before the target is built). I don't know if that's what you want or not.