###############################################################################
# This file is part of the IPCop Firewall.                                    #
#                                                                             #
# IPCop 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.                                         #
#                                                                             #
# IPCop 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 IPCop; if not, write to the Free Software                        #
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA    #
#                                                                             #
# Makefiles are based on LFSMake, which is                                    #
# Copyright (C) 2002 Rod Roard <rod@sunsetsystems.com>                        #
#                                                                             #
# Modifications by:                                                           #
# ??-12-2003 Mark Wormgoor < mark@wormgoor.com>                               #
#          - Modified Makefile for IPCop build                                #
#                                                                             #
# $Id: cdrtools 4388 2010-03-21 21:36:11Z owes $
#                                                                             #
###############################################################################

###############################################################################
# Definitions
###############################################################################

include Config

PKG_NAME   = cdrtools
VER        = 2.01
HOST_ARCH  = all
OTHER_SRC  = yes

THISAPP    = cdrtools-$(VER)
DL_FILE    = $(THISAPP).tar.bz2
DL_FROM    = ftp://ftp.berlios.de/pub/cdrecord
DIR_APP    = $(DIR_SRC)/$(THISAPP)
TARGET     = $(DIR_INFO)/$(STAGE_ORDER)_$(STAGE)/$(THISAPP)

PATCH1     = $(THISAPP)-glibc_conflicts-3.patch

###############################################################################
# Top-level Rules
###############################################################################

objects	= $(DL_FILE) \
	$(PATCH1)

$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
$(PATCH1)  = $(URL_BLFS)/svn/$(PATCH1)

$(DL_FILE)_MD5 = d44a81460e97ae02931c31188fe8d3fd
$(PATCH1)_MD5  = 7803d3a2f79112a7d90a80b76e95a7a6

install : $(TARGET)

check : $(patsubst %,$(DIR_CHK)/%,$(objects))

download :$(patsubst %,$(DIR_DL)/%,$(objects))

md5 : $(subst %,%_MD5,$(objects))

###############################################################################
# Downloading, checking, md5sum
###############################################################################

$(patsubst %,$(DIR_CHK)/%,$(objects)) :
	@$(CHECK)

$(patsubst %,$(DIR_DL)/%,$(objects)) :
	@$(LOAD)

$(subst %,%_MD5,$(objects)) :
	@$(MD5)

###############################################################################
# Installation Details
###############################################################################

$(TARGET) : $(firstword $(MAKEFILE_LIST)) $(patsubst %,$(DIR_DL)/%,$(objects))
	@$(PREBUILD)
	@rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE)
	cd $(DIR_APP) && patch -Np1 -i $(DIR_DL)/$(PATCH1)

	cd $(DIR_APP) && sed -i -e "s/; sleep 5//" RULES/mk-gmake.id
	cd $(DIR_APP) && ./Gmake.linux -j $(PARALLELISM) INS_BASE=/usr install

	@rm -rf $(DIR_APP)
	@$(POSTBUILD)
