{"id":26124430,"url":"https://github.com/dnaeon/makefile-graph","last_synced_at":"2025-04-06T20:09:26.963Z","repository":{"id":234876642,"uuid":"789670222","full_name":"dnaeon/makefile-graph","owner":"dnaeon","description":"Turn your Makefile into a graph","archived":false,"fork":false,"pushed_at":"2024-11-21T14:35:36.000Z","size":51,"stargazers_count":116,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"v1","last_synced_at":"2025-03-30T19:05:30.244Z","etag":null,"topics":["go","golang","graph","graphviz","make","makefile"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dnaeon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["dnaeon"]}},"created_at":"2024-04-21T08:11:25.000Z","updated_at":"2025-03-25T05:11:20.000Z","dependencies_parsed_at":"2024-06-19T11:28:33.284Z","dependency_job_id":"191dbe7c-dd8a-4367-95c1-8340ff97c94a","html_url":"https://github.com/dnaeon/makefile-graph","commit_stats":null,"previous_names":["dnaeon/makefile-graph"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnaeon%2Fmakefile-graph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnaeon%2Fmakefile-graph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnaeon%2Fmakefile-graph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnaeon%2Fmakefile-graph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dnaeon","download_url":"https://codeload.github.com/dnaeon/makefile-graph/tar.gz/refs/heads/v1","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247543589,"owners_count":20955865,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","graph","graphviz","make","makefile"],"created_at":"2025-03-10T16:08:19.903Z","updated_at":"2025-04-06T20:09:26.928Z","avatar_url":"https://github.com/dnaeon.png","language":"Go","funding_links":["https://github.com/sponsors/dnaeon"],"categories":[],"sub_categories":[],"readme":"# makefile-graph\n\n[![Build Status](https://github.com/dnaeon/makefile-graph/actions/workflows/test.yaml/badge.svg)](https://github.com/dnaeon/makefile-graph/actions/workflows/test.yaml/badge.svg)\n[![Go Reference](https://pkg.go.dev/badge/github.com/dnaeon/makefile-graph.svg)](https://pkg.go.dev/github.com/dnaeon/makefile-graph)\n[![Go Report Card](https://goreportcard.com/badge/github.com/dnaeon/makefile-graph)](https://goreportcard.com/report/github.com/dnaeon/makefile-graph)\n[![codecov](https://codecov.io/gh/dnaeon/makefile-graph/branch/master/graph/badge.svg)](https://codecov.io/gh/dnaeon/makefile-graph)\n\n`makefile-graph` is a Go module and CLI application, which parses\n[GNU Make](https://www.gnu.org/software/make/)'s internal database and generates a\ngraph representing the relationships between the discovered Makefile targets.\n\n## Requirements\n\n* [GNU Make](https://www.gnu.org/software/make/)\n* Go version 1.21.x or later\n\n## Installation\n\nYou can install the CLI application using one of the following ways.\n\nIf you have cloned the repository you can build the CLI app using the provided\nMakefile target.\n\n``` shell\nmake build\n```\n\nThe resulting binary will be located in `bin/makefile-graph`.\n\nInstall the CLI application using `go install`.\n\n``` shell\ngo install github.com/dnaeon/makefile-graph/cmd/makefile-graph@latest\n```\n\nIn order to install the parser package and use it in your own Go code run the\nfollowing command within your Go module.\n\n``` shell\ngo get -v github.com/dnaeon/makefile-graph/pkg/parser\n```\n\n## Usage\n\nLet's use the following [example\nMakefile](https://www.gnu.org/software/make/manual/html_node/Simple-Makefile.html)\nfrom [GNU make's documentation](https://www.gnu.org/software/make/manual/make.html).\n\n``` makefile\nedit : main.o kbd.o command.o display.o \\\n       insert.o search.o files.o utils.o\n\tcc -o edit main.o kbd.o command.o display.o \\\n\t\t   insert.o search.o files.o utils.o\n\nmain.o : main.c defs.h\n\tcc -c main.c\nkbd.o : kbd.c defs.h command.h\n\tcc -c kbd.c\ncommand.o : command.c defs.h command.h\n\tcc -c command.c\ndisplay.o : display.c defs.h buffer.h\n\tcc -c display.c\ninsert.o : insert.c defs.h buffer.h\n\tcc -c insert.c\nsearch.o : search.c defs.h buffer.h\n\tcc -c search.c\nfiles.o : files.c defs.h buffer.h command.h\n\tcc -c files.c\nutils.o : utils.c defs.h\n\tcc -c utils.c\nclean :\n\trm edit main.o kbd.o command.o display.o \\\n\t   insert.o search.o files.o utils.o\n```\n\nYou can also find this example Makefile in the [examples](./examples/) directory\nof this repo.\n\nRunning the following command will generate the [Dot\nrepresentation](https://graphviz.org/doc/info/lang.html) for the Makefile\ntargets and their dependencies from our example Makefile.\n\n``` shell\nmakefile-graph --makefile examples/Makefile --direction TB\n```\n\nIn order to render the graph you can pipe it directly to the\n[dot command](https://graphviz.org/doc/info/command.html), e.g.\n\n``` makefile\nmakefile-graph --makefile examples/Makefile --direction TB | dot -Tsvg -o graph.svg\n```\n\nThis is what the graph looks like when we render it using `dot(1)`.\n\n![Example Makefile Graph](./images/image-1.svg)\n\nSometimes when rendering large graphs it may not be obvious at first glance what\nare the dependencies for a specific target. In order to help with such\nsituations `makefile-graph` supports a flag which allows you to highlight\nspecific targets and their dependencies.\n\nThe following command will highlight the `files.o` target along with it's\ndependencies.\n\n``` makefile\nmakefile-graph \\\n    --makefile examples/Makefile \\\n    --direction TB \\\n    --target files.o \\\n    --highlight \\\n    --highlight-color lightgreen\n```\n\nWhen we render the output from above command we will see this graph\nrepresentation.\n\n![Example Makefile Graph Highlighted](./images/image-2.svg)\n\nIf we want to focus on a specific target and it's dependencies only we can use\nthe following command, which will generate a graph only for the target and it's\ndependencies.\n\n``` makefile\nmakefile-graph \\\n    --makefile examples/Makefile \\\n    --direction TB \\\n    --target files.o \\\n    --related-only\n```\n\nThis is what the resulting graph looks like.\n\n![Example Makefile Graph Related Only](./images/image-3.svg)\n\nThe `--direction` option is used for specifying the [direction of graph\nlayout](https://graphviz.org/docs/attrs/rankdir/). You can set it to `TB`, `BT`,\n`LR` or `RL`.\n\nThe `--format` option is used for specifying the output format for the graph. By\ndefault it will produce the `dot` representation for the graph.\n\nYou can also view the [topological\norder](https://en.wikipedia.org/wiki/Topological_sorting) for a given target by\nsetting the format to `tsort`, e.g.\n\n``` makefile\nmakefile-graph \\\n    --makefile examples/Makefile \\\n    --target files.o \\\n    --related-only \\\n    --format tsort\n```\n\nRunning above command produces the following output, which represents the\ntopological order for the `files.o` target.\n\n``` text\ndefs.h\nbuffer.h\ncommand.h\nfiles.c\nfiles.o\n```\n\n## Tests\n\nRun the tests.\n\n``` shell\nmake test\n```\n\nRun test coverage.\n\n``` shell\nmake test-cover\n```\n\n## Contributing\n\n`makefile-graph` is hosted on\n[Github](https://github.com/dnaeon/makefile-graph). Please contribute by\nreporting issues, suggesting features or by sending patches using pull requests.\n\n## License\n\n`makefile-graph` is Open Source and licensed under the [BSD\nLicense](http://opensource.org/licenses/BSD-2-Clause).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnaeon%2Fmakefile-graph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdnaeon%2Fmakefile-graph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnaeon%2Fmakefile-graph/lists"}