# Makefile for Linux System V init utility
#
# 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.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# History:
# Date		Author			Comment
# 07-22-2005	Victor Yu.		Create it.
#

CROSS_COMPILE=xscale_be-
TARGET=sysvinit
DIRS = src #contrib

all:
	for i in $(DIRS) ; do \
		unset LDFLAGS CFLAGS CPPFLAGS CXXFLAGS && \
		make CC=$(CROSS_COMPILE)gcc CXX=$(CROSS_COMPILE)g++ LD=$(CROSS_COMPILE)ld CPP=$(CROSS_COMPILE)cpp STRIP=$(CROSS_COMPILE)strip -C $$i $@; \
	done

romfs:
	$(STRIP) -s src/init src/halt src/shutdown
	$(ROMFSINST) src/init /sbin/init
	$(ROMFSINST) src/halt /sbin/halt
	$(ROMFSINST) src/shutdown /sbin/shutdown
	( cd  ${ROMFSDIR}/sbin; \
	[ -L telinit ] || ln -s halt telinit; \
	[ -L reboot ] || ln -s halt reboot; \
	[ -L poweroff ] || ln -s halt poweroff; \
	)

package: moxa-install.header $(TARGET).tar.gz
	mkdir -p installer
	cat moxa-install.header $(TARGET).tar.gz > installer/$(TARGET)_install.sh
	chmod 755 installer/$(TARGET)_install.sh


clean distclean:
	for i in $(DIRS) ; do \
		make -C $$i clobber ;\
	done
	rm -rf installer/*
