#  Makefile - libredhat-kernel.so build code.
#
#    Copyright 2002 Red Hat, Inc.  All Rights Reserved.
#
#    This library is free software; you can redistribute it and/or
#    modify it under the terms of the GNU Lesser General Public
#    License as published by the Free Software Foundation; either
#    version 2 of the License, or (at your option) any later version.
#
#    This library 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
#    Lesser General Public License for more details.
#
#    You should have received a copy of the GNU Lesser General Public
#    License along with this library; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
#
#
all: libredhat-kernel.so

ASFLAGS=-D__KERNEL__ -D__ASSEMBLY__ -I../include -nostdlib -nostartfiles
CFLAGS=-D__KERNEL__ -I../include -nostdlib -nostartfiles

so_objs=vsysaddr.o kso_init.o

vsysaddr.S: ../System.map stub.S Makefile
	rm -f vsysaddr.S
	echo '#include "stub.S"' >vsysaddr.S
	awk -- "/^00000000bfff.* vsys_/ { print \"dynamic_syscall(\"\$$3 \",0x\" \$$1 \")\"; }" <../System.map >>vsysaddr.S
	awk -- "/^bfff.* vsys_/ { print \"dynamic_syscall(\"\$$3 \",0x\" \$$1 \")\"; }" <../System.map >>vsysaddr.S

vsysaddr.o: vsysaddr.S

kso_init.o: ../include/linux/compile.h

libredhat-kernel.so.1.0.1: $(so_objs) libredhat-kernel.map
	gcc -nostdlib -nostartfiles -shared -Wl,--version-script=libredhat-kernel.map -Wl,-soname=libredhat-kernel.so.1 -o $@  $(so_objs)
	cp $@ $@.save
	strip $@

libredhat-kernel.so: libredhat-kernel.so.1.0.1
	ln -sf $< $@

clean:
	rm -f *.o libredhat-kernel.so myln libredhat-kernel.so.1* vsysaddr.S libredhat-kernel.so.1.save

# test app
myln: myln.c libredhat-kernel.so Makefile
	cc -g -o myln myln.c -L. -lredhat-kernel
