Index: trunk/stac/src/Makefile
===================================================================
--- trunk/stac/src/Makefile	(revision 3683)
+++ trunk/stac/src/Makefile	(revision 5743)
@@ -1,15 +1,26 @@
 SHELL = /bin/sh
 CC = gcc
-CFLAGS += -g -std=c99 -I/home/mithrandir/price/psLib/include -D_GNU_SOURCE # -DTESTING -DCRFLUX
-PSLIB += -L/home/mithrandir/price/psLib/lib/ -lpslib -lgsl -lgslcblas -lfftw3f -lsla -lcfitsio -lm -lxml2 -lmysqlclient
-LDFLAGS += $(PSLIB)
 
+### psLib
+PSLIB_INCLUDE := $(shell pslib-config --cflags)
+PSLIB_LINK := $(shell pslib-config --libs)
+
+### Additional flags for diagnostics, testing, etc
+#PAP_CFLAGS = -DTESTING
+#PAP_CFLAGS = -DCRFLUX
+
+### Build flags
+CFLAGS += -g -O2 -std=c99 -Werror -D_GNU_SOURCE -DPS_NO_TRACE $(PSLIB_INCLUDE) $(PAP_CFLAGS)
+LDFLAGS += $(PSLIB_LINK)
+
+### Ingredients for each program
 STAC = stac.o stacConfig.o stacRead.o stacErrorImages.o stacTransform.o stacCheckMemory.o stacHelp.o \
-	stacCombine.o stacInvertMaps.o stacRejection.o stacAreaOfInterest.o stacSize.o stacScales.o time.o
+	stacCombine.o stacInvertMaps.o stacRejection.o stacAreaOfInterest.o stacSize.o stacScales.o \
+	stacTime.o
 
 SHIFT = shift.o stacRead.o stacTransform.o stacCheckMemory.o stacInvertMaps.o stacSize.o
 
 COMBINE = combine.o combineConfig.o stacRead.o stacErrorImages.o stacCombine.o stacScales.o \
-	stacCheckMemory.o time.o
+	stacCheckMemory.o stacTime.o
 
 SHIFTSIZE = shiftSize.o stacWrite.o stacConfig.o stacRead.o stacCheckMemory.o stacSize.o
@@ -17,10 +28,19 @@
 FIXIMAGE = fixImage.o
 
-TARGETS = stac shift combine shiftSize fixImage
+CALCGRADIENT = calcGradient.o stacRejection.o
 
+SUM = sum.o
+
+### List of targets
+TARGETS = stac shift combine shiftSize calcGradient sum
+
+
+### Build recipes
 .PHONY: tags clean empty test profile optimise all
 
 .c.o:
 		$(CC) -c $(CFLAGS) $(OPTFLAGS) $<
+
+all:		$(TARGETS)
 
 stac:		$(STAC)
@@ -36,8 +56,10 @@
 		$(CC) $(CFLAGS) -o $@ $(SHIFTSIZE) $(LDFLAGS) $(OPTFLAGS)
 
-fixImage:	$(FIXIMAGE)
-		$(CC) $(CFLAGS) -o $@ $(FIXIMAGE) $(LDFLAGS) $(OPTFLAGS)
+calcGradient:	$(CALCGRADIENT)
+		$(CC) $(CFLAGS) -o $@ $(CALCGRADIENT) $(LDFLAGS) $(OPTFLAGS)
 
-all:		$(TARGETS)
+sum:		$(SUM)
+		$(CC) $(CFLAGS) -o $@ $(SUM) $(LDFLAGS) $(OPTFLAGS)
+
 
 clean:
