According to Hollywood legend, the 1992 film El Mariachi was made for just $7,000. The action movie had no stars and was shot on videotape, but it grossed $2m in US movie theatres and launched the career of its director, Robert Rodriguez. That should have made it an unqualified success story, one that would shame the usually profligate studios that spend hundreds of millions on flops like Waterworld, right?

Well, not exactly. Once Columbia bought the film from Rodriguez, the studio spent another $200,000 or so transferring the print to film, remixing the sound, and doing other post-production work. Then Columbia spent millions advertising the film and making prints to send to theatres. So the studio would have been lucky to break even on this $7,000 picture. For the sake of comparison, when Rodriguez remade the movie a couple of years later as Desperado, with then-rising star Antonio Banderas, he spent $7m - a thousand times as much - and earned back $25m at the US box office.

Welcome to the absurd world of Hollywood finance, where even huge hits can prove to be unprofitable flops, where expensive is often more cost-efficient than cheap, where final spending and earnings totals are never calculated but keep rolling over for ever, where no one knows what anything costs because every price is negotiable, and where people would rather reveal the most embarrassing details of their sex lives than discuss how much they pay or are being paid.

And yet, this summer, the content of Hollywood's cash registers has been more interesting than the content of its highly forgettable blockbusters. Virtually every weekend since the beginning of May, a new movie has opened to record-breaking or near-record-breaking grosses; three of the four biggest openings ever are this summer's Planet of the Apes ($68.5m), The Mummy Returns ($68.1m), and Rush Hour 2 ($66.8m). But most of these movies saw business drop by more than 50% in each subsequent week due to poor word of mouth. When all the smoke clears, the summer's biggest success stories may be relative cheapies The Fast and the Furious and Legally Blonde, though neither of them will earn nearly as much as the expensive, effects-driven action behemoths.

To ask, "How much does it cost to make a movie?", "Where does that money go?" and "How does a movie recoup its cost?" is to jump down the rabbit-hole. Nobody knows the answers to these questions, in part because there are so many variables involved (Big-budget studio pic or low-budget indie? Stars or no stars? Contemporary or period piece? Special effects or not?) and in part because no one wants to compromise their bargaining position. The studio doesn't want it to get out that it paid, say, George Clooney $15m for his last movie, lest Denzel Washington ask for the same amount. Similarly, Renée Zellweger may not want people to know that she did her last role for $4m, lest the studios try to hold her to that price again. And through the miracle of Hollywood accounting, a studio may fairly claim that a huge hit hasn't actually turned a profit, lest they be forced to pay the stars, director or writers the percentage of the earnings to which they may be contractually entitled.

Still, there are some guidelines for answering these questions. Producers do have a pretty good idea of what a movie will cost. The money will have to come from somewhere, whether it's the studio, the bank, the investors or the insurance company. The unions whose members make up the entirety of a film production crew do at least have specific minimum wage rates, though they may well charge more. And once a movie is released, there are some rules of thumb as to how much the producers will make back, and from which sources (American box office, foreign box office, home video and television) over the film's lifetime.

According to the Motion Picture Association of America (MPAA), the average negative cost of producing a Hollywood studio film (a term that includes all production, studio overheads and financing costs up to the creation of the actual negative of the movie, but before the striking of "show prints") was $54.8m in 2000. That's up 6.5% from 1999's figure of $51.5m; but for all of Hollywood's annual handwringing that costs are spiralling out of control, they've actually plateaued over the past four years, hovering between those two figures. The negative cost for movies made by the quasi-independents - the studio-affiliated low-budget art-movie arms like Miramax and Sony Pictures Classics - has remained between $18.4m and $21.8m over the past three years.

That figure does not include the cost of making prints and advertising the movie. The MPAA says that the studios are spending an average of $27.3m per movie on "P&A" costs - $3.3m on prints and $24m on advertising. For the quasi-indie affiliates, that P&A cost is only about $10.1m, with $1.2m spent on prints and $8.9m on advertising. So really, the total cost of putting a movie in theatres in the US is about $82.1m for big-budget movies and $31.9m for lower-budget art films.

