###############################################################################
# $Id: Makefile,v 1.14 2010/09/26 21:53:58 tw Exp $
#
# Build and install converter to Rigol DG function generator data.
#
# Copyright (C) 2009, 2010 Thomas Weidenfeller
# 
# This file is part of gds2000tools/gds-funcgen.
# 
# gds2000tools/gds-funcgen is free software: you can redistribute it
# and/or modify it under the terms of the GNU General Public License
# version 3 as published by the Free Software Foundation.
# 
# gds2000tools/gds-funcgen is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with gds2000tools/gds-funcgen.  If not,
# see <http://www.gnu.org/licenses/>.
###############################################################################

TOP	= ..
include $(TOP)/config.mk

INSTALL_FLAGS =

TARGETS	= gds-csv-to-afg gds-csv-to-rigol
LIBS	= $(TARGETS:=.awk) gds-csv-common.awk
#SRCS	= $(TARGETS:=.sh) $(LIBS)
SRCS	= $(TARGETS) $(LIBS)
HDRS	=
OBJS	=
MANS	= $(TARGETS:=.1)

default: all
all:
.PHONY: default all

clean::
	-$(RM) -f *~ *.bak

###############################################################################
# Installation
#
install: install-bin install-lib install-man
install-bin: $(TARGETS)
	if [ `id -u` -eq 0 ] ;					\
	then	 						\
		UG="-o bin -g bin";				\
	else 							\
		UG="" ;						\
	fi;							\
	install $(INSTALL_FLAGS) -m 755 $$UG -d $(BINDIR);      \
	install $(INSTALL_FLAGS) -m 755 $$UG $(TARGETS) $(BINDIR)

install-lib: $(LIBS)
	if [ `id -u` -eq 0 ] ;					\
	then	 						\
		UG="-o bin -g bin";				\
	else 							\
		UG="" ;						\
	fi;							\
	install $(INSTALL_FLAGS) -m 755 $$UG -d $(LIBDIR);      \
	install $(INSTALL_FLAGS) -m 644 $$UG $(LIBS) $(LIBDIR)

install-man: $(MANS)
	if [ `id -u` -eq 0 ] ;					\
	then	 						\
		UG="-o bin -g bin";				\
	else 							\
		UG="" ;						\
	fi;							\
	install $(INSTALL_FLAGS) -m 755 $$UG -d $(MAN1DIR);     \
	install $(INSTALL_FLAGS) -m 644 $$UG $(MANS) $(MAN1DIR)

.PHONY: install install-man install-lib install-bin
