In this work we report on the optimization of the conversion efficiency of the harmonic generation process, by adaptive control of the wavefront of sub-10-fs light pulses, obtained by using a deformable mirror and a genetic algorithm. Sub-10-fs, 0.2-mJ energy light pulses, generated by the hollow-fiber compression technique, were focused in the gas target (argon or neon) by a 250-mm focal-length mirror. Pulse wavefront correction has been achieved by using a deformable mirror (DM) controlled by 37 actuators distributed on a honeycomb pattern of 15 mm diameter. The harmonic radiation was observed by a soft-X-ray spectrometer, with double output: time-integrated high-resolution bidimensional focal-plane image and real-time (1 kHz) intensity of a suitable spectral region. This latter signal was used as fitness parameter for the genetic algorithm; an initial population of DM configurations was initialized with random values of the actuator signals. A new generation of DM configurations is derived from ordering, selection and transformation of previous generation, up to the convergence to the fittest individual. Strong enhancement of the harmonic conversion efficiency of about one order of magnitude, as well as a significant extension of the harmonic spectrum is evident. The initial and optimal wavefronts of the fundamental beam were measured both in real time with an Hartmann sensor and off-line using a ZYGO interferometer. Using the measured beam wavefront were calculated the spatial characteristics of the fundamental beam.