  We derive a set of necessary and sufficient conditions for obtaining N=1
backgrounds of M-theory and type IIA strings in the presence of fluxes. Our
metrics are warped products of four-dimensional Minkowski space-time with a
curved internal manifold. We classify the different solutions for irreducible
internal manifolds as well as for manifolds with $S^1$ isometries by employing
the formalism of group structures and intrinsic torsion. We provide examples
within these various classes along with general techniques for their
construction. In particular, we generalize the Hitchin flow equations so that
one can explicitly build irreducible 7-manifolds with 4-form flux. We also show
how several of the examples found in the literature fit in our framework and
suggest possible generalizations.
