top of page
Search
Writer's pictureClarisse Bonang

Haskell and BNFC for Windows Part II

We're at the half-way point of completing the necessary installations to make you Haskell ready!



After installing the Git Bash command line shell program you made your Windows computer a bit more Unix-like. Next, you'll install mingw64, the "Minimalist GNU for Windows" application. MinGW adds special commands such as mingw32-make that's identical to the Unix make command except for the name. The make command is essential for Haskell and BNFC.


Install mingw64 ("Minimalist GNU for Windows)

Open your web browser to the MinGW SourceForge web page: https://sourceforge.net/projects/mingw/

Click on the Files tab, adjacent to the highlighted Summary tab.


Click the Save File button.


In Windows Explorer, navigate to the location where you saved the mingw-get-setup.exe file and run it.


The MinGW Installation Manager Setup Tool window appears.

Click the Install button.

The Continue button is initially grayed-out.


When the Continue button is no longer grayed-out, press it.



The MinGW Installation Manager window will appear.

Click on the MSYS tree node in the Basic Setup section on the left hand side of the screen.


Click on the mingww-developer-toolkit check box at the very top of the Package column.



Select the Mark for Installation option.


The toolkit and the items it depends on will be marked.


Next, click on "All Packages" option on the left hand side. Scroll down in the Packages pane and then select the four mingw32-make options.


From the Installation menu, select the Apply Changes menu option.


The Schedule of Pending Actions window appears.

Press the Apply button.


The Download Package window will appear.

The Applying Scheduled Changes dialog appears next automatically.

When the changes are applied, the dialog window will indicate that "All changes were applied successfully; you may now close this dialog."

Press the close button.


Close the MinGW Installation Manager program.



The MinGW developer tookit is now installed in directory C:\MinGW on your Windows computer.


You'll need to add this path, C:\MinGW, to your Path environment variable.


On Windows 10, this may be done as follows.


In the Windows 10 search box in the lower left corner of the screen, type system.

The System Control Panel entry should appear at the top. Press the Enter key.


The Windows 10 System Control Panel Item dialog window appears.

Click on the Advanced system settings option at the left hand side of the window.


The System Properties dialog appears.

Press the Environment Variables ... button near the bottom of the Window.


(For security reasons, the values for my system are blurred-out.)


Ensure that within the System variable section, the Path environment variable is highlighted.


Click the Edit button.


The Edit environment variable dialog window appears.


Click the New button.


At the bottom of the dialog, in the blank space for the new entry that appears, enter the path to the MinGW "bin" directory. ("bin" stands for binary as in binary executable programs): C:\MinGW\bin


Press the OK button.


Minimalist GNU for Windows is now installed and its binary executable programs are in your Path and thus accessible from the command line.


However, you have installed mingw32-make.exe, not make.exe. Fortunately, mingw32-make.exe behaves identically to make.exe; it just has a different name.



Configure Make.exe

 

You'll need to make a copy of mingw32-make.exe and rename the copy to make.exe. (To build with the Haskell makefiles on Windows, you'll need to ensure the make program is named make.exe.)


Open a Windows Explorer window and navigate to the MingGW bin directory, C:\MinGW\bin.


Scroll down until you find the mingw32-make.exe program and copy it.

Paste the file into another location. I pasted it into C:\Documents\MingwPrograms.


After pasting the copy of mingw32-make.exe into the new location, rename it by right clicking on the file and selecting rename.

Once you've renamed the file, you need to make sure that make.exe is available from the Bash command line.


From the Windows 10 Start button, open the Git folder.



Within the Git folder, double click on Git Bash to launch a Git Bash shell.


The MingGW Git Bash command line shell program will appear.

Type the cd command to ensure that you're in your "home" directory.

My home directory is /c/Users/gigi.


You'll need to create a Bash resources file, .bashrc. The dot in front makes .bashrc a "hidden" file - it won't show up when you type the ls command to list the files in your home directory unless you add special options to ls.


To create the .bashrc file, you can use the vi editor available from the Git Bash command line.


At the command prompt, type: vi .bashrc

Press "i" to place vi into insert mode.


You should see "INSERT" appear at the bottom of the window.


Type in the export command to export the path to the folder where you placed your make.exe file (the copy you made of mingw32-make.exe that you renamed).


After you've type this in, press the escape key (ESC).


After pressing the ESC key, the "INSERT" text at the bottom of the screen will disappear.

Next, press :wq

The colon places vi in command mode. The "w" commands it to write the file (.bashrc) and the "q" commands vi to quit.


The vi program will exit and you're back to the Git Bash command line shell prompt.


Type ls -la .bashrc to make sure that the "hidden" .bashrc file is present in your home directory.


If you already had a .bashrc file in your directly, you just need to add the location of the folder containing make.exe to your PATH.Add the pathname to the end of the others, separating it with a colon character. (You would just type in something like :"C:\Users\gigi\Document\MingwPrograms", where the first character is the colon separator.) Here's what my .bashrc file looks like; I already had a path to another program in there.


As I mentioned earlier, the .bashrc file is the Git Bash resource file. It specifies the location of resources. Before these locations are made known the to the Git Bash command line shell, you must first "source" the .bashrc resource file.


This is easy. In your home directory, where the .bashrc file resides, simply type:


source .bashrc


The location of the make.exe program is now know to your Git Bash command line shell. You need to do this every time you run Git Bash.


To ensure that make.exe is now in your path, and accessible from Git Bash, use the "which" command as follows:

which make

You don't need to type the .exe extension; "which" know what you mean.


To make sure that make actually works, type make at the Git Bash command line shell's $ command prompt:

make

You should see something like "No targets specified ..." because there's no Makefile present and you didn't give make any arguments to specify a makefile either. make is doing what it's supposed to.


You now have a functional version of make with the correct name (and not mingw32-make.exe). You'll be able to build Haskell programs using make and makefiles.



Next, you'll need to get BNFC operational on your Windows system along with some supporting programs.

 

We're almost done!

In the next blog, we'll cover BNFC Installation, installing Alex using stack, and installing Happy using stack in Haskell and BNFC on Windows Part III.

The last part to this section, I promise.

Next week's Blog:

Haskell and BNFC on Windows Part III.

 

References


15 views0 comments

Recent Posts

See All

Comments


Post: Blog2_Post
bottom of page