Index: Portfile
===================================================================
--- Portfile	(revision 99112)
+++ Portfile	(working copy)
@@ -6,6 +6,7 @@
 
 name                kdelibs4
 version             4.8.5
+revision            1
 categories          kde kde4
 maintainers         sharky michaelld nicos
 license             GPL-2+
@@ -102,13 +103,26 @@
         ${destroot}${prefix}/Library/LaunchAgents/org.macports.kdecache.plist
     
     xinstall -d -m 755 ${destroot}${startup_root}/Library/LaunchAgents
-    ln -s ${prefix}/Library/LaunchAgents/org.macports.kdecache.plist ${destroot}${startup_root}/Library/LaunchAgents
 }
 
 post-activate {
+	# set user permissions for root install
     if { ![variant_isset no_root] } {
-        file attributes ${prefix}/Library/LaunchAgents/org.macports.kdecache.plist -owner root -group wheel 
+       file attributes ${prefix}/Library/LaunchAgents/org.macports.kdecache.plist -owner root -group wheel
     }
+
+    # delete leftover file, if any
+    if [file exists /Library/LaunchDaemons/org.macports.kdecache.plist] {
+		file delete -force /Library/LaunchDaemons/org.macports.kdecache.plist}
+	}
+	# The startupitem.install keyword does not exist in MacPorts < 2.1.
+    if {![info exists startupitem.install]} {
+       set startupitem.install yes
+    }
+    # If "startupitem.install" is set to "no" in macports.conf then do not link.
+    if {${startupitem.install} != "no"} {
+        ln -s ${destroot}${startup_root}/Library/LaunchAgents/org.macports.kdecache.plist /Library/LaunchDaemons
+    }
 }
 
 notes " ##########################################################################
