What's New in GMSL 1.0.2

[article]

The ifeq then compares the resulting value with $(DEBUG). That's pretty ugly, and hard to maintain and contains a subtle bug (what happens if $(DEBUG) is empty?). Fixing the bug means doing something like:

include gmsl

ifeq (x$(DEBUG)x,$(filter x$(DEBUG)x,xYx xYesx))
...
endif

Using the GMSL or operator this becomes much clearer:

ifeq ($(true),$(call or,$(call seq,$(DEBUG),Y),$(call seq,$(DEBUG),Yes)))
...
endif

That's much more maintainable. It works by before the or on two calls to seq and then comparing the result with $(true).

New in v1.0.2: uniq

The final new function in GMSL v1.0.2 is uniq which removes duplicates from a list (recall that in GNU Make terms a list is a string with spaces separating list elements).

GNU Make has a built-in sort function that both sorts a list and removes duplicates; uniqremoves duplicates without sorting the list (which can be handy if list order is important).

So, for example, $(sort c b a a c) will return a b c, whereas as $(call uniq,c b a a c) returns c b a.

For example, suppose you need to simplify the PATH variable by removing duplicate entries while preserving the order. The PATH is typically a colon-separated list of paths (e.g. /usr/bin:/bin:/usr/local/bin:/bin); here simple-path is the PATH with duplicates removed and order preserved:

include gmsl

simple-path := $(call merge,:,$(call uniq,$(call split,:,$(PATH))))

This uses three GMSL functions: uniq, split (which splits a string into a list at a certain separator character; in this case colon) and merge (which merges a list into a string separating list entries with a character; in this case a colon).

Bug Fixes in v1.0.2

Since 1.0.0 was released there have been three bug fixes that make v1.0.2 an important upgrade.

The most serious bug seq function is incorrect was an error in the implementation of the 'string equal' function (called seq).

The `%' character in strings not properly escaped bug meant that the seq function would give incorrect results if the first string argument contain the % character (since % is a GNU Make wildcard character).

The final, very minor, bug Define tracing variables even when GMSL_TRACE not set was fixed so that GNU Make doesn't report an 'undefined variable' error.

Future

The GMSL grows with suggestions from users. If you'd like to see new functionality added (or have a bug to report) please visit the GMSL web site and get involved: gmsl.sf.net.

About the author

John Graham-Cumming's picture John Graham-Cumming

John Graham-Cumming is Co-Founder at Electric Cloud, Inc . Prior to joining Electric Cloud, John was a Venture Consultant with Accel Partners, VP of Internet Technology at Interwoven, Inc. (IWOV), VP of Engineering at Scriptics Corporation (acquired by Interwoven), and Chief Architect at Optimal Networks, Inc. John holds BA and MA degrees in Mathematics and Computation and a Doctorate in Computer Security from Oxford University. John is the creator of the highly acclaimed open source POPFile project. He also holds two patents in network analysis and has others pending.

AgileConnection is one of the growing communities of the TechWell network.

Featuring fresh, insightful stories, TechWell.com is the place to go for what is happening in software development and delivery.  Join the conversation now!