 			proc.on "close", () ->
 				callback()
 
-
+		checkMake: (callback = (error) ->) ->
+			grunt.log.write "Checking make is installed... "
+			exec "make --version", (error, stdout, stderr) ->
+				if error? and error.message.match("not found")
+					grunt.log.error "FAIL."
+					grunt.log.errorlns """
+					Either make is not installed or is not in your path.
+
+					On Ubuntu you can install make with:
+
+					    sudo apt-get install build-essential
+
+					"""
+					return callback(error)
+				else if error?
+					return callback(error)
+				else
+					grunt.log.write "OK."
+					return callback()
 		checkMongoConnect: (callback = (error) ->) ->
 			grunt.log.write "Checking can connect to mongo"
 			mongojs = require("mongojs")



	grunt.registerTask 'install:all', "Download and set up all ShareLaTeX services",
		["check:make"].concat(
			("install:#{service.name}" for service in SERVICES)
		)


	grunt.registerTask "check:redis", "Check that redis is installed and running", () ->
		Helpers.checkRedisConnect @async()

	grunt.registerTask "check:mongo", "Check that mongo is installed", () ->
		Helpers.checkMongoConnect @async()

	grunt.registerTask "check", "Check that you have the required dependencies installed", ["check:redis", "check:mongo", "check:make"]

	grunt.registerTask "check:make", "Check that make is installed", () ->
		Helpers.checkMake @async()

	grunt.registerTask 'migrate', "compile migrations and run them", ['coffee:migrate', 'shell:migrate']

