Like everyone else said, usually these can be used synonymously.
Only in rare cases, the translation of English "to do" will demand usage of one rather than the other.
The difference appears to be that "machen" tends to imply an action that brings something into existence (cf. "maker" in English) or changes it somehow (usually physical, but also in a figurative sense):
- Ich mache mir gerade etwas zu essen. (I'm making myself something to eat.)
- Ich mache Dich zur Schnecke! (I'll kick your a**!)
- Du machst mir Angst! (You're frightening me!)
- Was machst Du beruflich? (What do you do for a living?)
[These don't usually work with "tun".]
"Tun" either tends to focus much more on the action itself rather that its effect, or is a kind of execution of an intention, order etc.
- Tu es einfach! (Just do it!) [also works with "machen"]
- Was tust Du da? (What are you doing?) [also works with "machen"]
- Jemandem etwas antun. (To do something to someone. (in this construction usually something horrible)) [never works with "machen]
ItNOTE: We're talking tendency here, i.e. it is one of these nuance things that are so hard for non-native speakers.