It appears that the best way to produce oxygen on Mars is using reverse fuel cells to extract oxygen from the co2 in the atmosphere. However any machine we sent there would eventually wear out. Does Mars have the necessary elements to allow us to create the fuel cells in situ?
In short: yes, but you would have to wait inordinately long for that.
Sending parts to be assembled on Mars into replacement machines is a no-brainer, and requires either an advanced robot or (much more likely) a small human base. Doesn't save much mass over sending the entire replacement electrochemical rig except one no longer has to engineer in extra stiffness to cope with end-of-launch maximum acceleration.
Sending raw materials and basic items (FPGAs for electronics, metal powder and 3D-printer-ready plastics for everything else) to be manufactured into parts and then assembled. A great solution that gets rid of this nasty Earth-to-Mars delivery lag, and allows one to fabricate nearly anything that has malfunctioned. Still requires an unwieldy set of machines, and a fairly large Martian base for the investment to be economically sensible.
Producing raw materials in situ. Not going to happen soon, since you'd need to replicate a goodly chunk of Earth-wise mining, metal-making and chemical industries in a hostile Martian environment. Very capital-intensive, not confined to one base (suitable deposits will most likely be spread across Mars), and hence energy-hungry (no cheap travel on Mars has been invented yet).
Note: on resources please also start reading linked articles from the Wikipedia. We simply don't know where the exploitable deposits are.