Your final step is to get the software installed on the Unix system. With some programs, all you’ll have to do is put the files in the directory where you want them to live (often ~/bin for programs or scripts or sometimes cgi-bin for scripts or programs for Web use). With others, though, you’ll have to compile first and then install.
You can compile and install using make install, which reads the Makefile (to see how to set everything up) and takes care of compiling and installing for you (Code Listing 14.4). Again, be sure to read the instructions carefully before you start and follow them exactly.
jdoe /home/jdoe/src/yencode-0.46 $ make
cd .
&& CONFIG_FILES= CONFIG_HEADERS=config.h
/bin/sh ./config.status
config.status: creating config.h
config.status: config.h is unchanged
make all-recursive
make[1]: Entering directory '/home/jdoe/src/yencode-0.46'
Making all in intl
make[2]: Entering directory '/home/jdoe/src/yencode-0.46/intl'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/jdoe/src/yencode-0.46/intl'
Making all in po
make[2]: Entering directory '/home/jdoe/src/yencode-0.46/po'
...
gcc -DLOCALEDIR="/home/jdoe/share/locale" -DSYSTYPE="i686-pc-linux-gnu" -I. -I. -I..
→ -I../lib -I../intl -Wall -Wno-unused -g -O2 -c 'test -f ydecode.c || echo './'`ydecode.c
gcc -Wall -Wno-unused -g -O2 -o ydecode ydecode.o crc.o file.o output.o ../lib/libmisc.a
make[3]: Leaving directory '/home/jdoe/src/yencode-0.46/src'
make[2]: Leaving directory '/home/jdoe/src/yencode-0.46/src'
make[2]: Entering directory '/home/jdoe/src/yencode-0.46'
make[2]: Leaving directory '/home/jdoe/src/yencode-0.46'
make[1]: Leaving directory '/home/jdoe/src/yencode-0.46'
|
1. | make
For starters, type make at the shell prompt (in the main directory containing your program setup files) to set up all of the variables you specified in the previous section. Code Listing 14.4 shows what make displays on the screen. If you see error messages that aren’t accompanied by a reassuring “Will continue to use something else” message, you may need to return to editing the Makefile. When you make successfully, without nasty error messages, you’re ready to move ahead to step 2. Code Listing 14.5. Type make install to finish the installation process.
| |
2. | ||
3. | ~/bin/yencode Try out the new software! (Of course, replace yencode with the name of the software you installed.) (See Code Listing 14.6). Zowie! It works! Code Listing 14.6. It works! We didn’t do anything with it, but it works.
| |
4. | cd ; rm -Rf ~/src/yencode* After you’re sure that everything works right, tar and gzip the complete source tree (in case you need to reinstall). Or, if space is tight, save the Makefile and any other files you edited, and remove the rest. (If space is tight and you didn’t make any substantive changes to get everything to compile, just rm it all.) |
✓ Tips
Be patient, and puzzle your way through if you encounter unexpected errors or if something just doesn’t go right. Reading the Makefile and source code is your best bet for solving problems.
After a failed attempt, type make clean or make distclean to clear out the garbage before you try again.
Sometimes stuff just isn’t worth the trouble. Compiling and installing new software can be fairly difficult, and sometimes the problems you encounter aren’t easily resolved. In writing this chapter, for example, we had a great program to install but had to spend about four hours tweaking and fixing it to get it to compile. (That’s about three hours and 15 minutes longer than we’d planned on.) This can happen to anyone, so don’t get discouraged, but feel free to seek out help or simply find another program that does essentially the same thing; There’s enough software out there that technical difficulties in one place shouldn’t be any kind of serious obstacle.
Pay particular attention to the paths to programs and files as you’re editing scripts and other setup files—a little error in a path can be hard to spot and completely prevent the new software from working.