Writing Makefiles is tricky and error prone. Makefiles are hard to debug, and it's not easy to see what's going on when they are executed. Therefore I've made a Makefile for Haskell scripts, to solve the problem once and for all. GNU make is required.
The directory structure is as follows.
hsscripts/ |
|
The root of the directory tree. The name is arbitrary. |
hsscripts/build/ |
|
Everything generated goes here. |
hsscripts/src/ |
|
The source files |
hsscripts/Makefile |
|
The makefile |
There are two kinds of source files in src/. Main modules have file names which start with a lower case letter. The programs generated from them get the same name, without the .hs suffix. Internal modules are normal Haskell modules. The file name maches the module name, which starts with an upper case letter. Internal modues can be shared between scripts.
In order to add a new program or internal module, you just place the file in src/. The makefile will then compile it. No modifications are required, since the source files are located by wildcard patterns.
You might want to use the executable compressor UPX. It considerably reduces the size of (the rather big) Haskell programs compiled by GHC, so they use less disk space and load faster. On Debian, the package is called upx-ucl.
Here is the Makefile, and some example scripts.