# Makefile for the lsh shell

# If you do not want to use the termcap library, 
# just delete the -DUSE_TERMCAP (and -ltermcap or -l(n)curses) and do a 
#   make clean ; make
# Some newer systems provide a termcap interface via terminfo, 
# so you might want to try that.
CC      = gcc
CFLAGS  = -Wall -O2 -fomit-frame-pointer -DUSE_TERMCAP
LIBS    = -lncurses
OBJ     = inp.o built.o parse.o map.o lex.o misc.o prompt.o exp.o alias.o main.o 

# Compile the shell (dynamically linked).
lsh: $(OBJ)
	$(CC) $(CFLAGS) $(OBJ) -o lsh $(LIBS)

# Compile the shell (static).
static: $(OBJ)
	$(CC) $(CFLAGS) -s -static $(OBJ) -o lsh $(LIBS)

# Install. Attempts to compile from source.
install: lsh
	install -m 755 -o root -s lsh /bin/lsh
	install -m 644 -o root sample.etc.autoexec /etc/autoexec
	install -m 644 -o root lsh.1 /usr/man/man1

# Install. Installs precompiled binaries.
install-precompiled: 
	install -m 755 -o root -s lsh /bin/lsh
	install -m 644 -o root sample.etc.autoexec /etc/autoexec
	install -m 644 -o root lsh.1 /usr/man/man1

# Build the modules.
.c.o :
	$(CC) $(CFLAGS) -c $*.c

# Delete the object files.
clean: 
	rm -f *.o

# Delete the executable.
reallyclean: clean
	rm -f lsh *.lsm *.tar.gz
