Smart Deals - promotions, discount codes and sales

Makefile Generator

Turn a list of name: command tasks into a ready Makefile with real tabs and a help target.

Secure (SSL)
Client-Side Processing
100% Free
Instructions
  • 1
    Enter data
    Enter content, paste text or load a file from disk.
  • 2
    Click the button
    The tool will immediately process your data in the browser.
  • 3
    Get the result
    Copy the finished text or save the file to your device.
function runTool() {
  return "Result ready in 0.1s";
}
Enter your tasks and click "Generate Makefile".

Rate this tool:

Related tools

Other tools you may find useful

Makefile generator - targets, commands and a self-documenting help

The Makefile generator turns a list of name: command tasks into a ready Makefile: real tab characters in every recipe, a .PHONY declaration covering all targets, and a help target that prints the available commands by itself. Type a project name, paste your tasks and copy the result into the root of your repository.

What this tool actually produces

Every line of the form is split on the first colon: the left side becomes the target name, the right side the shell command. A name may contain only letters, digits, underscores and hyphens, so you cannot end up with a target Make refuses to call. An empty command becomes echo "name", so the file stays runnable and the target is visibly a placeholder. Repeated names are merged into one entry, because a second recipe for the same target triggers the overriding recipe for target warning.

The file opens with a comment carrying your project name. Next comes .DEFAULT_GOAL := help, so a bare make prints help instead of building whatever target happens to be first. Then a single .PHONY line lists every target, and finally the targets themselves appear in the order you entered them, each with a ## comment that the help target turns into a command listing.

Anatomy of a Makefile

ElementSyntaxRole
Targetbuild:Task name you invoke with make build
Recipe npm run buildThe command for a target - tab first, one shell per line
Prerequisitesbuild: installTargets that must run before this one
.PHONY.PHONY: build testTargets that are not files, so Make skips timestamp checks
.DEFAULT_GOAL.DEFAULT_GOAL := helpThe target a bare make runs
Doc commentbuild: ## builds the bundleText after ## is collected by help

Tabs instead of spaces - the classic Make trap

Every recipe line must begin with a tab. Four spaces end in Makefile:7: *** missing separator. Stop. This generator emits real tab characters, but an editor configured to convert tabs into spaces can undo that the moment you paste.

Disable tab conversion for files named Makefile in your editor. To inspect a suspicious file, run cat -A Makefile - a correct recipe line starts with ^I. GNU Make does let you change the indent character through .RECIPEPREFIX, but that breaks portability, so sticking with the tab is the safer choice.

Dollar signs and variables inside recipes

Make expands $ before the line ever reaches the shell, which is why shell variables and awk fields are written twice: $$PATH, $$1, $$(date). A single $(FOO) is a Make variable, and $(shell date) runs while the file is being parsed rather than while the target executes. The help target from this generator uses both forms at once: $(MAKEFILE_LIST) stays on the Make side, while $$1 and $$2 reach awk as column numbers.

How to use the generator

  1. Enter a project name - it goes into the comment on the first line of the file.
  2. List your tasks, one per line, in the name: command format, for example test: vendor/bin/phpunit.
  3. Click Generate Makefile and copy the result.
  4. Save the contents as Makefile (capital M) in the root of your project.
  5. Run make or make help to see the target list, then run the one you need: make test.

A Makefile fits into the rest of the toolchain: a short make deploy can be called from a pipeline built with the GitLab CI configuration generator or the Jenkinsfile generator, while recurring jobs belong in the crontab generator. Before the first commit the .gitignore file generator helps, and for an Apache deployment so does the .htaccess file generator.

What this tool does not do

One target gets exactly one command. Multi-line recipes, prerequisites, variables, ifeq conditionals and pattern rules such as %.o: %.c you add by hand to the generated skeleton. The generator also does not check whether a command exists on your system - it validates the line format and the target name.

Frequently asked questions

Why does a Makefile require tabs?

It is a 1976 decision that the author of Make later called a mistake, but backward compatibility won. Today the tab is the only portable recipe indent. Spaces produce a missing separator error that names the line number, so start your search there.

How is a Makefile different from a bash script or npm scripts?

Make understands dependencies between targets and files: when a target matches a file newer than its prerequisites, it skips the work. A bash script runs everything every time, and npm scripts only exists in projects with a package.json. A Makefile is language agnostic, so a single make test can cover a repository holding PHP, Python and a frontend at once.

What is .PHONY really for?

It declares targets that do not create a file named after them. Without it, a build directory or a test file in the repository is enough for Make to consider the target done and print make: 'test' is up to date. This generator adds .PHONY for every target, because all of them are tasks rather than build products.

How do I pass an argument to a target?

A variable is the simplest route: make deploy ENV=staging, then $(ENV) inside the recipe. Set a default with ENV ?= production above the targets. Command line variables take precedence over those in the file, so a one-off run needs no edits.

Does a Makefile work on Windows?

Yes, once make is installed - usually through Git Bash, MSYS2, Chocolatey or WSL. The syntax is portable, the commands inside recipes are not: rm -rf and path separators behave differently under cmd.exe. If the project has to run on both systems, invoke Make from WSL or move the commands into scripts called by the target.

Install Webp.pl Have the tools in your own pocket!