Of course, these are just the averages. Titanic, famously, had a negative cost of $200m. Pearl Harbor's negative cost was reported at $135m, plus untold millions more in P&A costs for the thousands of prints made and the endless marketing campaign. (The premiere alone, in which journalists and stars were flown to an aircraft carrier in Hawaii and treated to a display of fireworks and an air show by US Navy pilots, supposedly cost $5m.)

As the El Mariachi/Desperado example suggests: "You can make any movie for any amount of money." These are the words of Alan Blomquist, line producer on Miramax productions Chocolat and The Cider House Rules. "The question is, how big do you want to compromise?" Every detail of a production can cost whatever you are willing to spend, says Blomquist. "You can get a caterer for $8 a plate or $20 a plate, serving out of the back of a truck or on linens and china."

To figure out how much to spend turning a script or an idea into a movie, the studios employ accountants ($2,000 to $5,000 a week) to figure out what a given movie will cost and whether it's worth making. That rough-estimate process can take about a week. There's a piece of software called Movie Magic that makes it much easier to plug in the variables and get a rough idea of what a film will cost to produce, but that's not full, accurate accounting. The person who figures out every penny of what's being spent is a line producer, like Blomquist, and his or her job may take months, as costs are continually revised during the shoot.

Production costs are generally divided into "above the line" and "below the line". Above the line is the "talent" - the actors, the writer, the director, the producers. Below the line is everything else - the crew, the sets, the costumes, food, transport and anything else needed to shoot the movie, plus post-production costs: editing, sound, music, special effects. A good rule of thumb is that below-the-line costs will make up one-half to two-thirds of the budget.

The biggest variable above the line, of course, is the cast. An A-list leading man like Harrison Ford or Tom Cruise will cost you $25m, plus a percentage of the gross. An A-list leading lady (Meg Ryan, Sigourney Weaver) will cost you $15m. (Julia Roberts may get $8-10m more than that.) So if you want to make a big-budget romance with big stars, you've already spent $40m before you've shot a frame of film. On the other hand, if you want to cast someone from Dawson's Creek, or another teen star (Freddie Prinze Jr, say, or Katie Holmes), you may spend only $1m or $2m for each lead. Then you have to cast all the supporting actors, which may cost a million or two more.

Stars raise the cost of the movie not just by their own salaries but also by the salaries of all the people who attend them. A star's make-up person may earn three to five times what a regular make-up person earns. Also, a star may come with a caterer, a personal trainer, an acting coach, a drug counsellor, etc. (On the other hand, says Blomquist, Michael Caine "comes with only a toothbrush".)

Assuming that their agents don't negotiate higher fees for them, actors with speaking parts are guaranteed by Screen Actors Guild rules to earn at least $617 per day on big-budget films and $466 per day on low-budget (that is, less than $2m) films. Extras earn $100 per day. Of course, there are price breaks if actors are hired by the week, and there are all kinds of other rules and exceptions. Rates for other unionised film workers vary similarly. Directors are guaranteed by their union to earn $12,106 per week on features budgeted over $1.5m, or $8,647 on features budgeted between $500,000 and $1.5m, and $7,608 on features budgeted under $500,000. A director is guaranteed at least eight weeks of work on the lowest-budgeted films and 10 weeks on all others. So while a big budget director will earn at least $121,000, top directors earn north of $3m, plus a percentage. Producers, too, take a fee, which may be as much as $1m per picture.

The writer, often considered the lowest form of life in Hollywood, still gets paid above the line. Although only half of Hollywood's writers are working at any given time, those whose movies do get made earn an average of $213,000 per year. The Writers Guild of America reports that the highest paid 25% of its membership earns more than $575,000 per year. A top screenwriter may earn as much as $2m per movie, plus a percentage, while a writer called in to doctor the script can earn six figures.

