#******************************************************************************
#                                  Makefile                                   *
#                                 ----------                                  *
# Description : House-keeping for the GNU Spice GUI Project example schematic *
#               files.                                                        *
# Started     : 20/01/2004                                                    *
# Last update : 28/09/2011                                                    *
# Copyright   : (C) 2004 by MSWaters                                          *
# Email       : M.Waters@bom.gov.au                                           *
#******************************************************************************

#******************************************************************************
#                                                                             *
#     This program is free software; you can redistribute it and/or modify    *
#     it under the terms of the GNU General Public License as published by    *
#     the Free Software Foundation; either version 2 of the License, or       *
#     (at your option) any later version.                                     *
#                                                                             *
#******************************************************************************

#******************************************************************************
# Specify string values
#******************************************************************************

# Root directory
ROOT := $(shell pwd)

# Objects
OBJS := $(patsubst %.sch, %.ckt, $(wildcard */*.sch))

# Install directory
INSTALLDIR = /usr/local

#******************************************************************************
# Make these targets
#******************************************************************************

all : $(OBJS)

# Schematic to netlist conversion rules :
#   -v  verbose mode (gives as much feedback to the user as possible)
#   -q  quiet   mode (turns off all warnings / notes / messages)
#   -g  the guile procedure executed to create the netlist
#   -o  place output file in $@
#   $<  is the name of the first dependency
#   $@  is the file name of the target

%.ckt : %.sch
	@cd $(dir $<) ; gnetlist -g spice-sdb -o $(notdir $@) $(notdir $<)
	@echo

#******************************************************************************
# Perform installation tasks
#******************************************************************************

install :
	cp -r $(ROOT) $(INSTALLDIR)/share/gspiceui

#******************************************************************************
# Perform uninstall tasks
#******************************************************************************

uninstall :
	rm -fr $(INSTALLDIR)/share/gspiceui/sch

##******************************************************************************
# Remove temporary files and backup files
#******************************************************************************

clean :
	rm -f Makefile~ */*.gnucap.?? */*.ngspice.?? */*.ckt */*.sim */*.log */*.sch~

#******************************************************************************
# Specify phony targets
#******************************************************************************

.PHONY : install uninstall clean

#******************************************************************************
