Index: trunk/psastro/src/Makefile.am
===================================================================
--- trunk/psastro/src/Makefile.am	(revision 7573)
+++ trunk/psastro/src/Makefile.am	(revision 7573)
@@ -0,0 +1,53 @@
+
+lib_LTLIBRARIES = libpsastro.la
+libpsastro_la_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSASTRO_CFLAGS)
+
+bin_PROGRAMS = psastro
+psastro_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSASTRO_CFLAGS)
+psastro_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS)
+psastro_LDADD = libpsastro.la
+
+psastro_SOURCES = \
+	psastro.c		
+
+libpsastro_la_SOURCES = \
+psastroArguments.c          \
+psastroParseCamera.c   	    \
+psastroDataLoad.c           \
+psastroDataSave.c           \
+psastroAstromGuess.c        \
+psastroLoadReferences.c     \
+psastroConvert.c	    \
+psastroChipAstrom.c         \
+psastroOneChip.c	    \
+psastroUtils.c	       	    \
+psastroTestFuncs.c          \
+psastroMosaicAstrom.c       \
+psastroMosaicGetGrads.c     \
+psastroMosaicGetRefstars.c  \
+psastroMosaicChipAstrom.c   \
+psastroMosaicSetAstrom.c    \
+psastroMosaicSetMatch.c	    \
+psastroMosaicHeaders.c	    \
+psastroMosaicRescaleChips.c \
+psastroWCS.c	   
+
+include_HEADERS = \
+	psastro.h		
+
+clean-local:
+	-rm -f TAGS
+
+# Tags for emacs
+tags:
+	etags `find . -name \*.[ch] -print`
+
+### Error codes.
+#BUILT_SOURCES = psastroErrorCodes.h psastroErrorCodes.c
+#CLEANFILES = psastroErrorCodes.h psastroErrorCodes.c
+
+#psastroErrorCodes.h : psastroErrorCodes.dat psastroErrorCodes.h.in
+#	$(ERRORCODES) --data=psastroErrorCodes.dat --outdir=. psastroErrorCodes.h
+
+#psastroErrorCodes.c : psastroErrorCodes.dat psastroErrorCodes.c.in psastroErrorCodes.h
+#	$(ERRORCODES) --data=psastroEerrorCodes.dat --outdir=. psastroErrorCodes.c
Index: trunk/psastro/src/psastroArguments.c
===================================================================
--- trunk/psastro/src/psastroArguments.c	(revision 7385)
+++ trunk/psastro/src/psastroArguments.c	(revision 7573)
@@ -41,5 +41,5 @@
     if ((N = psArgumentGet (*argc, argv, "-chip"))) {
 	psArgumentRemove (N, argc, argv);
-	psMetadataAddStr (config->arguments, PS_LIST_TAIL, "CHIP_SELECTION", PS_DATA_STRING, "", psStringCopy(argv[N]));
+	psMetadataAddStr (config->arguments, PS_LIST_TAIL, "CHIP_SELECTIONS", PS_DATA_STRING, "", psStringCopy(argv[N]));
 	psArgumentRemove (N, argc, argv);
     }
Index: trunk/psastro/src/psastroLoadReferences.c
===================================================================
--- trunk/psastro/src/psastroLoadReferences.c	(revision 7385)
+++ trunk/psastro/src/psastroLoadReferences.c	(revision 7573)
@@ -3,4 +3,5 @@
 
 # define ELIXIR_MODE 1
+# define PIPE_MODE 1
 
 psArray *psastroLoadReferences (pmConfig *config) {
@@ -8,5 +9,5 @@
     int fd;
     bool status;
-    char tempFile[64], tempLine[256];
+    char tempLine[256];
 
     // select the DVO database?
@@ -25,4 +26,31 @@
     // getstar -region RAmin RAmax DECmin DECmax
 
+# if PIPE_MODE
+    // use fork to add timeout capability
+    // use cfitsio |filename format to avoid tempFile
+    # if ELIXIR_MODE
+    sprintf (tempLine, "getstar -D CATFORMAT elixir -D CATMODE mef -region %f %f %f %f |", RAmin, DECmin, RAmax, DECmax, tempFile);
+    # else
+    sprintf (tempLine, "getstar -D CATFORMAT panstarrs -D CATMODE mef -region %f %f %f %f |", RAmin, DECmin, RAmax, DECmax, tempFile);
+    # endif
+
+    psTrace (__func__, 3, "%s\n", tempLine);
+
+    // the output from getstar is a file with the Average table
+    psFits *fits = psFitsOpen (tempLine, "r");
+
+    # if ELIXIR_MODE
+    psFitsMoveExtName (fits, "DVO_AVERAGE_ELIXIR");
+    # else
+    psFitsMoveExtName (fits, "DVO_AVERAGE_PANSTARRS");
+    # endif
+
+    psMetadata *header = psFitsReadHeader (NULL, fits);
+    psArray *table = psFitsReadTable (fits);
+    psFitsClose (fits);
+
+# else /***** use a temp file instead ****/
+
+    char tempFile[64];
     sprintf (tempFile, "/tmp/psastro.XXXXXX");
     if ((fd = mkstemp (tempFile)) == -1) {
@@ -61,4 +89,6 @@
     unlink (tempFile);
 
+# endif
+
     // convert the Average table to the pmAstromObj entries
     psArray *refs = psArrayAlloc (table->n);
Index: trunk/psastro/src/psastroParseCamera.c
===================================================================
--- trunk/psastro/src/psastroParseCamera.c	(revision 7385)
+++ trunk/psastro/src/psastroParseCamera.c	(revision 7573)
@@ -44,17 +44,2 @@
     return true;
 }
-
-
-// useful for debugging
-# if 0
-for (int i = 0; i < input->fpa->chips->n; i++) {
-    pmChip *chip = input->fpa->chips->data[i];
-    fprintf (stderr, "chip %2d: %x %x\n", i, chip->file_exists, chip->process);
-
-    for (int j = 0; j < chip->cells->n; j++) {
-	pmCell *cell = chip->cells->data[j];
-	fprintf (stderr, "cell %2d: %x %x\n", j, cell->file_exists, cell->process);
-
-    }
-}
-# endif
