To solve this optimization problem, we need to define the decision variables, objective function, and constraints. 

Let's denote:
- $x_c$ as the number of cheese pizzas made,
- $x_p$ as the number of pepperoni pizzas made.

The objective is to maximize profit, given by $7x_c + 9x_p$.

Constraints are based on the availability of ingredients:
1. Flour: $30x_c + 40x_p \leq 3000$
2. Cheese: $50x_c + 20x_p \leq 4000$
3. Sauce: $40x_c + 30x_p \leq 5000$

Also, the number of pizzas cannot be negative:
- $x_c \geq 0$
- $x_p \geq 0$

Now, let's translate this into Gurobi code in Python:

```python
from gurobipy import *

# Create a new model
model = Model("Pizza_Profit_Optimization")

# Define the decision variables
x_c = model.addVar(vtype=GRB.CONTINUOUS, name="cheese_pizzas", lb=0)
x_p = model.addVar(vtype=GRB.CONTINUOUS, name="pepperoni_pizzas", lb=0)

# Set the objective function
model.setObjective(7*x_c + 9*x_p, GRB.MAXIMIZE)

# Add constraints
model.addConstr(30*x_c + 40*x_p <= 3000, "flour_constraint")
model.addConstr(50*x_c + 20*x_p <= 4000, "cheese_constraint")
model.addConstr(40*x_c + 30*x_p <= 5000, "sauce_constraint")

# Optimize the model
model.optimize()

# Print the results
if model.status == GRB.OPTIMAL:
    print(f"Optimal solution: {x_c.varName} = {x_c.x}, {x_p.varName} = {x_p.x}")
    print(f"Maximum profit: {model.objVal}")
else:
    print("No optimal solution found")

# Output the gurobi model
print(model)
```