Makefiles are commonly used to help people compile and install programs on UNIX/Linux with and without the use of package management.
CC=gcc
CFLAGS=-O2 -Wall
DFLAGS=-DFIREFOX
BINDIR=$(HOME)/bin
EXECUTABLES=ssh_test
all: $(EXECUTABLES)
.c.o: ;
$(CC) $(DFLAGS) $(CFLAGS) $<
ssh_test: ssh.c
$(CC) $(DFLAGS) $(CFLAGS) ssh.c -o ssh_test
@echo "Compile finished, now type \"make install\""
clean:
rm -f *.o *.bak *~ $(EXECUTABLES)
install: all
mkdir -p $(BINDIR)
@echo "Installing into directory: "$(BINDIR)
cp -v $(EXECUTABLES) $(BINDIR)
@echo "Successfully installed "$(EXECUTABLES)"
uninstall:
@echo "Attempting to remove installed programs from directory:"$(BINDIR)
rm -v $(BINDIR)/$(EXECUTABLES)
@echo "Successfully uninstalled "$(EXECUTABLES)"
Compilation: Having ssh.c and Makefile in the same folder, open a command prompt, cd into that directory, and type make1. This will compile ssh.c into a binary named ssh_test. To test the binary, type ./ssh_test and it will execute.
Installation: Installation is simple - just type make install. This will create a folder named bin in your home directory if it does not already exist and copy ssh_test into that folder. Remember that if you compile this program on Linux it will not run on Solaris and vice versa, so compile/install this program using the same platform you usually use2.
Uninstallation: In the event that you decide you want to uninstall this program, you can either delete ~/ssh_test or type make uninstall.
Now that you've got this thing compiled and installed, turn to the .mycshrc page to learn how to put this program to use.
1: Microsoft does not ship a compiler with Windows. Consider using GCC or Microsoft Visual C++.
2: Future versions of Solaris and current versions of (x86) FreeBSD Unix provide Linux binary compatibility, so it may be possible for you to compile software for Linux and execute it under a UNIX OS provided an i686 platform.