Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Coffee corner » The power of Makefile
icon3.gif  The power of Makefile [message #24947] Fri, 05 February 2010 15:45 Go to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

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 Wink

Best regards,
Honza
 
Read Message icon3.gif
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message icon14.gif
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Anybody still knowing anyone using Win98?
Next Topic: What do you think I should do?
Goto Forum:
  


Current Time: Thu Mar 28 17:00:41 CET 2024

Total time taken to generate the page: 0.01813 seconds