Well, a quick and dirty way you can do it is by using sprite animations.
e.g. For every free spot on the hill where you can build, place a sprite which is either set to invisible or has a clear animation so you can't see it. Each sprite also has other animations of different buildings which aren't shown at start. Now set conditions like,
If player selects sprite
+ player clicks pink button
+ sprite is clear
+ Gold > 100
- -> set sprite animation to "Barracks" + Subtract 100 from gold
(So if we select a clear sprite and click the "build barracks" button, and have enough gold, we build a barracks)
If player selects sprite
+ player clicks blue button
+ sprite animation is "Barracks"
+ Gold > 200
+ Lumber > 100
--> set sprite animation to "BarracksUpgrade1" + subtract 200 from gold + subtract 100 from lumber
(So if we select a "barracks" sprite and click the upgrade button, and we have enough resources, we upgrade the barracks)
For resource generation, you can use variables like e.g. give Barracks a variable Money and do something like this:
Variable Money>0 --> subtract 1 from Money (you can also use delta time)
Variable Money=0 --> set Money to 100 + Add 5 to gold
(This means each barracks will generate 5 gold every short interval)
Anyway, that's one way to do it. Probably could use some finesse and tuning to suit your needs as they come up.