Detail textures contain the high frequency components from the texture image. The high frequency information is extracted, not generated from scratch. So you must start with a high resolution version of the desired texture.
The first step is to choose the size of the detail texture, and select a region of the detailed image that contains high frequency details representative of the entire image. Now extract the high frequency components of that region. One technique is to remove the high frequency components from one copy of the region by blurring it. This can be done with an image processing application, or you can use gluScaleImage() to scale the image down, then up again. For more sophisticated filtering, you can use a blurring convolution kernel, assuming your implementation of OpenGL supports the imaging subset. Enable convolution, set the appropriate blurring filter kernel and use glCopyPixels() to process the image.
Now subtract the blurred image from the unprocessed one. You can do this using the subtractive blend mode or with the accumulation buffer. The result will be a signed image that contains the high frequency components of the image. You will have to be careful to add a biasing value before subtracting (or before returning the image from the accumulation buffer) to avoid negative pixel values, since the frame buffer will clamp them. If you have the imaging subset, you can use the minmax feature to find the range of pixel values in both the sharp and blurry parts of the detail texture image before you subtract them. You can then use the results to find the proper biasing term.