Walmart, Target and Kroger are opening their wallets to fend off Amazon.

They're raising minimum wages to retain and attract workers. Stores are being remodeled to encourage customers to add a few extra items to their baskets each time they visit — and convince them to return. All three have lowered their prices.

The companies are optimizing stores and warehouses for speedy curbside pickups and grocery deliveries. Walmart is plowing cash into updating its website.

Related: Why some retailers are winning and some are losing

They're also going on a buying spree.

Target bought grocery startup Shipt for $550 million last year, and Walmart bought e-commerce platform Jet.com for $3 billion in 2016.

On Wednesday, Kroger said it was scooping up meal-kit company Home Chef in a deal worth up to $700 million.

Last week, the grocery chain paid $250 million for a stake in British online supermarket Ocado to help manage automated warehouses and leverage its digital technology in the United States.

Growing pains

The moves signal how far brick-and-mortar grocers and retailers today are reaching beyond their stores to fight off Amazon and adapt to online shopping.

"They are relying on acquisitions, which are proving to be very expensive, in order to catch up quickly or risk completely being outrun," said Tom Gehani, director of client strategy and research at consulting firm Gartner L2.

Renovations, raises, supply chain optimizations, and acquisitions and demonstrate the high costs of slogging ahead with a long-term plan — one often at odds with Wall Street's impatience.

Related: Best Buy's strong sales leave Wall Street wanting more

Spending a ton of cash to ramp up digital operations, while slashing prices, has cut into profit margins at Walmart, Target and Kroger.

"Managing margins for an online business is very difficult," said Cowen analyst Oliver Chen. "It's a journey."

Walmart (WMT) is down 16% this year and Kroger (KR) has lost 10%. Target (TGT) is up 9%, but shares fell sharply after it missed profit expectations.

Related: Target's shift to digital is painful

Playing the long game

Despite Wall Street's hesitancy about the companies' near-term prospects, Walmart, Target and Kroger are plowing ahead, determined to stem the tide of fleeing customers by adapting to the digital age and changing consumer habits.

For example, Target CEO Brian Cornell said last year that the company would embark on a three-year, $7 billion effort to reposition it for the future. The strategy includes opening smaller stores in urban markets and rolling out more private label brands.

"We're investing in our business with a long-term view of years and decades, not months and quarters," he said.

Walmart is also rapidly searching for new growth opportunities.

The company admitted that Jet has failed to resonate with shoppers in the middle of the country, but it has acquired niche brands such as Bonobos, Modcloth. Walmart paid $16 billion last month for India's Flipkart, its largest deal ever.

Kroger hopes the Ocado deal "will allow [it] to react to how the customer may want to change their shopping habits over time in a big way," chief financial officer John Schlotman said at a conference last week. Many Kroger customers have defected to Whole Foods after Amazon lowered prices at Whole Foods.

Pick up or delivery?

All three companies hope to use their massive network of physical stores to their advantage in their battle against Amazon. They are all focusing efforts on so-called click-and-collect, where shoppers order items off their computers or phones and then drive to pick them up outside stores.

Walmart believes that its 4,760 US stores within 10 miles of 90% of Americans will allow the retailer to transition its real estate into shopping centers that can easily fulfill online orders, too.

It will have 2,100 pickup locations by the end of the year. Target plans to have 1,000 pickup spots by the end of 2018 for clothes, home appliances and groceries. And Kroger said in March that it has more than 1,000 collection sites. Expanding pickup can help these companies keep down expensive shipping costs.

"They need to use their core assets to drive relevance and connection with shoppers," said Laura Kennedy, vice president of retail insights at Kantar Consulting. "Whether you are an apparel retailer, Walmart, or Kroger, Amazon has changed shoppers' perception of convenience and speed."

For customers who don't want to pick up items at stores, the companies are ramping up their effort to deliver items quickly from stores to customers' doors — despite the limited profitability shipping goods to your home.

Walmart will have grocery delivery available at around 800 stores by the end of the year, and Target will have same-day delivery for its stuff at close to all of its 1,822 US locations by then.

Investing in groceries is crucial for Walmart and Kroger to stay ahead, but they're fighting to keep control of an already low-margin business. "Amazon has caused them to chase the wrong end of the profit spectrum," Gehani said.

Walmart and Target have shown they're capable of making the shift to digital. Walmart's online sales grew 33% and Target's jumped 28% last quarter from a year prior. Store upgrades are also helping: Same-store sales grew 2.1% at Walmart and 3% at Target last quarter.

"I like what Target's doing," Cowen analyst Chen said. "It takes a little time."