  A Lagrangian density is provided, that allows to recover the Z4 evolution
system from an action principle. The resulting system is then strongly
hyperbolic when supplemented by gauge conditions like '1+log' or 'freezing
shift', suitable for numerical evolution. The physical constraint $Z_\mu = 0$
can be imposed just on the initial data. The corresponding canonical equations
are also provided. This opens the door to analogous results for other
numerical-relativity formalisms, like BSSN, that can be derived from Z4 by a
symmetry-breaking procedure. The harmonic formulation can be easily recovered
by a slight modification of the procedure. This provides a mechanism for
deriving both the field evolution equations and the gauge conditions from the
action principle, with a view on using symplectic integrators for a
constraint-preserving numerical evolution. The gauge sources corresponding to
the 'puncture gauge' conditions are identified in this context.
