# Makefile for rc.

# Check the definitions in config.h and stddef.h to make sure they are correct
# for your system.

# Set EXECVE to execve.o if you are using the execve() emulator (see config.h)
#EXEXVE=execve.o

# Use an ANSI compiler (or at least one that groks prototypes and void *):
CC=gcc -g -O

# Use bison if you will, but yacc generates a smaller y.tab.c, and the speed
# of the parser is largely irrelevant in a shell.
YACC=yacc

OBJS =  builtins.o except.o exec.o $(EXECVE) fn.o footobar.o getopt.o glob.o \
	glom.o hash.o heredoc.o input.o lex.o list.o main.o match.o nalloc.o \
	open.o redir.o sigmsgs.o status.o tree.o utils.o var.o version.o walk.o \
	which.o y.tab.o

# If rc is compiled with GNU readline, you must supply the correct arguments to
# ld on this line. Typically this would be something like:
#
#	$(CC) -o rc $(OBJS) -lreadline -ltermcap

rc: $(OBJS)
	$(CC) -o rc $(OBJS)

sigmsgs.c: mksignal
	sh mksignal /usr/include/sys/signal.h

y.tab.c: parse.y
	$(YACC) -d parse.y

clean:
	rm -f a.* *.o *.s core *.tab.* *.out

history: history.c
	$(CC) -o ./- history.c
	ln -s ./- ./--
	ln -s ./- ./-p
	ln -s ./- ./--p

C: force
	-mkdir C
	for i in *.c; do awk -f cfix.awk $$i >C/$$i; done
	for i in *.h; do awk -f hfix.awk $$i >C/$$i; done
	sed '/^CC=/s/$$/ -Dconst=/' Makefile > C/Makefile
	cp mksignal *.y C

force:

# dependencies:

sigmsgs.h: sigmsgs.c
lex.o y.tab.o: y.tab.c
builtins.c fn.c status.c hash.c: sigmsgs.h