As for below the line costs, "shooting days and the art department are the two big areas of expense", says Stuart Cornfeld, producer of the upcoming Ben Stiller comedy Zoolander. That is, the big variables are the number of days or weeks producers have to pay workers or rent cameras and other gear; and the production design - sets, costumes, effects shots and anything else that needs to be created from scratch. Recreating the past for a period piece will be more costly and time-consuming than mounting a contemporary tale, or as Cornfeld puts it, "Barry Lyndon is going to cost more than Mean Streets." Labour costs depend, first of all, on where the film is shot. Shooting in Canada can cost 30% less in labour than shooting in Los Angeles, though the US Congress is currently considering a bill meant to stem such "runaway production" by giving tax credits to films and TV shows shot entirely in the US.

Below-the-line workers are almost always members of the International Alliance of Theatrical Stage Employees (IATSE), which has about two dozen chapters in the Los Angeles area alone, divided according to task. There are separate chapters for costumers and costume designers, for illustrators and scenic artists and art directors and set designers, for painters and plumbers and plasterers, for sound technicians and laboratory technicians, for cinematographers and editors, even for studio teachers (tutors and social workers for kids), publicists and emergency medics. Each chapter sets its own daily and weekly rates for workers.

Make-up artists and hair stylists earn at least $42 per hour and work 54-hour weeks. The number of cosmeticians on a shoot depends on the number of stars and extras and the number of special-effects requirements. To turn Jim Carrey and his co-stars into pointy-snouted Dr Seuss characters in The Grinch took 30 make-up artists, which is at the high end. A set designer must earn at least $1,258 per week, while a senior illustrator (who draws the storyboards) must earn $1,752 per week. Ordinarily, a film may use one or two such illustrators, though more elaborately designed pictures, like the Batman films, used as many as 20.

Art directors and production designers make at least $2,503 per five-day week, while assistant art directors make $1,873 per week. There are usually about three such people on a film shoot. Among electrical workers, gaffers (chief lighting technicians) make $31 per hour, while best boys (assistant chief lighting technicians) make $28 per hour. Other lighting technicians make $27 per hour. A shoot may require 10 electricians on the scene being shot and another 10 to 20 to rig lights for scenes yet to be shot. A film crew will also include three to five emergency medical personnel - say, a paramedic, a registered nurse and a doctor. Members of the first-aid unit earn between $12 and $26 per hour for an eight-hour day. Once principal photography is complete, there is a picture editor, who earns at least $2,234 per 54-hour week, and a sound editor, who earns $1,628 for a 48.6-hour week. (They're editors, so they've got it all timed to the nearest 24th of a second.)

Then there's the cost of actually financing the production. In addition to the 1.3% to 1.5% of the budget spent on general insurance, independent and other bank-financed features must buy a completion bond, an insurance policy whose cost is 3% to 5% of the budget. This ensures that, if the film-makers run out of money, the shoot will still be completed. Studios that finance their movies out of pocket don't buy a completion bond but set aside 10% of the budget as a contingency.

According to the MPAA, American theatres took in $7.66bn in 2000, up 2.9% from the year before. And that was a slow-growth year; American box-office receipts have risen an average of 5.3% every year since 1992. But that's only the beginning of the story. Not all that money goes back into the studios' pockets; the theatres get some, and in many cases, so does the above-the-line talent. Plus, there are all the ancillary sources of revenue, worldwide box office, home video, TV and licensing (movie-related products like toys, soundtrack albums and theme-park rides). US box-office receipts now account for well under half of what a movie will earn over the years. "Ancillaries is where you really see revenues," says Don Murphy, producer of Natural Born Killers. "Box office is the loss leader for the life of the film."

The box-office figures that appear in the newspapers after every weekend of moviegoing are misleading. Studios and theatres split revenues on a sliding scale that favours the studios during the earliest weeks of release and comes to favour the theatres over the long run. A studio that sees a $50m opening weekend on a movie may get 70% of that, sliding down to less than half of the week's take in later weeks. A situation like the one this summer, with a new movie opening strongly each week and then plummeting by more than 50% each week thereafter, is very good for the studios but bad for the exhibitors. Still, a rule of thumb is that the studio will earn about 50% of a movie's final US box-office take.

