Building WeeChat on Windows in Cygwin
IRC is a fairly old protocol at this point, and while I can't say its aged well (its aged sort of like one of those types of cheese that gets a bunch of mold in it and for some reason people were like "yes, let's eat this and pretend it tastes good!"), it at least has a fairly strong set of clients that have matured a bit better than the protocol itself.
The best one I've used so far is WeeChat, which unfortunately does not itself provide a binary on Windows. So I've only been able to enjoy it on Linux, until recently -- I decided to dig down into the build process, seeing as it purports to build properly in cygwin, and try to get it up on my Windows machine.
(I discovered while writing this post that Weechat 1.3 is available as a package in Cygwin. I decided to post this anyway, as it might be helpful to those who want WeeChat 1.4 and who are building other things in cygwin on Windows).
Note: If you've got cygwin, you can just install the weechat package and move on with your life, if you don't care about getting version 1.4. Otherwise, if know how to extract sources, you can skip right to Step 6 with a brief stopover in Step 3 to check that you've got all the packages you need.
I'm starting with a clean Windows 7 VM, so that I can be sure to include all the prerequisites here. Some of the packages may already be installed,
Alright, let's get started.
Start by downloading cygwin. Make sure you get the right build (32-bit or 64-bit) -- if you're on a relatively recent machine, chances are you'll want 64-bit. Note: Make sure you take note of where this installer downloads to, as you may need to run it again if you find out you missed a package.
Step 2: Running the cygwin installer
Run the cygwin installer. You'll likely want to choose "Install from Internet" and install to the default directory (C:\cygwin64), for All Users.
The Local Package directory doesn't matter -- I put them in my Downloads folder because that seemed the most sensical.
Your knowledge of your proxy settings is your own -- if you don't know, it's probably just Direct Connection.
The particular site you download from doesn't really matter -- I always choose one of the .edu domains, since I live in America and that's the easiest way to ensure the server will be fairly close by without individually checking where the DNS resolves. If you don't live in America, there are some other country-specific mirrors down the list.
At this point, the package list will download, and then you'll be dropped into one of the more confusing interfaces I've ever seen. I think this deserves its own step.
Step 3: Choosing packages
This is where, if you don't want to bother building WeeChat yourself, you would select the weechat package in cygwin, install it, and close the post. For those intrepid souls who wish to build it themselves, continue on....
By default, cygwin installs a small set of packages that gives you a basic unix-like command line environment. Unfortunately, this is not enough to build anything! We'll also need to get some libraries that WeeChat needs specifically. Which ones are needed will depend on whether you want TLS support, but I'll assume for the moment that you do.
Go ahead and tell the installer to install the following packages if it isn't planning to already already (Not absolutely sure this is the minimal set, but if you get these, you won't go wrong):
automake (The one without a specific version number)
It will ask if it should download the dependencies of the above packages. You definitely want to do that. The option is selected by default, so just hit Next.
Sit back and relax, because the install will take a while (5-20 minutes to download, depending on connection speed, plus another 5 or so to install).
Hopefully that goes off without a hitch. If so, you're ready to proceed...
Step 4: Downloading the WeeChat source
This one's easy. Just go here and click one of the downloads under "Download Sources".
You will, however, need to extract the .tar.gz or .tar.bz2 file that it comes in. Windows has apparently locked itself into .zip compression and doesn't have anything built in to extract these. Luckily, we just installed a set of linux tools!
Step 4.5: Intro to Cygwin
Open your newly minted Cygwin terminal. It's worth digressing for a moment here to explain the basics of how cygwin works.
Inside the cygwin terminal (and cygwin applications), you're in a virtual file system that looks, to any casual observer, like a linux file system. It starts at /, has all the usual /var, /bin, /dev folders and so on, with one important deviation: there's a /cygdrive folder as well, and this is how you access the actual disks windows knows about. Your C:\ drive will be /cygdrive/c for example.
Cygwin did not actually rewrite your hard disk, it's just pretending that the folder where it installed is the root of the filesystem. If you open Windows Explorer and browse to C:\cygwin64 (or wherever you installed it), you'll see var, bin, dev, and cygdrive folders right there. Inside cygdrive are symlinks to the root of whatever disks you have available.
The cygwin prompt starts you at your "home folder", which it calls /home/username. This is not the same folder as C:/Users/username. If you look in the cygwin directory, in home, you can see that its a regular folder and the only contents are the .rc and .profile files (known colloquially as dotfiles) it creates when you launch the terminal for the first time. If you want to get to your Windows user directory, you'll want /cygdrive/c/Users/username/. If you're clever with Windows command line and have admin access, you can probably link the cygwin folder to your user profile folder, but I won't cover that here.
Step 5: Extracting the WeeChat sources
Okay, now we've got the hang of cygwin, navigate in your cygwin prompt (if you're not sure how to do this, you might want to brush up on your command line skills before continuing) to the folder where you downloaded the weechat sources.
One of the core cygwin tools, luckily, is tar, so we are well equipped to extract the sources. I'm going to extract them in the same place, because it simplifies things and it doesn't particularly matter where you do the build. While I think it would be amusing to leave you to figure out the tar syntax, I'm not that cruel. Here's the command:
tar xf weechat-1.4.tar.gz
If you want to see each and every file as it extracts, you can make that xvf instead of xf.
Now, that should have extracted everything to a folder called Weechat-1.4 (or whichever version it's on when you read this). cd into it and we can start the build process
Ha. Ha. Ha. You think WeeChat will only take 1 step to build? Foolish mortal.
WeeChat has two paths for building. The one they recommend uses cmake, and the other uses the whole mess of auto____ tools known as autotools. (At least the naming is logical). I was unable to get WeeChat to build with TLS support using cmake, so I will be guiding you through the more arcane autotools path. If you want to try the cmake route for yourself, the readme.asciidoc should tell you just about everything you need to know.
First, run ./autogen.sh. If all goes well, it should say it's running several rm -f operations to clean up, then stick on Running "autoreconf -fvi"... for a long time, then exit. If it doesn't, you have a problem. Check your cygwin packages.
Now, if the world was a pleasant place and software worked all the time, we'd just be able to run a couple more commands and everything would compile nicely. Unfortunately, this is not that world, and we're going to have to make a couple tweaks to build files in order to get all the way through. You can see what the issue is by running ./configure right now, but it takes a while to get to the problem area so I don't recommend it.
Step 7: "Fixing" configure
For whatever reason, the check that configure performs for the Enchant lib fails with a syntax error, so we need to disable it. This does unfortunately mean you won't get spell-checking in WeeChat. I haven't found another way around it, but if you want to experiment more in your own time, by all means.
Open configure in your text editor of choice (be sure it can handle unix line endings and fairly large files -- Notepad won't cut it). You'll need to comment out these three lines (around line 22815 in mine):
if test "x$enable_enchant" = "xyes" ; then PKG_CHECK_MODULES(ENCHANT, enchant, ac_found_enchant_lib="yes", ac_found_enchant_lib="no") fi
This will cause the found_enchant_lib check to fail and the rest of the section will be skipped as well.
Now you can run ./configure in the directory you extracted weechat to, and it should go fairly smoothly. After it finishes, skim the last pageful or so of output to make sure nothing errored out. If it did, check that you have all the libraries from Step 3. If nothing went wrong, you should see the following line at the bottom:
configure complete, now type 'make' to build WeeChat 1.4
This one is fairly straightforward. Double check that ./configure produced a file called makefile, then run make. It'll take a while to build everything, so sit back and sip your drink of choice.
If we were using cmake, it'd have a nice percentage indicator on the left, but we have no such luxury. If someone has an idea about how to get TLS support built using the cmake path, I'd be happy to issue a revision to this post cutting its content down by about 50%.
It's harder to tell when make is done than when configure is, but you should hopefully see a bunch of make[x]: Leaving directory 'blah' statements at the bottom. If you see any errors, make sure configure ran okay and all the libraries are installed.
Step 9: Running make install
You'd think this would be the easiest step, seeing as everything is already built, but life is full of surprises. For some reason, several of the install commands refer to //usr/local/bin instead of /usr/local/bin. You wouldn't think that would be an issue, but you'd be wrong. Perhaps its a quirk of cygwin, but using // causes it to try to install to some read-only virtual file system somewhere, which make install will grumpily tell you if you try it. So we have to tweak some more.
Go into your editor again and open up the makefile in weechat-1.4/src/plugins/ (it's specifically this one that fails). Search for "prefix" and "exec_prefix" and edit both of them to be usr/local instead of /usr/local. I'm not certain both need to be edited, but there's no harm in doing so. Save the file, and now run make install. Everything should go smoothly, and like the previous make step, it's very hard to tell if it exits properly.
One easy way to tell: you run weechat and it works.
One last thing to do is make it so you can run weechat from your windows command prompt. Go to "System Properties" -> "Advanced" and click on "Environment Variables". Scroll down to "Path" in the System variables panel and edit it to include C:\cygwin64\usr\local\bin. You can test if this works by opening a new command prompt (not cygwin/bash) window and typing weechat.
Step 10: Enjoying WeeChat
There's lots to like about weechat, and there are tons of scripts available. I recommend you browse around in the /script menu in weechat, as there are plenty that add features that make weechat quite a bit nicer. 99% of things you find on the web about weechat should apply without modification to the Windows version, so don't hesitate to make use of your friendly neighborhood search engine.
If you have any question, comments, or suggestions about this post, you can contact me on twitter @chronaldragon or by email (see elsewhere on the site).