We have developed some software and we want to provide with the source code and binaries to the academic and industry community, so that they can freely use it. But if anybody wants to make commercial profit they should ask us for permission first. What do you think is the right license for this?
No such open source license exists. Usage restrictions, e.g. forbidding commercial use, violates point 6 of the Open Source Definition:
6. No Discrimination Against Fields of Endeavor
The license must not restrict anyone from making use of the program in a specific field of endeavor. For example, it may not restrict the program from being used in a business, or from being used for genetic research.
Rationale: The major intention of this clause is to prohibit license traps that prevent open source from being used commercially. We want commercial users to join our community, not feel excluded from it.
You will have to look for a non-Open Source license, or ask a lawyer to draft a custom license for your use case. Note that publishing software with no license is also possible in which case all rights are reserved. But this can cause accidental copyright infringement, for example if someone publishes a modified version of the software, even if only to send you a pull request.
You may particularly want to look at “shared source” licenses, e.g. the license suite created by Microsoft in 2001: https://en.wikipedia.org/wiki/Shared_Source_Initiative