#
#   Makefile for making the executable of program MOPAC
#
#
#    Valid Commands of this makefile
#
#	make		Makes the MOPAC file
#	make clean	Clean up disk to minimum config
#       make install    Install binaries, tests and documentation
#       make uninstall  Remove installed files
#
FC              = fort77
CC              = gcc
FFLAGS	        = -O -w
CFLAGS	        = -O
HDRS		= SIZES
SRCS		:= $(shell ls *.f)
CSRCS           := $(shell ls *.c) 
OBJS		= $(SRCS:.f=.o) $(CSRCS:.c=.o)
SIZEDEPSRC	:= $(shell grep -l -i '      INCLUDE ' *.f; true)
SIZEDEPEND	= $(SIZEDEPSRC:.f=.o)
MOPAC		= MOPAC7
MOPACSHELL	= mopac
BINDIR		= /usr/bin
OWNER		= root.bin

$(MOPAC):     	SIZES $(OBJS) 
		@echo -n "Loading $@ ... "
		$(F77) -O $(OBJS) -o $@
		@echo "done"

clean:
	 	$(RM) $(OBJS) $(MOPAC) *.trace core


cleanall:	clean
		$(RM) $(MOPAC)

uninstall:
		$(RM) -rf $(BINDIR)/$(MOPAC) $(BINDIR)/$(MOPACSHELL)

install:
		strip $(MOPAC)
		chmod 755 $(MOPAC) $(MOPACSHELL)
		chown $(OWNER) $(MOPAC) $(MOPACSHELL)
		cp -p $(MOPAC) $(BINDIR)/$(MOPAC)
		cp -p $(MOPACSHELL) $(BINDIR)/$(MOPACSHELL)

###
