# About web2c, c code conversion

I'd like to convert some Tex-and-friends code to C, so that I can play with modifying it. As I understand it, the process is:

(1) The tangle utility converts foo.web to a foo.p (Pascal) file, and then

(2) I use web2c to convert foo.p to foo.c

I have managed to make step #1 work, but I'm stuck on step #2. I found the "convert" function and it's components in .../texk/web2c/web2c (in the Live Tex distribution). I was hoping that I could just switch to that directory and type "make" to compile/build the web2c utility. But this directory does not contain a typical Makefile. It has Makefile.am and Makefile.in, but these don't seem to do any compilation, as far as I can see (though I know very little about make files).

So, the questions are:

(1) Is there somewhere I can get a pre-built web2c conversion tool (for Windows), or

(2) Can someone give me good instructions for building it myself.

Edit: Even better ...

(3) Is there somewhere I can get C code for TeX and Metafont. This code is produced as part of the TeX build process, but apparently it must get thrown away after compilation, since I can't seem to find it anywhere.

Edit: Regarding approach #3, I looked at Y&Y TeX, LuaTex, and CXTeX. They have C code, but, as far as I can see, none of them include Metafont, which is the subsystem that most interests me.

Results from typing "Build":

``````configure: WARNING: Sorry, neither Carbon framework nor fontconfig library: disabling xetex
configure: error: terminating.
=== configuring in web2c failed
``````

And in config.log, I found:

``````configure:18449: checking for installed fontconfig headers and library
configure:18482: gcc -o conftest.exe -g -O2    conftest.c -lfontconfig  >&5
conftest.c:48:35: fatal error: fontconfig/fontconfig.h: No such file or directory
compilation terminated.
configure:18482: \$? = 1
configure: failed program was:
| /* confdefs.h */
``````

But, as Khaled pointed out, I could have avoided building these components, anyway, if I'd done a bit more research.

Avoiding the Above Error In case it helps any of my fellow neophytes and idiots ...

The error arises because fontconfig is missing. The "prerequisites" section of the build instructions tells you how to avoid this. You have to use

`````` --disable-xetex
--disable-xdvipdfmx.
``````
-
Is there a `configure` script? Running this generates `Makefile` from `Makefile.in`. (If there's only a `configure.in`, you will need to run `autoconf`, but you may not already have that installed.) Can't help with the rest I'm afraid. –  cyberSingularity Nov 24 '12 at 2:04
With regards to your edit, as you say you're interested in Windows, how about miktex.org/sources, which includes already C-translated versions of the code for both TeX and metafont in the `Programs\TeXAndFriends\mf` and `Programs\TeXAndFriends\tex` folders. –  cyberSingularity Nov 24 '12 at 2:16
If you built TeX Live with the included `Build` script, the converted files should be under `Work/texk/web2c/`; there you will find `tex0.c`, `mf0.c` etc. but I don’t think hacking the generated C files is such a good idea. –  Khaled Hosny Nov 24 '12 at 4:04
You can only build TeX and MetaFont, see `README.config` for build options (e.g. passing something like `--disable-all-pkgs --enable-tex --enable-mf --without-mf-x-toolkit --without-x` to `configure` would do the trick. I put the two files here `tex0.c` & `mf0.c`. But if I were you, I’d learn `WEB` and pascal, actually this exactly what I did to hack LuaTeX (before it was ported to C) and XeTeX. –  Khaled Hosny Nov 24 '12 at 12:49
To get your way around `WEB`, you should start with webman (I can’t find a PDF file, but just `tex` it). –  Khaled Hosny Nov 24 '12 at 12:51

If you built TeX Live with the included Build script, the converted files should be under `Work/texk/web2c/`; there you will find `tex0.c`, `mf0.c` etc. To build only TeX and MetaFont, you can pass something like `--disable-all-pkgs --enable-tex --enable-mf --without-mf-x-toolkit --without-x` to `configure` (see `README.config` for general build option documentation)