Movies generally gross as much in all other countries combined as they do in America. The studios get to keep as much as 75% of the worldwide gross. Then there are home video sales and rentals, which should be worth at least 20% of the US box-office gross to the studio. And then there are the television rights, which are worth tens of millions of dollars, again depending on how successful the film was in theatres.

Murphy uses as an example this summer's Cats & Dogs. "That thing supposedly cost $70m. No one ever tells you the right number. Then there's another number, P&A. It could easily have been $20m. So the movie cost $90m, total. Now, it's made $100m, but only $50m of that goes to Warner Bros. Fuck me, it just lost $40m! But worldwide, you should do at least as well as in America. And those theatres take a 25% fee. That's $75m for you, so now you're at plus $35m. Video profits could be $20m. Now you're at $55m. Plus cable TV; if you can't get $15m, somebody's fucking you up. So Cats & Dogs could make a profit of $70m. This is over its entire lifetime, after it's played in airplanes in Zimbabwe."

Even that's not the whole story. "Where you really get fucked is if you have a gross participant," Murphy says. This is when an above-the-line person makes a deal for a percentage of the studio's take from each ancillary deal. "The classic example was [1987's] Ishtar. For every dollar that comes back today on Ishtar, 10 cents is going to Warren Beatty, 10 cents is going to Dustin Hoffman, and five cents is going to Elaine May. Some of the money that you need desperately to break even is going to the profit participants. That's why Ishtar probably still hasn't covered its nut."

Of course, given what Murphy calls the "Martian accounting" practices of studios, some profit participants may never be paid. Studios frequently perform all kinds of tricks frowned upon by standard- practice accountants, like charging themselves for overheads and endlessly deferring the profits from a film, in order to avoid such payments. The famous case is Winston Groom, author of the novel Forrest Gump, who complained that he hadn't seen a dime from the worldwide hit movie version made by Paramount. But given Paramount's Martian accounting, the film was still considered a loss, so he wasn't entitled to any receipts.

Moreover, says Murphy, Groom and other profit participants have no right to complain if they don't see any profits because they sign a contract agreeing to abide by the studios' accounting rules. "According to Martian accounting, it is really possible that Coming to America still has not made money, especially with 10 cents of every dollar going to Eddie Murphy and five cents going to John Landis."

In extreme cases, having a big hit can even bankrupt a studio. In the early 1990s, Orion had huge back-to-back successes with Dances with Wolves and The Silence of the Lambs, and Carolco struck gold with Total Recall and Terminator 2. But the worldwide profit from those hits was too slow in returning to save the studios from bankruptcy. "That's why Carolco and Orion went out of business," Murphy says. "The cash flow can take years."

Only the studios - and the Inland Revenue Service - know for sure what they spend and what they earn on individual pictures so, unless they authorise the release of that information, educated guesses are the best way forward. Even someone like Murphy, a genuine expert on Hollywood finances, remains largely in the dark. "I don't even know what they really spent on my own movies," he says.

My Best Friend's balance sheet

We asked Natural Born Killers producer Don Murphy to help us estimate the costs on a typical big-budget Hollywood hit at the end of its revenue-generating cycle. We chose the 1997 Julia Roberts vehicle My Best Friend's Wedding.

Costs

Julia Roberts $20m

Rupert Everett 'That's being generous' $1m

Cameron Diaz 'This was before There's Something About Mary' $2m

Dermot Mulroney 'The guy with a million names? If he's lucky' $1m

All other actors $1m

Director PJ Hogan 'Let's say he's got a really good agent' $3m

Writer Ron Bass 'He's a top guy' $2m

Producers $1m

Labour, materials, post-production $20m

Prints and advertising (P&A) $22m

Total cost $73m

Grosses

(Estimated total followed by Tri-Star Pictures' share)

US box office $126.8m $63.4m

World box office $148.2m $111.2m

Home video sales & rentals $58.5m

TV rebroadcast rights $15.0m

Total gross $248.1m

Profit $175.1m*

* This doesn't take into account studio accounting costs or any possible profit participation for Julia Roberts and Ron Bass.