Makefile
changeset 518 576a7e0fd9e0
parent 386 3efe37437745
child 536 14583eae4848
--- a/Makefile	Tue Dec 14 15:54:04 2010 +0200
+++ b/Makefile	Wed Dec 22 14:57:33 2010 +0200
@@ -2,6 +2,14 @@
 #
 # You can do anything with this file without any warranty.
 
+################################################################
+# Helper definition.
+
+which = $(firstword $(foreach item,$(subst :, ,$(PATH)),$(wildcard $(item)/$1)))
+
+################################################################
+# Platform/environment definition.
+
 ifeq '' '$(HOME)'
   $(error Home env var not set!)
 endif
@@ -11,13 +19,17 @@
   host_os = windows
 endif
 
-# Special case for Windows if emacs-nox from Cygwin installed along with native Emacs.
-# So we run native Emacs to compile sources.
 EMACS = emacs
+# I prefer native Windows Emacs, so use it if available.
 ifeq 'windows' '$(host_os)'
-  EMACS = runemacs
+  ifneq '' '$(call which,runemacs.exe)'
+    EMACS = runemacs
+  endif
 endif
 
+################################################################
+# Targets.
+
 FILES_MODE_EL := $(wildcard *-mode.el)
 
 .PHONY: all