# MakeCommands

## Overview

If you have installed this package, there are automatically created sublime-commands from Makefiles' targets.

### Motivation

I mostly work with makefiles and I am used to vim's :make command, where you can optionally pass a target. So you can run :make test or :make deploy, or whatever target is there.

This package makes targets available as sublime commands, such that you can run them from Command Palette.

### Default Behaviour

If you are editing a file, which has a Makefile on same or higher level in directory structure, targets from it are automatically made available as commands. If there is a target "test", then there will be created command ":make test".

### How Makefiles are Processed

Usually all targets containing only characters, numbers, "_" or "-", are made available as targets.

There may be produced too many targets from your makefiles and you only use a subset of the targets. Then you can create a special target .SUBLIME_TARGETS and list targets as prerequisites, which you want to access from sublime text:

.SUBLIME_TARGETS: all deploy test


This example would only make targets all, deploy and test available as commands regardless, which targets you have in your Makefile.

There is a special recipe for writing targets, which may have input and are always displayed as sublime-targets, even if they are not part of .SUBLIME_TARGETS.

Initial motivation for this mechanism was the need of an overall commit in the root of nested repositories even if editing a file in a subrepository.

First have a look at the targets:

sublime.hg-status:
hg status

sublime.hg-commit.in-commit_message:
hg commit -m "$(SUBLIME_INPUT_commit_message)" sublime.hg-add.in-file: if [ -z$(SUBLIME_INPUT_file)] ; then \
cd $(dirname$(SUBLIME_FILENAME)) ; \
hg add $(SUBLIME_FILENAME) ; \ else \ cd$(dirname $(SUBLIME_INPUT_file)) ; \ hg add$(SUBLIME_INPUT_file) ;\
fi

sublime.hg-status
This target will be displayed as :make hg-status in command palette and displays the status of the repository the Makefile is in.
sublime.hg-commit.in-commit_message:
This target is represented by :make hg-commit in command palette and will first open input_panel and ask for a commit_message and then runs the target with SUBLIME_INPUT_commit_message make variable set.

This target is represented by :make hg-add in command palette and will ask for a file. If no filepath given, the view's filename represented by make variable SUBLIME_FILENAME will be taken, else the filepath entered will be taken and interpreted relative to Makefile.

Finally file represented by final filepath, will be added to nearest enclosing repository.

So it is easy to ask for interactive input, which you can later use in your make recipes.

## Installation

Download Package Control and use Package Control: Install Package Command from command palette. Command Palette is opened using ctrl+shift+p on Windows and Linux and cmd+shift+p on Mac.

Once you run Package Control: Install Package, there will open up a list of packages. Type MakeCommands and hit enter.

## Configuration

First a quick overview on configuration settings.

Setting Type Default
make_commands_makefiles String or List []
}


### make_commands_stop_at_opened_folders

If there is turned on make_commands_find_parent_makefile, this toggle specifies, if it is stopped looking for Makefile at directory level of currently opened folders.

### make_commands_find_parent_makefile

If this setting is turned on, there is tried to find a makefile matching make_commands_makefile_pattern in parent folders starting in folder of file in current view. Depending on make_commands_stop_at_opened_folders it is stopped in folders opened in current window.

### make_commands_search_in_opened_folders

If this setting is turned on, it is looked for makefiles matching make_commands_makefile_pattern in opened folders.

### make_commands_command_caption_format

This specifies how your commands' caption shall look like. Default is:

":make %(target)s"


### make_commands_make_command

This specifies your make command. It defaults to make.

### make_commands_debug

This toggle enables debug output to console panel.

You can use this under Simplified BSD License: