Small cell networks utilizing millimeter wave (mmWave) links are expected to enhance system throughput, since the wide bandwidths at mmWave frequencies can afford high data rates. Due to mmWave's unfavorable channel conditions, it is necessary for mmWave communication systems to use beamforming with a large number of antennas to generate sharp and strong beams. In this paper, we propose a codebook design algorithm for the beamforming by considering the directional characteristic of mmWave links. The proposed codebook design algorithm can be easily adapted to different kinds of antenna arrays. Simulation results show that the proposed codebook outperforms previously reported codebooks for mmWave systems.