PIC16F877 analog pin configuration
See datasheet, Section 11.0 (Register 11-2), page 112.

You select the operation of the pins by setting the four bits PCFG3:PCFG0 in the ADCON1 register
according to the table in the datasheet.

The power-on default of these bits is 0000, which means that all the pins AN0...AN7 are configured as analog inputs.

To configure all the AN-pins as digital, you set the PCFG bits to 011x (x means don't care). The rest of the combinations are in the datasheet.