Dylann Roof
Charleston shooter suspect Dylann Roof wearing pro-apartheid badgesFacebook

As America struggles to come to terms with racist massacre in Charleston, South Carolina, by 21-year-old Dylann Roof, indications of the ideas that drove his decision to calmly gun down nine black church-goers are beginning to emerge.

Roof's friends recalled the 21-year-old launching tirades against African Americans "taking over the world" and his desire to ignite "a civil war" and "planning something like that for six months".

A day after the massacre – labelled a "hate crime" by South Carolina police – a portrait of the "quiet, softly-spoken" Roof as a committed racist seething with hatred of black people is building from interviews with associates of the young man.

A Facebook search showed a picture of glowering Roof with badges of the Rhodesia (now Zimbabwe) and the South African apartheid flags pinned on his jacket.

Joseph Meek Jr, a childhood friend who saw Roof the morning of the shooting, said the pair had never discussed race growing up. But when they recently reconnected, Roof told him: "Blacks were taking over the world [and] someone needed to do something about it for the white race", he told the Associated Press.

"He said he wanted segregation between whites and blacks. I said: 'That's not the way it should be.' But he kept talking about it."

Roof's subsequent targeting of the historic Emanuel African Methodist Episcopal Church in Charleston was the final act of the embittered loner, the marginalised non-entity desperate to be noticed and the "disaffected white supremacist".

Charleston shooting dylann roof
The Turner Diaries advocates a US race war

This form of terror can be traced back to a particularly gruesome book, written in the style of a trashy airport novel. The Turner Diaries is about a thirtysomething all-American computer programmer, Earl Turner, who flips and embarks on a campaign of political assassination and racial murders, attempting to spark an Aryan revolution.

When Roof calmly told one of his victims who tried to talk him out of firing his weapon while he reloaded: "I have to do it. You rape our women, and you're taking over our country, and you have to go," he could have been channelling Earl Turner's white rage.

Written by Dr William Pierce, a former physics professor who became America's most influential Nazi, the book talks of secret cells waging acts of terror against multicultural communities, designed to trigger anarchy and create racial battle-lines. It culminates in the systematic extermination of all black people, Jews and "race traitors".

Pierce, who wrote under the pseudonym of Andrew Macdonald, has had several high-profile devotees; the Oklahoma bomber Timothy McVeigh, who killed 168 poeople at the Murrah Federal Building on 19 April 1995, is just one of a pack of American lone wolves to have read the book.

Pierce elucidated his vision in a broadcast by the far-right National Alliance in 1997. He said that, when he started writing The Turner Diaries in 1975, "I wanted to take all of the feminist agitators and propagandists and all of the race-mixing fanatics and all of the media bosses and bureaucrats and politicians who were collaborating with them, and I wanted to put them up against a wall, in batches of a thousand at a time, and machine-gun them.

"And I still want to do that. I am convinced that we will have to do that before we can get our civilisation back on track, and I look forward to the day."

From Breivik to Isis

The book was published in 1978, and its first band of adherents were a group known as The Order, who committed a spate of armed robberies and synagogue bombings in the early 1980s, even killing Jewish talk-show personality Alan Berg in Denver.

Oklahoma bombing
The devastated north side of the Alfred Murrah Federal Building in Oklahoma after Timothy McVeigh's attackGetty Images

Days before detonating his bomb in Oklahoma, McVeigh wrote a letter to his sister warning "something big is going to happen". A second letter contained clippings from The Turner Diaries.

When officers raided McVeigh's pick-up, they found a copy of the book, with several passages underlined, including sections providing graphic details of the terrorist attacks on the US capital and an airliner flying to Tel Aviv.

Since then we have seen Anders Breivik, whose attack on a Norwegian government building was almost a carbon copy of McVeigh's assault on the federal offices in Oklahoma City.

Reports in Sweden, published in the immediate aftermath of the attack, suggested Breivik was a member of a Nazi forum that frequently referenced The Turner Diaries; certainly, the fact that he attacked multiple targets and encouraged other extremist groups, including the EDL, to rise up in a wider campaign of hatred suggests Earl Turner's strategies had a profound effect.

The links between The Turner Diaries and 21st-century Islamist terror are more tangential but it is hard to dispute that the 9/11 attacks, a simultaneous orgy of violence that brought down planes and iconic buildings, bears the hallmarks of Pierce's blueprint for synchronised Armageddon.

The effective digital propaganda machine used but Isis and other Islamist terror groups has hijacked the ideology of the 'lone wolf' attack inspiring the Charlie Hebdo attacks in Paris, the shootings at the Ottawa war memorial and the street beheading of British soldier Lee Rigby.

Pierce's vile creed was initially spread via America's prison network and the secret meetings of its furtive race hate groups. By the time McVeigh struck, the means of propagation had shifted; the internet enabled xenophobes to email passages of the book to each other and post them on forums.

Now, of course, the focus of lone wolf terror has shifted again. Social media provides the circuitry for IS and other Islamist networks, which launch super-fast recruitment campaigns through the miracle of fibre optic broadband.

But the core message that zips back and forth across cyberspace is largely unchanged from that which spewed from The Turner Diaries; 40 years after Pierce began writing, his blueprint for a synchronised crusade of lone-wolf terror attacks continues to motivate the global hate brigade.

Lone wolf attacks are often difficult to detect and prevent, as assailants are able to hide their intentions right up to the day of attack, said Richard Cohen, president of the Southern Poverty Law Center.

"Unfortunately there are thousands of young men like [Roof] who are looking for an identity larger than themselves," Cohen said. "We've seen a drifting away from organised white supremacy and the prevalence of lone-wolf attacks."