Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

8 Answers 8

My resume. LaTeX input, PDF output.

share|improve this answer

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.

share|improve this answer
    
+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 –  Server Horror Jun 24 '09 at 17:40

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).

share|improve this answer
    
+1 for rake, it's easier to use than make and you have the power of a scripting language –  chmeee Jun 29 '09 at 8:49

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

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer
    
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 1 '12 at 15:36

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

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.