Usage of P4P_TARGET_PORT is defined but implementation is missing / confusing.
In mkdirs.cfg there is a definition for P4P_TARGET_PORT as the master's target port. However, in mkdirs.sh#100 there is a redefinition of that variable at line 1284 to "P4P_TARGET_PORT="${SSL_PREFIX}${P4MASTERHOST}:${P4_PORT}"" so it is used for more than just the master's target port. At line 1307 it is used by sed to replace REPL_P4P_TARGET_PORT in the instance_vars.template file, except that file doesn't have REPL_P4P_TARGET_PORT in it so ultimately P4P_TARGET_PORT is never actually used.
Looking at CL 27512 it seems the intent was to remove REPL_P4P_TARGET_PORT? If so, the mkdirs.cfg and mkdirs.sh files also have P4P_TARGET_PORT removed to avoid confusion, and perhaps a comment added to use P4PORTNUM instead of P4BROKERPORTNUM for the proxy's target port. I can do this, but first wanted to open an issue because I wasn't sure if it was the right thing to do given the check for a ServerType = p4proxy at line 1283 of mkdirs.sh. I'm also not sure if there would be impacts to other scripts or functionality if everything related to P4P_TARGET_PORT goes away although from a quick grep it looks like nothing uses it.