General procedure of gauge fixing based on BRS invariance principle