CC = CC

targets = test_fork test_exit test_waitpid \
          test_exec test_pipe   \
          command_pipe command_pipe2  \
          test_popen  getproc   


all : $(targets) mini-shell

$(targets) : $$@.C 
	CC -o $@ $@.C 

mini-shell :  shell.y.o shell.yy.o shell.o exec_cmd.o
	$(CC) -o $@ shell.y.o shell.yy.o shell.o exec_cmd.o

shell.y.o : shell.y
	yacc -d shell.y
	$(CC) -c y.tab.c
	mv y.tab.o shell.y.o
	/bin/rm -f y.tab.c

shell.yy.o : shell.l
	lex shell.l
	$(CC) -c lex.yy.c
	mv lex.yy.o shell.yy.o
	/bin/rm -f lex.yy.c

shell.o exec_cmd.o : $$(@:.o=.C)
	$(CC) -c $(@:.o=.C)

clean :
	/bin/rm -f  $(targets) mini-shell *.o y.tab.h
