Home » Community » Coffee corner » The power of Makefile
The power of Makefile [message #24947] |
Fri, 05 February 2010 15:45  |
|
Hello everybody!
I just have to share this bit of kowledge I've just gained with all of you... Until yesterday, I thought that make is just another simple unix tool. But after reading Managing projects with GNU make, I changed my mind.
Actually make is more like a programming language. It provides a lot of features and possibilities I would ever think of. Like defining functions, built-in rules, pattern expansion and many more.
Just to show you (at least to those of you who don't know make really good): Following Makefile is just a few lines, but it can analyze U++ package dependencies. For now, it is restricted to one directory, so it works only for uppsrc or in directory with exported project. Also, it ignores flags (just includes everything in "uses") . Both of this could be probably fixed with few more lines. Another problem might be it's speed. For ide it takes about 12s on my laptop, but for average-sized packages, it's less than second (also it's definitely not optimal, some steps are duplicated). Ok, here is the code:
PKG=ide
DEP=$(PKG)
define get-upp
$(if $(findstring /,$1),$1/$(notdir $1).upp,$1/$1.upp)
endef
define get-uses
$(strip $(shell cat $(call get-upp,$1) | tr ",\n;" " \n" | grep "uses" | sed 's/(.*)//'))
endef
define get-deps
$(sort $1 $(foreach d,$(sort $(subst \,/,$(filter-out uses%,$(call get-uses,$1)))),$(call get-deps,$d)))
endef
.PHONY: all
all:
@echo "To build $(PKG) following packages are needed:"
@echo "$(call get-deps,$(PKG))"
If you want to try it, just create file uppsrc/Makefile and copy this in. To execute call make or make PKG=AnyOtherPackage. Actually this is what I like best - the universality. Actually I believe that it would be possible to extend this simple example to not only analyze, but also compile any package. The only information that would have to be added would be assembly structure, flags and compiler/linker options (or path to .bm and .var file).
If you read all the way down here, thanks for your patience 
Best regards,
Honza
|
|
|
 |
 |
The power of Makefile
|
 |
|
Re: The power of Makefile
By: mirek on Fri, 05 February 2010 16:04
|
 |
|
Re: The power of Makefile
By: masu on Fri, 05 February 2010 16:32
|
 |
|
Re: The power of Makefile
|
 |
|
Re: The power of Makefile
By: masu on Sat, 06 February 2010 22:46
|
 |
|
Re: The power of Makefile
By: masu on Sat, 06 February 2010 22:55
|
 |
|
Re: The power of Makefile
|
 |
|
Re: The power of Makefile
By: mr_ped on Sun, 07 February 2010 01:42
|
 |
|
Re: The power of Makefile
By: masu on Sun, 14 February 2010 21:08
|
 |
 |
Re: The power of Makefile
|
 |
|
Re: The power of Makefile
By: masu on Mon, 15 February 2010 16:24
|
 |
|
Re: The power of Makefile
|
 |
|
Re: The power of Makefile
By: masu on Tue, 16 February 2010 23:24
|
 |
|
Re: The power of Makefile
|
 |
|
Re: The power of Makefile
By: chickenk on Mon, 15 March 2010 11:38
|
 |
|
Re: The power of Makefile
|
 |
|
Re: The power of Makefile
By: koldo on Mon, 15 March 2010 12:13
|
 |
|
Re: The power of Makefile
|
 |
|
Re: The power of Makefile
By: masu on Mon, 15 March 2010 12:31
|
 |
|
Re: The power of Makefile
|
 |
|
Re: The power of Makefile
By: masu on Thu, 18 March 2010 10:57
|
 |
|
Re: The power of Makefile
By: Reini on Fri, 19 March 2010 17:53
|
 |
|
Re: The power of Makefile
|
 |
|
Re: The power of Makefile
By: masu on Mon, 22 March 2010 11:05
|
 |
|
Re: The power of Makefile
By: Reini on Mon, 22 March 2010 20:32
|
 |
|
Re: The power of Makefile
By: masu on Tue, 23 March 2010 10:45
|
 |
|
Re: The power of Makefile
|
 |
|
Universal Makefile
|
 |
|
Re: Universal Makefile
By: chickenk on Sat, 28 August 2010 09:22
|
 |
|
Re: Universal Makefile
|
 |
|
Re: Universal Makefile
By: masu on Mon, 29 November 2010 20:57
|
 |
|
Re: Universal Makefile
|
 |
|
Re: Universal Makefile
By: masu on Mon, 29 November 2010 23:33
|
Goto Forum:
Current Time: Mon Apr 28 02:07:34 CEST 2025
Total time taken to generate the page: 0.00623 seconds
|