4

Makefiles are great for automating builds, installs and tests.

But, that is not the end of Make. I have used makefiles to do many tasks like cleaning up logs, keeping mirrored web pages and downloads, hooked them into crontabs and test suites...

Like scripting, I think there is a large scope of automating with Makefiles. Particularly when you have a chain of dependency based triggering required.

What different things have you done using Makefiles?
What are you planning to do more with them, on a rainy day perhaps.

nik
  • 7,100
  • 2
  • 25
  • 30

8 Answers8

6

My resume. LaTeX input, PDF output.

freiheit
  • 14,544
  • 1
  • 47
  • 69
4

I like Makefiles very much, especially for junior sysadmins.

Update the bind zonefile?

No problem: target has checkzone and checkconfig (out of memory) and only does sudo cp <editlocation> <reallocation>; git commit -a .... if everything seems basically fine...

Complex deployment?

No problem record it in a Makefile

I've pretty much used Makefiles anywhere where a script would have been appropriate also. Acutally I combine them, /usr/local/[s]bin/ is where the "single step" scripts are and the Makefile is in the working directory of the service in question.

Actually I have used them a lot more for the above reasons than for build systems - that is if you don't count latex and builds from upstream.

serverhorror
  • 6,478
  • 2
  • 25
  • 42
  • +1 for managing your DNS config files – ericslaw Jun 24 '09 at 17:37
  • actuall I don't :) - I've long ago abandoned bind because of the syntax. I'm using either tinydns or powerdns both of which I find a lot better than bind :) -- I just remembered it because typos in the zonefiles where a really common pitfall – serverhorror Jun 24 '09 at 17:40
2

Since we're pretty much a Ruby shop, I use Rake instead of Make. I've automated the following with Rake, and it shouldn't be too difficult to do these with Make:

EC2 node maintenance. Create and terminate instances.

Create a tarball and upload it to S3.

Deploy server configurations; mainly by calling rsync for directories and directly copying singleton files.

Convert Ruby DSL code into JSON data.

Handle software releases in a git repository (creating new branches, tags, etc).

jtimberman
  • 7,587
  • 2
  • 34
  • 42
1

sendmail.cf back in the 8.9 days if I recall.

Kyle
  • 1,859
  • 2
  • 17
  • 23
0

I used makefiles to handle XML transformation from DocBook sources. That way I could pipeline all of the commands and do "make pdf" or "make wordml" from the same source depending on who the intended audience was.

Alex
  • 6,603
  • 1
  • 24
  • 32
0

Nothing really. I find Makefile syntax to be horrible for most day-to-day tasks and I try to only interact with Makefiles when absolutely necessary. For system administration tasks, I don't see what they offer over a Bash or Python script. For building software, there are better build systems out there.

Kamil Kisiel
  • 12,184
  • 7
  • 48
  • 69
  • i don't see how a bash or python script would understand dependencies or if a file has actually been produced at an intermediate step without writing all these checks by hand – jermdemo Feb 01 '12 at 15:36
0

I've used it to "print all notes since last printing" in a random notes directory:

printflag: *.txt
    printcmd $?
    echo "printcmd $?" > $@

I echoed the command into the flag file so I could just ". printflag" to reprint the same set if need be;

to maintain DNS / DHCP / etc. :

edit hosts.dat # maintain single file with all relevant info
make           # work copies for visual check, diffs, etc., if needed
make install   # put into deploy-from-here location
make deploy    # push changed files to servers
make restart   # restart appropriate server processes here and there

(or just "edit hosts.dat; make restart" for the foolishly brave)

and as a quick and dirty way to generate manual scripts for procedures -- that is, just use pseudo targets and have the makefile commands echo something along the lines of "do step Foo" -- when you need something more sophisticated than tsort

hornlo
  • 16
  • 1
0

I know some people used to use Makefile script instead of init scripts. This effectively made them run paralelly and define dependencies between steps.

liori
  • 767
  • 3
  • 15