KDE-Apps.org Applications for the KDE-Desktop 
 GTK-Apps.org Applications using the GTK Toolkit 
 GnomeFiles.org Applications for GNOME 
 MeeGo-Central.org Applications for MeeGo 
 CLI-Apps.org Command Line Applications 
 Qt-Apps.org Free Qt Applications 
 Qt-Prop.org Proprietary Qt Applications 
 Maemo-Apps.org Applications for the Maemo Plattform 
 Java-Apps.org Free Java Applications 
 eyeOS-Apps.org Free eyeOS Applications 
 Wine-Apps.org Wine Applications 
 Server-Apps.org Server Applications 
 apps.ownCloud.com ownCloud Applications 
 KDE-Look.org Artwork for the KDE-Desktop 
 GNOME-Look.org Artwork for the GNOME-Desktop 
 Xfce-Look.org Artwork for the Xfce-Desktop 
 Box-Look.org Artwork for your Windowmanager 
 E17-Stuff.org Artwork for Enlightenment 
 Beryl-Themes.org Artwork for the Beryl Windowmanager 
 Compiz-Themes.org Artwork for the Compiz Windowmanager 
 EDE-Look.org Themes for your EDE Desktop 
 Debian-Art.org Stuff for Debian 
 Gentoo-Art.org Artwork for Gentoo Linux 
 SUSE-Art.org Artwork for openSUSE 
 Ubuntu-Art.org Artwork for Ubuntu 
 Kubuntu-Art.org Artwork for Kubuntu 
 LinuxMint-Art.org Artwork for Linux Mint 
 Frugalware-Art.org Artwork for Frugalware Linux 
 Arch-Stuff.org Artwork and Stuff for Arch Linux 
 Fedora-Art.org Artwork for Fedora Linux 
 Mandriva-Art.org Artwork for Mandriva Linux 
 KDE-Files.org Files for KDE Applications 
 OpenTemplate.org Documents for OpenOffice.org
 GIMPStuff.org Files for GIMP
 InkscapeStuff.org Files for Inkscape
 ScribusStuff.org Files for Scribus
 BlenderStuff.org Textures and Objects for Blender
 VLC-Addons.org Themes and Extensions for VLC
 KDE-Help.org Support for your KDE Desktop 
 GNOME-Help.org Support for your GNOME Desktop 
 Xfce-Help.org Support for your Xfce Desktop 
openDesktop.orgopenDesktop.org:   Applications   Artwork   Linux Distributions   Documents    Linux42.org    OpenSkillz.com   
KDE-Files.org - Documents for your KDE-Desktop

 Aug 29 2016  
 Not logged in  
 Home    Add Document   Forum   Groups   Knowledge   Events   Jobs   Users   Register   Login-


- Content .- Fans  . 

Makefile highlighting Fixed


Kate Highlighting

Score 53%
Makefile highlighting Fixed

Downloads:  93
Submitted:  Oct 6 2012
Updated:  Nov 16 2012


The standard KDE Makefile highlighter is mostly reflex based — it sees tokens and words, and colors them. My problem was its lack of understanding of nesting, and the resulting garbling of nested function calls.

This remake uses the state machine approach much more — it actually understands syntax (e.g. nesting), and will mark some of your syntax errors.

There was a KDE feature request for which I submitted this fix:
However, this is a fix for so much more, and it has yet to be commented after 5 months.

How to install:
Replace the default makefile.xml in /usr/share/kde4/apps/katepart/syntax/ with mine.


This version is dedicated to zaufi. Massive thanks for sending me that crazy real-world testcase! I have implemented every bit of it to the best of my knowledge.

* Fix: In recipes, or as termination of recipes, permit leading spaces in front of keywords (like ifdef), comments, new rules and assignments. Leading spaces are sometimes used inside ifdefs.
* Region markers for ifdef, define
* Comment alerts
* Green colored shell both in recipes and the $(shell function,call). Primitive highlighting of shell syntax (inclusion of bash.xml proved futile).
* Orange rules, with purple special targets (.PHONY).
* Cyan builtin variables for $(CC) $(LD) $(RM) etc. These barely stand out from the blue ordinary ones.
* Cyan bold special variables like $< $^ $@ $(SHELL) $(MAKE). These are more screaming.
* In-variable pattern substitution $(origin:%=prefix%suffix)
* Differ between immediate and deferred assignment.
* Random adjustments all over the place.

* Look for comments before looking for rule defs. (thanks, zaufi)
* Use custom style for error marking. (thanks, zaufi)
* Adjust extensions & priority so that makefile.inc and makefile.xml are recognised as makefile and XML respectively (instead of PHP and makefile).
* Removed silent operator '@' from normal mode (probably a leftover from old design).


There are mainly 2 things I have refactored from the 1.12 version I started with, plus some random fixes.

