--- Nukefile.orig	2017-04-14 23:02:41.000000000 -0500
+++ Nukefile	2017-11-26 09:25:43.000000000 -0600
@@ -25,6 +25,9 @@
      (if (env objectForKey:"PREFIX")
          (then (set @prefix (env objectForKey:"PREFIX")))
          (else (set @prefix "/usr/local")))
+     (if (env objectForKey:"FRAMEWORKS_DIR")
+         (then (set @frameworks_dir (env objectForKey:"FRAMEWORKS_DIR")))
+         (else (set @frameworks_dir "/Library/Frameworks")))
      (if (env objectForKey:"DESTDIR")
          (then (set @destdir (env objectForKey:"DESTDIR")))
          (else (set @destdir ""))))
@@ -79,23 +82,8 @@
 
 ;; build configuration
 
-(set @sdkflags "")
-(set @sdk
-     (cond ((NSFileManager directoryExistsNamed:"#{DEVROOT}/SDKs/MacOSX10.8.sdk")
-            (set @sdkflags "-D__OBJC2__")
-            ("-isysroot #{DEVROOT}/SDKs/MacOSX10.8.sdk"))
-           ((NSFileManager directoryExistsNamed:"#{DEVROOT}/SDKs/MacOSX10.7.sdk")
-            (set @sdkflags "-D__OBJC2__")
-            ("-isysroot #{DEVROOT}/SDKs/MacOSX10.7.sdk"))
-           ((NSFileManager directoryExistsNamed:"#{DEVROOT}/SDKs/MacOSX10.6.sdk")
-            (set @sdkflags "-D__OBJC2__")
-            ("-isysroot #{DEVROOT}/SDKs/MacOSX10.6.sdk"))
-           ((NSFileManager directoryExistsNamed:"#{DEVROOT}/SDKs/MacOSX10.5.sdk")
-            (set @sdkflags "-D__OBJC2__")
-            ("-isysroot #{DEVROOT}/SDKs/MacOSX10.5.sdk"))
-           ((NSFileManager directoryExistsNamed:"#{DEVROOT}/SDKs/MacOSX10.4u.sdk")
-            ("-isysroot #{DEVROOT}/SDKs/MacOSX10.4u.sdk"))
-           (else "")))
+(set @sdkflags "-D__OBJC2__")
+(set @sdk "@SDK@")
 
 (ifDarwin
          (then (set @cflags ( "-Wall -g -fPIC -O2 -DMACOSX #{@sdk} #{@sdkflags}"))
@@ -112,10 +100,7 @@
 (set @cflags (+ @cflags " -DHAVE_CONFIG_H"))
 
 (ifDarwin
-         (then (set @arch '()))) ;; optionally add "ppc" or "ppc64" to the list
-
-(if (or isSnowLeopard isLion)
-    (then (set @arch (append @arch '("x86_64")))))
+         (then (set @arch '("@ARCHS@"))))
 
 (set @includes
      ((@inc_dirs map: (do (inc) " -I#{inc}")) join))
@@ -239,7 +224,7 @@
 
 (task "default" => "nush")
 
-;; Except for the Nu.framework (installed in /Library/Frameworks),
+;; Except for the Nu.framework (installed in #{@frameworks_dir}),
 ;; all scripts and binaries are installed to #{@prefix}/bin
 
 (set @installprefix "#{@destdir}#{@prefix}")
@@ -247,28 +232,28 @@
 (task "install" => "nush" is
       ('("nuke" "nustyle" "nutemplate" "nutest" "nudoc" "nubake" "nutmbundle") each:
         (do (program)
-            (SH "sudo cp tools/#{program} #{@installprefix}/bin")))
-      (SH "sudo cp nush #{@installprefix}/bin")
+            (SH "cp tools/#{program} #{@installprefix}/bin")))
+      (SH "cp nush #{@installprefix}/bin")
       (ifDarwin
                ;; install the framework
-               (SH "sudo rm -rf #{@destdir}/Library/Frameworks/#{@framework}.framework")
-               (SH "sudo ditto #{@framework}.framework #{@destdir}/Library/Frameworks/#{@framework}.framework"))
+               (SH "rm -rf #{@destdir}#{@frameworks_dir}/#{@framework}.framework")
+               (SH "ditto #{@framework}.framework #{@destdir}#{@frameworks_dir}/#{@framework}.framework"))
       (ifGNUstep
                 ;; install the dynamic library
-                (SH "sudo mkdir -p #{@installprefix}/lib")
-                (SH "sudo cp #{@library_executable_name} #{@installprefix}/lib")
+                (SH "mkdir -p #{@installprefix}/lib")
+                (SH "cp #{@library_executable_name} #{@installprefix}/lib")
                 ;; copy the headers
-                (SH "sudo rm -rf #{@installprefix}/include/Nu")
-                (SH "sudo mkdir -p #{@installprefix}/include/Nu")
-                (SH "sudo cp -rp objc/*.h #{@installprefix}/include/Nu")
-                (SH "sudo rm -rf #{@installprefix}/share/libNu")
-                (SH "sudo mkdir -p #{@installprefix}/share/libNu")
-                (SH "sudo cp -rp nu/* #{@installprefix}/share/libNu"))
-      (SH "sudo mkdir -p #{@installprefix}/share")
-      (SH "sudo rm -rf #{@installprefix}/share/nu")
-      (SH "sudo cp -rp share/nu #{@installprefix}/share/nu")
+                (SH "rm -rf #{@installprefix}/include/Nu")
+                (SH "mkdir -p #{@installprefix}/include/Nu")
+                (SH "cp -Rp objc/*.h #{@installprefix}/include/Nu")
+                (SH "rm -rf #{@installprefix}/share/libNu")
+                (SH "mkdir -p #{@installprefix}/share/libNu")
+                (SH "cp -Rp nu/* #{@installprefix}/share/libNu"))
+      (SH "mkdir -p #{@installprefix}/share")
+      (SH "rm -rf #{@installprefix}/share/nu")
+      (SH "cp -Rp share/nu #{@installprefix}/share/nu")
       (ifDarwin
-               (SH "sudo ditto examples #{@installprefix}/share/nu/examples")))
+               (SH "ditto examples #{@installprefix}/share/nu/examples")))
 
 ;; Build a disk image for distributing the framework.
 (task "framework_image" => "framework" is
