Hundreds of bright blue T-shirts with the slogan "smile" pass down a row of tables where they are inspected, folded, bagged and tagged. From here they will embark on an arduous journey of more than 600 miles.

A truck will haul them from Kampala, Uganda's capital, across Kenya to the port of Mombasa. A week later they will be loaded onto a ship for Hamburg, Germany. There they will be sold for $11 each by Bonprix, part of a family-owned mail-order firm with sales of $13 billion a year.

These shirts began as cotton bolls on the equator in the far west of Uganda. Their odyssey reveals much about Africa's manufacturing potential. By following in the footsteps of China and Bangladesh, which began their industrial revolutions with textiles, Africa could in theory create millions of jobs. But it will not be easy.

Several African countries have tried in the past to become tailors and cloth-makers to the world. Nigeria's cities of Kaduna and Kano were once home to textile mills that employed 350,000 people. Yet these factories are now rusting, and employ perhaps a tenth of that number.

This mirrors a wider trend. In 1990 African countries accounted for about 9 percent of the developing world's manufacturing output. By 2014 that share had slumped to 4 percent.

As the world's labor-intensive jobs left the rich world for countries with lower wages, Africa lost out to Asia because of bad governance, political instability and poor infrastructure. Another shift of similar proportions now seems in the offing as China grows richer. But there are some signs that, this time, Africa might catch the wave of industrialization.

In the shade of a large tree just a few kilometers from Uganda's border with the Democratic Republic of Congo, a group of farmers have gathered to discuss their bumper cotton crop and the obstacles they had to overcome to grow it. Elephants sometimes trample the neat rows of cotton, they complain. They plant barriers of chili peppers and keep beehives to keep the jumbos out.

Markets are even less predictable. All the farmers at this meeting are tenants who rent small plots. "When the price of cotton goes up, so does the rent we pay," said one woman.

African farmers, who use ox-drawn plows and pick cotton by hand, are competing against vast mechanized farms in Texas that still receive subsidies. About 80 percent of Uganda's cotton is exported, but because its fields are far inland and the cotton has to travel over rutted roads past rapacious officials, the price these farmers receive is only 60-70% of the international benchmark for delivery to Asia, a lower share than goes to U.S. farmers.

Yet the Ugandan farmers' income is rising because of two changes further along the chain between shrub and shirt. One occurs at the ginnery, where huge clumps of seed-studded fluff are shoveled into gigantic machines that clean and comb them. At the entrance, two officials of the government's Cotton Development Organization diligently record each sale in order to tax it. The money goes back into buying good seeds and pesticides that are then given to farmers. New seeds introduced from Zimbabwe last year produce bolls that yield about a third more usable cotton than the old variety.

Uganda's main advantages are cheap cotton and labor, and preferential access to American and European markets. When exporting to the rich world "Africa has an 18 to 35 percent duty advantage over any other continent," said Nick Earham, a shareholder in Western Uganda Cotton Company. "It's very competitive."

Textile workers in Kampala earn about $85 a month, compared with $150 in Kenya and $108 in Vietnam, never mind up to $700 in China. But these savings are offset by problems in almost every other sphere. Power cuts keep plunging the factory into darkness, and an erratic supply of steam to the dyeing machines makes it hard to ensure that each batch of fabric looks alike.

In a cramped meeting room alongside the factory, executives of Bonprix visiting from Europe make their unhappiness clear. Their inspectors in Hamburg are discovering more defects than they would like.

Yet Bonprix is placing orders at higher prices than it might pay elsewhere and offering technical help to nurture an industry which it hopes will, in time, become competitive. As its rivals look to countries such as Vietnam and Bangladesh, which are starting to replace China as big suppliers of clothing, Bonprix is already seeking out the countries that will, in turn, replace them. As Asia grows richer, its pool of cheap labor will eventually run dry — and Africa is next in line.