In principle you earn miles, just as with any corporate discount program. However, keep in mind that being able to earn miles in general depends on the fare class that a given ticket is booked in. Some airlines have deep-discount fare classes that don't earn miles* - whether they're booked by the military, a corporation with a discount contract, or an individual. You have to be aware of this possibility and check out each ticket on a case-by-case basis, or at least check out the program in question for this sort of rule.
__________________________
*Examples from one of the programs you mentioned: AA Q fares on trans-Atlantic routes, O fares on most overseas routes