What's New in GMSL 1.0.2


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))

Using the GMSL or operator this becomes much clearer:

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

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.


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

AgileConnection is a TechWell community.

Through conferences, training, consulting, and online resources, TechWell helps you develop and deliver great software every day.