Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language Make

Date:04/20/05
Author:Andrew Dunstan
URL:n/a
Comments:3
Info:n/a
Score: (2.88 in 8 votes)
make is technically a tool for building applications, but it's 
amazing what a pre-processor and recursion can do for you.

#
#
# quick effort at 99 bottles program using gnu make
#
# the file must be called makefile.bottles
#
# Author: Andrew Dunstan (andrew.dunstan@its.maynick.com.au)
#
 
default:
        $(MAKE) -f makefile.bottles BOTTLES=99 bottles
 
.SILENT:
 
bottles:
        echo $(BOTTLES) bottles of beer on the wall
        echo $(BOTTLES) of beer
        echo Take one down and pass it around
ifeq ($(BOTTLES),0)
        echo No bottles of beer on the wall
else
        echo `expr $(BOTTLES) - 1` bottles of beer on the wall
        echo
        $(MAKE) -f makefile.bottles BOTTLES=`expr $(BOTTLES) - 1`  bottles
endif

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
GNU version, no shell commandswrtlprnft07/30/100
make syntax,portable,simple,dependenciesrahul03/17/080

Comments

>>  Rune Berge said on 06/20/05 16:28:00

Rune Berge Yes, but it's not completely fair to compare it to programs that don't cheat by not handling the singular case of bottles.

>>  Phil Ashby said on 11/21/05 15:48:40

Phil Ashby This was the original GNU make version that annoyed me by using backticks and expr to do the math, hence my pure GNU Make version.. however I think there is a better way... (since I only got one vote for Bad as Hell :)

>>  Krzysztof Nosek said on 03/24/06 10:36:25

Krzysztof Nosek Well, using external math or even simulating math via chains of conditionals is unnecessary. Naming file specifically or recurring the call of make also... Please have a look on an alternate version at

http://www.99-bottles-of-beer.net/language-gnu-make-1097.html

Download Source | Write Comment

Add Comment

Please provide a value for the fields Name, Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.

Please don't post large portions of code here! Use the form to submit new examples or updates instead!

Name:

eMail:

URL:

Security Code:
  
Comment: