As Lowell says, short both the A and data pins:
The A pin isn't easy to short because it is recessed. I've done it more or less permanently by jamming some tinfoil into the camera side A pin's recess (it doesn't seem to matter if the camera thinks all my strictly manual lenses are A lenses....but I've not tried to use a K lens.)
Use the e-wheel to turn the aperture down as far as it'll go (probably F 1.2); if F - - appears in the viewfinder, the pins are not shorted (at least for the K100D.)
Now a manually stopped down m42 lens will meter correctly & the on-board flash will be automatically adjusted (at least for a K100D...I'm not sure the data pin must be shorted for all models & would appreciate info on that.)
Iowa Dave
PS at the present time, I've rigged things so my camera thinks all lenses are A type.; this seems to work ok.