You are thinking in terms of extremes. Relations are not black or white, not every nation has to be either an, "enemy," or "friend." China can recognize the geopolitical realities that would prevent India from being a "friend," but it is still in China's interests to prevent India from being an, "enemy." Whenever possible, you want to avoid making your neighbors, especially big ones, your "enemies." India for the most part has resisted direct alignment with the West, and it is in China's interests that India continues to do so. Adopting a hostile policy towards India only increases the probability of India drifting closer to the West. It is also not in any country's interest for a large neighbor to collapse and descend into chaos, especially if that large neighbor has a nuclear arsenal (regardless of how small and basic that arsenal may be).
If you go back about 25 years, China was also heavily reliant on foreign technology, and with a level of industrial and economic development much behind Turkey and Iran. In terms of real (PPP) GDP per capita, China only surpassed Iran within the past decade and still significantly lags behind Turkey. In Iran's case, being sanctioned from much of the international market and being cut off from foreign technology held Iran back far more than its limited energy sales could compensate for. Pakistan, on the other hand is even less developed than India. The differentiating factor between India/Pakistan and Iran/Turkey is that India/Pakistan were British colonies for 200 years while Iran and Turkey were never colonized. In terms of independent technology, very few countries have the necessary population size to be fully independent in terms of technology, not even the US, and definitely not any individual European state (not even Germany or Russia). Only China does, and questionably the entirety of Europe as a whole. India may have the potential based solely on population size, but is held back by innumerable other factors.
Persian may have thousands of years of history, but Turkey also has at least 700 years of history (if you choose not to count Byzantium's cultural legacy). But India too has thousands of years of history and Europe only about 1400 years of history, so total length of history is largely irrelevant. What is more meaningful is which countries had independent institutions over the past 300-400 years. Persia, Turkey, Europe, and China did while India/Pakistan and most of the Middle East did not.