The brokers I have used give you the option of accounting for transaction on the basis of first-in-first-out (FIFO) or last-in-first-out (LIFO). I think (ask someone who really knows) you're free to decide later. There are issues, though, if you sell and and then repurchase just to realize the gain in particular tax year or if you take a short position to lock in gains but defer the taxes to a later year.
For me the brokers always give me a report that I used to file taxes. The few years where I had a complicated situation, I've used an accountant. Most of the time the statements from the brokers gives enough info to answer TurboTax's questions.