--- Makefile.orig	Mon Mar 29 15:24:31 2004
+++ Makefile	Tue Feb  1 01:37:09 2005
@@ -14,25 +14,25 @@
 
 # Directory for Standard .qcl files
 
-QCLDIR = /usr/local/lib/qcl
+QCLDIR = ${PREFIX}/share/qcl
 
 # Path for qcl binaries
 
-QCLBIN = /usr/local/bin
+QCLBIN = ${PREFIX}/bin
 
 # Debugging options
 
 #DEBUG = -g -pg -DQCL_DEBUG -DQC_DEBUG
 #DEBUG = -g -DQCL_DEBUG -DQC_DEBUG
-DEBUG = -O2 -g -DQCL_DEBUG -DQC_DEBUG
+DEBUG = -DQCL_DEBUG -DQC_DEBUG
 #DEBUG = -O2
 
 # Plotting support 
 #
 # Comment out if you don't have GNU libplotter and X
 
-PLOPT = -DQCL_PLOT
-PLLIB = -L/usr/X11/lib -lplotter -lXaw -lXmu -lXt -lXext -lXpm -lSM -lICE -lX11
+#PLOPT = -DQCL_PLOT
+#PLLIB = -L/usr/X11/lib -lplotter -lXaw -lXmu -lXt -lXext -lXpm -lSM -lICE -lX11
 #PLLIB = -L/usr/X11/lib -lplotter -lXaw -lXmu -lXt -lXext -lX11 
 #PLLIB = -L/usr/X11/lib -lplotter -lXaw -lXmu -Xt -lSM -ICE -lXext -lX11 
 
@@ -42,8 +42,8 @@
 # explicit linking against libtermcap or libncurses may be required
 
 RLOPT = -DQCL_USE_READLINE
-#RLLIB = -lreadline
-RLLIB = -lreadline -lncurses
+RLLIB = -lreadline
+#RLLIB = -lreadline -lncurses
 
 # Interrupt support
 #
@@ -51,12 +51,6 @@
 
 IRQOPT = -DQCL_IRQ
 
-# Replace with lex and yacc on non-GNU systems (untested)
-
-LEX = flex
-YACC = bison 
-INSTALL = install
-
 ##### You shouldn't have to edit the stuff below #####
 
 DATE = `date +"%y.%m.%d-%H%M"`
@@ -65,13 +59,11 @@
 QCLIB = $(QCDIR)/libqc.a
 QCLINC = lib
 
-CC = g++
-CPP = $(CC) -E
-CFLAGS = -c -Wall $(DEBUG) $(PLOPT) $(RLOPT) $(IRQOPT) -I$(QCDIR) -DDEF_INCLUDE_PATH="\"$(QCLDIR)\""
-LFLAGS = -L$(QCDIR) $(DEBUG) $(PLLIB) -lm -lfl -lqc $(RLLIB) 
+CXXFLAGS += $(DEBUG) $(PLOPT) $(RLOPT) $(IRQOPT) -I$(QCDIR) -DDEF_INCLUDE_PATH="\"$(QCLDIR)\""
+LDFLAGS += -L$(QCDIR) $(DEBUG) $(PLLIB) -lm -lfl -lqc $(RLLIB) 
 
-FILESCC = $(wildcard *.cc)
-FILESH = $(wildcard *.h)
+FILESCC = *.cc
+FILESH = *.h
 
 SOURCE = $(FILESCC) $(FILESH) qcl.lex qcl.y Makefile
 
@@ -79,23 +71,11 @@
           lex.o yacc.o print.o quheap.o extern.o eval.o exec.o \
           parse.o options.o debug.o cond.o dump.o plot.o format.o
 
-all: do-it-all
+all: build
 
-ifeq (.depend,$(wildcard .depend))
-include .depend
-do-it-all: build
-else
-do-it-all: dep
-	make
-endif
-
-#### Rules for depend
-
-dep: lex.cc yacc.cc yacc.h $(QCLIB)
-	for i in *.cc; do \
-	  $(CPP) -I$(QCDIR) -MM $$i; \
-	  echo -e '\t$(CC) $(CFLAGS)' $$i '\n'; \
-	done > .depend
+
+dep:
+	mkdep ${CXXFLAGS} ${FILESCC}
 
 lex.cc: qcl.lex
 	$(LEX) -olex.cc qcl.lex
@@ -107,26 +87,26 @@
 	mv yacc.*?h yacc.h
 
 $(QCLIB):
-	cd $(QCDIR) && make libqc.a
+	+cd ${QCDIR} && ${MAKE} ${MAKEFLAGS} libqc.a
 
 #### Rules for build
 
 build: qcl $(QCLINC)/default.qcl
 
 qcl: $(OBJECTS) qcl.o $(QCLIB)
-	$(CC) $(OBJECTS) qcl.o $(LFLAGS) -o qcl
+	$(CXX) $(OBJECTS) qcl.o $(LDFLAGS) -o qcl
 
 qcl-static: $(OBJECTS) qcl.o $(QCLIB)
-	$(CC) -static $(OBJECTS) qcl.o $(LFLAGS) -o qcl-static
+	$(CXX) -static $(OBJECTS) qcl.o $(LDFLAGS) -o qcl-static
 	strip qcl-static
 
 $(QCLINC)/default.qcl: extern.cc
 	grep "^//!" extern.cc | cut -c5- > $(QCLINC)/default.qcl
 
 install: build
-	$(INSTALL) -m 0755 -d $(QCLBIN) $(QCLDIR)
-	$(INSTALL) -m 0755 ./qcl $(QCLBIN)
-	$(INSTALL) -m 0644 ./lib/*.qcl $(QCLDIR)
+	umask 022; mkdir -p $(QCLDIR); chmod 0755 $(QCLDIR)
+	${INSTALL} -m 0755 ./qcl $(QCLBIN)
+	${INSTALL} -m 0644 ./lib/*.qcl $(QCLDIR)
 
 uninstall:
 	rm -f $(QCLBIN)
