After reading this overly long tome: What Programmers Want I thought a bit about programmer motivation.
I've been a working programmer for 31 years now, in all sorts of environments from my own startup, big companies to small, even Apple for a bit when they sucked, from defense to healthcare to currently travel, consulting to gaming; I have a pretty good idea of what makes good programmers tick.
Good programmers like challenges. Good programmers hate stupid.
There are lots of things in between that may or may not motivate some people more than others. Everyone likes money but it only rarely affects the quality of work. People like praise but the best programmers prefer the internal feeling of accomplishment. Programmers like good tools and reasonable process and great work environments and time off and learning new stuff and supportive managers; but the real motivator is writing great code, building cool products, and solving nasty problems. The best programmers are always self-motivated: just give them opportunity to rock and stay out of the way.
No two programmers are the same, trying to force sameness in tools or process or how they write code or fill their time with useless meetings devoted to enforcing the corporate standards only result in wasting a good programmer's motivation. Demanding impossible deadlines, ridiculous overtime and grinding people into the ground is a recipe for getting nothing out of a good programmer.
Now I am not advocating chaos in the workplace but whatever organization exists needs to be flexible and supportive of the team and work with both the individualistic needs of the programmers as well as appeal to their desire to produce great products or code or whatever the team produces. It's a tough bunch to manage but it can be done. I've seen it, I've done it on occasion (but always as a leader who also codes), and I know it can be done.
Programmers dig solving problems, even insurmountable ones. Programmers also complain a lot and can be incredibly lazy which is a good thing as it forces them to find ways to make things easier. Fill their time with worthless meetings and silly process and they will lose motivation. Programmers want to program, and anything that takes away from this is probably not worth doing.
I've always admired the Agile Manifesto because it makes sense to virtually every programmer I know. Many of them also hate how these sensible ideas turned into cumbersome processes. If your process makes programmers more likely to work better then great; if it just gets in the way then it's stupid to do it.
An app we worked on this year took 9 weeks from start to finish and turned out really well (debuted #1 in its category in the App Store) but we were forced to follow an experimental Scrumban process. The team gamely put up with the requirements and the irritating tool but we routed around it and mostly kept working efficiently in our own "process". So far the experiment hasn't returned so maybe it was obvious it didn't provide any benefits.
The requirements were vague, the deadline was short, the challenges were many but those of us on the team had fun, didn't work any overtime, and produced a high quality app. All the celebrations and cake (in the shape of the app icon) and internal bragging weren't that big of a deal. We got to write a cool app and that was the real motivator. Fortunately the stupid didn't get in the way.
I've seen the alternative as well. I worked on a project in Mexico that crammed 40 people into a single room on a death march project where we were alternatively yelled at for not meeting arbitrary deadlines and then for not including impossible changing requirements. People tried to create miracles but eventually the horrible conditions just made people give up and the project thankfully tanked. Another project I saw from outside required each of 30 programmers to write only their code and never see anyone's else's (because the managers thought they would steal the code) which resulted in a huge mess with 30 separate slices of application glued together. That stupidity cost the company a 600 million dollar market and they went out of business. Even the Copland disaster at Apple (during my brief tenure) was a major cluster of stupidity which did little to motivate the programmers there.
Steve Jobs was an irritating SOB but he understood how to motivate people to do amazing things. That same Apple changed from the sad place I worked to an amazing company in such a short period of time. Take good people and give them the opportunity to do the incredible.
So no matter what you do the best programmers will motivate themselves if you give them challenging code to write or problems to solve, and keep the stupid as far away as you can. Give them a work environment that makes this possible and consistent. Manage them with this understanding. Rewards are nice but the ultimate motivator is still opportunity.
Just keep the stupid away.