Main thing 1:
Expand the state machine to identify prerequisites and rule definitions.
This allowed me to:
* mark leading spaces as errors in rule definitions (Finally!)
* don't recognise keywords in rule definitions
* don't recognise keywords, singlequotes or doublequotes in prerequisites
* color prerequisites (default color for data types (blue))

Main thing 2:
Rework how variables and function calls are recognised.
* don't distinguish callsites of functions
(don't neglect functions in rhs of assignments)
* distinguish function calls from variables in an intermediate "call" state
(stop looking for function names in variables)
* test what comes after the $ sign in an intermediate "dollar" state
(simplified many other states)
* recognise unparenthesized variables
e.g. var$iable means var$(i)able
* recognise computed variable names
e.g. $(var$(i)able)

Random fixes:
* mark illegal characters in variable names (whitespace, =, :, #)
* add the "override" keyword
* make the "filter-out" function work (the only with a dash in its name)
* color assignment operators (=, +=, :=) like operators, not as strings
* recognise singlequoted strings in function parameters
* recognise doublequoted strings in commands
* color commas in function calls
* color the whole command if the silent operator @ is prepended to it

public domain

Send to a friend
Other  Documents  from aNordal
Report inappropriate content


 few problems...

 by zaufi on: Oct 8 2012
Score 50%

0) if comments (lines w/ '#' as first noncpace char) contains a ':' symbol they higlighted as targets (not as comments!)

1) I still can't see error highlighting when spaces mixed w/ tabs (particularly spaces before tabs in rule definition)

Reply to this


 Thanks for testing

 by aNordal on: Oct 9 2012
Score 50%

0) Will fix. Thanks, that was embarrasing ;)

1) Works for me.
Leading spaces in rule defs are marked with the default "Error" style (red underline, in my case).
How is your "Error" style? (Settings → Configure Editor → Fonts & Colors → Highlighting Text Styles)
It needs to be underlined to be visible on spaces. I could make a custom style.

Reply to this


 Re: Thanks for testing

 by zaufi on: Oct 10 2012
Score 50%


I've played w/ 2.1 version and still found few problems w/ it... Some of them are:
0) it is Ok to use a backslash to continue dependency list on a next line, but it displayed as error in that case:

some-target : dep1 dep2 ... depM \
<spaces-here> depN ... depZ
<-tab->@rules goes here

1) it is not required for target names to be the first symbol on a line

target-1-displayed-ok : blah

<spaces> target-2-not-higlighted : blah-blah

sometimes it is convinient to have indented target definitions due `if' conditions...
btw, even if target name is at position 0, the following snippet displayed incorrectly:
target: blah
<-tab-># empty rule... just target (deps) declaration...

<spaces> # just a comment w/ leading spaces...

2) static pattern rules are diplayed strange (see 4.12.1 of `info make`) -- I guess better to introduce a few types (attributes) for different kind of rule declarations

3) the following snippet has strange (incorrect) higlighting @ 2nd line:
foo:= a.c b.c c.c
bar:= $(foo:.c=.o)

4) the following snippet is valid, but displayed incorrectly:

all:;echo $(foo)

moreover if next line starts w/ leading spaces it will be displayed as error, which is obviously incorrect as well...

also here is a whishlist :)
* it would be neat to higlight special targets (like .PHONY, .DEFAULT, & etc)
* also it may helps to higlight predefined make variables (like MAKELEVEL, MAKEFILES, etc) to make 'em visually diferent than a usual one...
* "10.5.3 Automatic Variables" (like $@, $<, $(D), etc)
* maybe "10.3 Implicit Variables"
* it would be nice to reuse bash.xml somehow to higlight a rules...

Reply to this


 Re: Thanks for testing

 by zaufi on: Oct 10 2012
Score 50%

btw, I have some legacy project w/ a sophisticated makefile(s) (in fact a whole build system like autotools was implemented on pure makefiles), so you may play w/ higligting on it...

just give me a mail where I can send some files for you...

Reply to this


 Re: Re: Thanks for testing

 by aNordal on: Oct 10 2012
Score 50%

You can find me in makefile.xml.
You had lots of suggestions here, will look into it ;)
If this takes off, I might put this in a git repo…

Reply to this

Add commentBack


Copyright 2004-2016 KDE-Files.org Team  Legal Notice
All rights reserved. KDE-Files.org is not liable for any content or goods on this site.
You can find our FAQ here.
All contributors are responsible for the lawfulness of their uploads.
Please send us a notice if you spot an ABUSE of the website.
Information about advertising in KDE-Files.org.
Developers can use our public webservice interface. More information here: public api
For further information or comments on this site, please send us a message
KDE and K Desktop Environment are trademarks of KDE e.V.
Content RSS   
Events RSS