# $Id: #
#

.PHONY : clean 2.4.0 2.4.11 2.4.13 2.4.15 2.4.18 RH72

FLAGS=-Wall -O3

all:
	@echo "Ups, you should specify kernel version for which to build"
	@echo "Execute 'make 2.4.0' for kernels 2.4.0 - 2.4.10"
	@echo "Execute 'make 2.4.11' for kernels 2.4.11 - 2.4.12"
	@echo "Execute 'make 2.4.13' for kernels 2.4.13 - 2.4.14"
	@echo "Execute 'make 2.4.15' for kernels 2.4.15 - 2.4.17"
	@echo "Execute 'make 2.4.18' for kernel 2.4.18"
	@echo "Execute 'make 2.4.19ac' for kernel 2.4.19-pre10-ac2"
	@echo "Execute 'make WOLK3' for kernel 2.4.18-wolk3.x"
	@echo "Execute 'make WOLK4' for kernel 2.4.20-wolk4.x"
	@echo "Execute 'make RH72' for kernel 2.4.7-10 (RedHat 7.2)"
	@echo
	@false

2.4.0:
	sed  -e 's/NRSETCPUCAP/223/g' <cap.in >cap.c
	make cap

2.4.11:
	sed  -e 's/NRSETCPUCAP/225/g' <cap.in >cap.c
	make cap

2.4.13:
	sed  -e 's/NRSETCPUCAP/226/g' <cap.in >cap.c
	make cap

2.4.15:
	sed  -e 's/NRSETCPUCAP/226/g' <cap.in >cap.c
	make cap

2.4.18:
	sed  -e 's/NRSETCPUCAP/238/g' <cap.in >cap.c
	make cap

2.4.19ac:
	sed  -e 's/NRSETCPUCAP/243/g' <cap.in >cap.c
	make cap

WOLK3:
	sed  -e 's/NRSETCPUCAP/244/g' <cap.in >cap.c
	make cap

WOLK4:
	sed  -e 's/NRSETCPUCAP/260/g' <cap.in >cap.c
	make cap

RH72:
	sed  -e 's/NRSETCPUCAP/223/g' <cap.in >cap.c
	make cap

cap: cap.c
	gcc $(FLAGS) -o cap cap.c

install: cap
	strip cap
	install -s --backup=off cap /usr/bin/
	install --backup=off cap.8 /usr/share/man/man8/

clean:
	rm -f cap cap.c

