#++++++++++++++++
#.IDENTIFICATION Makefile
#.LANGUAGE       Make (makefile script)
#.AUTHOR         Francois Ochsenbein [CDS]
#.ENVIRONMENT    Unix
#.KEYWORDS       
#.VERSION  1.0   03-Mar-1997
#.VERSION  2.0   19-Oct-1998: USNO-A2.0
#.PURPOSE        (Re)Create dependent files in this Directory
#.COMMENTS       The script check.sys is assumed to exist.
#		It creates in a local file .sys the `uname -m` value
#		followed by the necessary -l options
#----------------

SHELL=/bin/sh
#MACHINE=local

# Defaut rule (e.g. copy from a public directory)
.DEFAULT:

# Programs:
CC      = cc
COPY    = cp -p
STRIP   = strip
RANLIB  = ranlib
AR      = ar ruv

# Directories:
PREFIX   = ..
BINDIR   = $(PREFIX)/bin
SHSDIR   = $(PREFIX)/bin
MANDIR   = $(PREFIX)/man

# Files:
EXPORT  = usnob1.h usnob1def.h ReadMe *.h *.c 
BIN     = usnob1 tycho_index usnob1_read usnob_make
SHS     =
MAN     =

# Options:
DEBUG = -O
C_OPT = 
SYS =
CFLAGS = $(C_OPT) $(local_CFLAGS) $(DEBUG) $(SYS) -I. 
COMPILE= $(CC) $(CFLAGS) -c
LIBSYS = $(local_LIBSYS) -lm

# RULES: If the default rules haven't to be applied, remove the #
.SUFFIXES: 


# Dependencies:
default: usnob1 

install: install_bin 

install_bin: usnob1
	@if test -d $(BINDIR); then echo ....$(BINDIR) exists; \
	else echo ....Creating $(BINDIR) && mkdir $(BINDIR); \
	fi
	$(COPY) usnob1 ../bin

pmm80: pmm80.c usnob1.h
	$(CC) -I. pmm80.c -o $@

usnob_make: usnob_make.c
	$(CC) $(CFLAGS) $@.c -o $@

usnob_sub: usnob_sub.c
	$(CC) -DTEST $(CFLAGS) $@.c -o $@ -lm

usnob1: usnob1.c usnob_sub.c
	$(CC) $(CFLAGS) usnob1.c usnob_sub.c -o $@ -lm

tycho_index: tycho_index.c
	$(CC) $(CFLAGS) $@.c usnob_sub.c -o $@ -lm

usnob1_read: usnob1_read.c 
	$(CC) $(CFLAGS) $@.c usnob_sub.c -o $@ -lm

export: /tmp/usnob.tar.gz

/tmp/usnob.tar.gz: $(EXPORT) Makefile
	$(MAKE) CLEAN
	-test -d /tmp/src && rm -rf /tmp/src
	mkdir /tmp/src
	cp -p `ls $(EXPORT)|fgrep -v _v.` Makefile /tmp/src
	cd /tmp && tar cfv /tmp/usnob.tar src
	gzip -v9 /tmp/usnob.tar
	rm -rf /tmp/usnob

# Clean up everything
clean:
	rm -f core a.out *.o *.log *.lis *.dvi *.ps *.aux *.trace
	rm -f .sys

CLEAN:	clean
	rm -f *.a $(BIN)
