First, install HPIJS. The following command works for Debian and similar systems:
apt-get install printer-driver-hpijs
Then, as root, download the PPD files into /usr/share/ppd/custom/:
cd /usr/share/ppd/custom wget -c https://njh.eu/Brother-HL-2240D-hpijs-pcl5e.ppd wget -c https://njh.eu/Brother-HL-2240D-hl1250.ppd chmod 644 *
That's it! Run the CUPS web interface, and you'll be presented the drivers for Brother HL-2240D.