Makefile call to script issues - makefile

I have a script that calls to a linter and I want to implement it into my makefile and call to it with the command make lint.
A simple call to the script (linter) either with it's path or without does not work, eg:
.PHONY: lint
lint:
./$(ROOT)/tools/Manage/linter
Even though that command works fine in the terminal. However I did get this command to work:
.PHONY: lint
lint:
cd /$(ROOT)/tools/Manage/ ; ./linter
However I've been informed that cd'ing to run script is improper makefile
practice. Any help on cleaning this up would be greatly appreciated.

Related

configure CXXFLAGS refuses to accept more than one include path

I am trying to build a project that requires two include paths.
My command is:
./autogen.sh --prefix /usr/ --libdir /usr/lib/x86_64-linux-gnu/ CXXFLAGS="-I${TensorflowPath} -I${TensorflowPath}/tensorflow/lite/tools/make/downloads/flatbuffers/include" --enable-tflite
and I have set TensorflowPath to the correct path for my tensorflow source directory.
but the error I get is:
configure: error: unrecognized option: `-I/home/aaron/src/tensorflow/tensorflow/lite/tools/make/downloads/flatbuffers/include'
This is really maddening! The second or third option is always erroring out. Please advise !!
This autogen.sh script appears to be broken both conceptually by unifying two very distinct steps (generating configure with its related files and running configure) into one without good reason, and by the actual implementation of that broken concept using a broken way of passing command line arguments to the child configure process.
If you can replace the call to autogen.sh with a call to autoreconf -vis ., just do that and ignore the broken autogen.sh:
autoreconf -vis .
./configure CXXFLAGS="-Ifoo -Ibar" --prefix=/what/ever --and-so-on
make
make install
If you absolutely need to use that autogen.sh script and cannot just replace it with a call to autoreconf -vis ., call autogen.sh with the single parameter --help to prevent it from running configure with any consequences.
The single --help argument contains no spaces and thus even an autogen.sh script with shell quoting bugs should pass it on correctly to configure. Now autogen.sh should do its buildsystem setup first, and then run configure --help which does nothing but print a bunch of messages to the console.
Then you can run your actual configure command with the correct parameters afterwards:
./autogen.sh --help
./configure CXXFLAGS="-Ifoo -Ibar" --prefix=/what/ever --and-so-on
make
make install

Makefile Cygwin: mkdir, "The syntax of the command is incorrect."

Running the following Makefile gives an error message
The syntax of the command is incorrect.
This is because the makefile calls mkdir which is a windows command instead of mkdir from Cygwin. Even though I put cygwin path first in the environment variable, it still calls the windows mkdir instead of the Cygwin one. One quick way to fix is to use mkdir.exe. Then the Cygwin one is called. I am looking for a method to call the correct one without changing the Makefile is there any way to tell Makefile which one it should call. Something in the settings?
all:
echo "make started"
mkdir -p test/tmp
echo "make ended"
Output:
C:\Users\me\Desktop\New_folder>make
echo "make started"
"make started"
mkdir -p test/tmp
The syntax of the command is incorrect.
make: *** [all] Error 1
C:\Users\me\Desktop\New_folder>
I am looking for a method to call the correct one without changing the Makefile is there any way to tell Makefile which one it should call. Something in the settings?
It's unclear which setting you're referring to, but the root of the issue is the shell the Makefile is using. It looks like it's getting cmd.exe in your case, so unqualified "mkdir" triggers its builtin. No path search is performed.
You could try to work around that by directing make to use a different shell, something like this:
make SHELL=\path\to\cygwin\bash.exe
or you could launch make from a bash shell in the first place.
Be aware, however, that even if that works, this may not be the last issue you encounter. Makefiles not built with Windows specifically in mind -- which is most of them -- cannot often adapt to the quite different Windows environment. I've had more luck with MinGW in this area, and then with Automake-based makefiles, but it has nevertheless required some special accommodation in makefile sources and in programming-language sources.

Nothing to be done for dev makefile

I have a simple Makefil here:
.PHONY: dev
dev:
php -S localhost:8000
And this error comme out: Nothing to be done for dev
The only way this could be happening is if make can't find your makefile. Are you in the same directory as this makefile when you run make? Did you name your makefile makefile or Makefile, or did you call it something else? In your question you say you have a simple Makefil but I don't know if that was a typo or if you really tried to call your makefile "Makefil" (missing final "e").
See the GNU make manual for information on how make locates makefiles.

Calling jam from Makefile does not work

In my makefile I was trying to go into a different directory and invoke jam with something like:
jam-build:
cd <somedirectory> && jam <target>
This did not work, but caused "Unknown target. Please edit 'Jamrules'." even though the exact same command on the command line works perfectly. So I know that jam can find the target.
I also tried
jam-build:
sh -c "cd <somedirectory> && jam <target>"
and variations with the same results. Also this works perfectly from the command line.
Any other command instead of "jam " works as expected (ls, ps, cat, pwd).
Update: Even creating a Makefile in <somedirectory> and running make there gives the same result.
Any ideas to why this happens would be appreciated. And, of course, things to try.
I'm running cygwin with latest gnu make, FT-jam 2.5.2.

PATH variable when calling make from XCode

For an iPad application I need to transform some CoffeeScript files into JavaScript files before bundling them with the application.
I tried to add a Makefile to my XCode project with the following code:
MANUAL_ROOT=IOS12BSH/manual
SCRIPTS_ROOT=$(MANUAL_ROOT)/scripts
COFFEE_SOURCES=$(SCRIPTS_ROOT)/*.coffee $(SCRIPTS_ROOT)/guides/*.coffee
JAVASCRIPT_TARGETS=$(COFFEE_SOURCES:.coffee=.js)
all: build
build: coffeescript
clean: clean_coffeescript
coffeescript: $(JAVASCRIPT_TARGETS)
clean_coffeescript:
rm -f $(JAVASCRIPT_TARGETS)
$(JAVASCRIPT_TARGETS): $(COFFEE_SOURCES)
coffee -c $(COFFEE_SOURCES)
Running this Makefile from the shell works without problems. However, after I added the Makefile as a target in XCode, I ran into problems.
The following error was produced by the Makefile:
coffee -c IOS12BSH/manual/scripts/*.coffee IOS12BSH/manual/scripts/guides/*.coffee
/bin/sh: coffee: command not found
make: *** [IOS12BSH/manual/scripts/*.js] Error 127
Command /Applications/Xcode.app/Contents/Developer/usr/bin/make failed with exit code 2
That is strange, as the coffee command is installed on my machine (it is installed under /opt/local/bin/coffee and /opt/local/bin is added to my $PATH in ~/.profile).
So I added an echo $(PATH) to my Makefile and it seems that the $PATH is different, when the Makefile is executed by XCode. XCode does not seem to read the settings from ~/.profile and therefore /opt/local/bin is not in $PATH.
What is the reason for this and how can I fix this, so that the coffee command is found?
Well, it seems that programs started via the Dock or Spotlight do not execute .profile and therefore $PATH is not set correctly.
So one way would be to set the $PATH in ~/.MacOSX/environments.plist. That works then apparently, but you will need a restart before it works.
Another way is to start XCode always from the command line with open projectfile.
This answer explains the problem in detail:
https://stackoverflow.com/a/14285335/751061
What ended up working best for me is just to launch Xcode from the command line.
I wrote a simple bash script that looks like:
source ~/.bash_profile # This is the trick that gets us our environment variables.
open -a "Xcode"
And then I call it from an Applescript Application just to give it a bundle I could put on the dock:
do shell script "~/xcode_launcher"
Sourcing your profile is necessary in the bash script, because running a script from Applescript doesn't ever source from a profile, so you still wouldn't have your default environment variables.
SAme thing with ant command. It works on terminal, not if Xcode have to do it. Only way to got it work: sudo open project.xcodeproj in terminal.

Resources