Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced sub-make with function calls #337

Closed
wants to merge 1 commit into from

Conversation

michaelbaisch
Copy link

By not using sub-make but function calls one is able to use this as a global makefile.

Let's say you want to use this makefile in a script or app and don't want to have a makefile in every project folder.
This could be done like this:

# Set environment variables
$ cd ~/my-arduino-project
$ make -f ~/Arduino-makefile/Arduino.mk

But using upload isn't working because it's using sub-make:

$ make -f ~/Arduino-makefile/Arduino.mk upload
make[1]: *** No rule to make target `reset'.  Stop.
make: *** [upload] Error 2

Is the use of sub-make appropriate here? Because no separate makefile is used.

https://www.gnu.org/software/make/manual/html_node/Recursion.html

This technique is useful when you want separate makefiles for various subsystems that compose a larger system. For example, suppose you have a subdirectory ‘subdir’ which has its own makefile, and you would like the containing directory’s makefile to run make on the subdirectory.

subsystem:
    cd subdir && $(MAKE)

The problem is that the -f flag isn't passed down, which makes sense if you use sub-make for separate makefiles.

https://www.gnu.org/software/make/manual/html_node/Options_002fRecursion.html

The options ‘-C’, ‘-f’, ‘-o’, and ‘-W’ are not put into MAKEFLAGS; these options are not passed down.

My suggestion is to use functions instead of sub-make.
I'm aware that this is a specific problem and maybe there is a cleaner solution.

@sudar
Copy link
Owner

sudar commented Mar 30, 2015

@michaelbaisch Thanks for the suggestion and the pull request.

While on the whole I may agree with you that we should use functions instead of sub-make, it may not be possible for us to change it in the current project because of the following reasons.

  • There are lot of customisation options that needs to be set and it may not be practical to specify all of them in the command line each time.
  • This project has been for a while and there are lot of users who are already using it. Changing it to use functions might break things for them.

@sej7278
Copy link
Collaborator

sej7278 commented Mar 30, 2015

also there is a comment that submake has been used to ensure that reset happens before upload when using multiple threads to compile

@sudar
Copy link
Owner

sudar commented Mar 30, 2015

@michaelbaisch As @sej7278 mentioned "making sure reset happens before upload" is the third reason why we are using sub-make.

Because of the above mentioned reasons, we will not be able to merge this. But if you have a solution which address these issues then we would be happy to look into it again.

@sudar sudar added the wontfix label Mar 30, 2015
@michaelbaisch
Copy link
Author

@sudar As far as I know by using functions like I did in the commit everything should work like before. And the ability to use this makefile as a global makefile (with specifying all environment variables in the command line) is with this also possible.

But as I looked into it I understand @sej7278 concern about multiple threads.
My makefile knowledge is rather rudimentary but shouldn't it be possible to use "order-only prerequisites" to ensure the right order? And maybe the additional functions aren't even necessary because the targets could be called directly?
http://www.gnu.org/software/make/manual/make.html#index-order_002donly-prerequisites

@sudar sudar force-pushed the master branch 2 times, most recently from 8c75177 to 467b677 Compare April 4, 2015 00:57
@sudar
Copy link
Owner

sudar commented Sep 30, 2018

@michaelbaisch

Are you still interested in getting this feature merged?

If yes, then please refresh your PR and we can start doing some tests.

I am closing this for now. But feel free to re-open when you refresh the PR.

@sudar sudar closed this Sep 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants