In the recent Operation Pillar of Defense against Gaza, many Palestinian civillians were killed by Israeli air-strikes (the Palestines claim the number is as high as 158, while according to the IDF the correct number is 57 [source]). Israel has stated that they do everything in their control to minimize casualties (utilizing precision strikes, issuing preemptive warnings to Palestinian residents and aborting strikes because of civilian presence) and in any war it is inevitable that there will be civilian loss. What does halacha say about this topic; it seems clear that we can and may defend ourselves but does halacha specifically address the issue of civilians getting killed in a military operation?
See Rabbi Michael Broyde's excellent essay (entitled, in various versions, either "Only the Good Die Young" or "Judaism is Not a Suicide Pact!") here.
It is clear to me that the vast majority of contemporary poseqim agree with R. Shaul Yisraeli, and for that reason, even as there are numerous sefarim that deal with religious life in the army, not a single one of them discusses battlefield ethics halakhah le-ma`’aseh. Why? Because the Israeli army obeys international law, and that is all halakhah requires in war.
Rabbi Aaron Soloveichik zt"l (quoted by his son Rabbi Chaim Soloveichik in an mp3 about the halachas of drafting yeshiva students) similarly points to a Tanchuma -- "be aggressive to the Midianites and strike them, for they are aggressive to you -- from here the Sages deduced: one who is approaching to kill you, kill him first." Rabbi Soloveichik commented that the concept of self-defense for the individual civilian is found more plainly in Exodus, absolving someone for killing a thief who broke into their house (as we assume the thief may have been willing to lethally silence the homeowner). He said the Tanchuma is referring to actions on a national scale -- a country's army can go to war in self-defense, and does not have to perform a calculus regarding every single person on the battlefield, "am I certain that this person is a lethal threat to me right now?"
Rambam addresses this (Melachim 6:4): "And do not kill women or children".
This is talking about a case where the women and children are not part of the war - as opposed to cases where children and women are part of the war effort, for instance, by being soldiers themselves, or the nations which we are commanded to annihilate.
This is the practice in our wars today, also regarding "innocent" poeple who are in close proximity to soldiers so that killing the soldiers will result in their death as well (Rabbi Shmuel Elyahu, Rabbi Neria Guttel (see summary and footnotes), Rabbi S. Yisraeli - Amud Hyemini 16, Rabbi D. Lior - here and other various places)
here's what Rabbi Mordechai Eliyahu zt'l, the former chief rabbi of Israel, ruled on this (he was also known as a great kabalist and a miracle man):
All civilians living in Gaza are collectively guilty for Kassam attacks on Sderot, former Sephardi chief rabbi Mordechai Eliyahu has written in a letter to Prime Minister Ehud Olmert. Eliyahu ruled that there was absolutely no moral prohibition against the indiscriminate killing of civilians during a potential massive military offensive on Gaza aimed at stopping the rocket launchings. The letter, published in Olam Katan [Small World], a weekly pamphlet to be distributed in synagogues nationwide this Friday, cited the biblical story of the Shechem massacre (Genesis 34) and Maimonides' commentary (Laws of Kings 9, 14) on the story as proof texts for his legal decision. According to Jewish war ethics, wrote Eliyahu, an entire city holds collective responsibility for the immoral behavior of individuals. In Gaza, the entire populace is responsible because they do nothing to stop the firing of Kassam rockets. The former chief rabbi also said it was forbidden to risk the lives of Jews in Sderot or the lives of IDF soldiers for fear of injuring or killing Palestinian noncombatants living in Gaza. Eliyahu could not be reached for an interview. However, Eliyahu's son, Shmuel Eliyahu, who is chief rabbi of Safed, said his father opposed a ground troop incursion into Gaza that would endanger IDF soldiers. Rather, he advocated carpet bombing the general area from which the Kassams were launched, regardless of the price in Palestinian life. "If they don't stop after we kill 100, then we must kill a thousand," said Shmuel Eliyahu. "And if they do not stop after 1,000 then we must kill 10,000. If they still don't stop we must kill 100,000, even a million. Whatever it takes to make them stop." In the letter, Eliyahu quoted from Psalms. "I will pursue my enemies and apprehend them and I will not desist until I have eradicated them." Eliyahu wrote that "This is a message to all leaders of the Jewish people not to be compassionate with those who shoot [rockets] at civilians in their houses."