# ktcpvs: Kernel TCP Virtaul Server Module NAME = ktcpvs VERSION = 0.0.14 # uncomment the following line for DEBUG DEBUGFLAGS = -g -DCONFIG_TCP_VS_DEBUG # need to specify the path of kernel source KERNELSOURCE = /usr/src/linux KERNELRELEASE = $(shell echo -e "\#include \nUTS_RELEASE" \ > conftest.c && \ gcc -E -I$(KERNELSOURCE)/include conftest.c | tail -1 \ | cut -d '"' -f 2 && rm -f conftest.c) KERNELSYMS = /boot/System.map-$(KERNELRELEASE) # As per the Linux Kernel's Makefile: # INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory # relocations required by build roots. This is not defined in the # makefile but the arguement can be passed to make if needed. MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)/kernel/net/ktcpvs/ # If System.map exists, run depmod. This deliberately does not have a # dependency on System.map since that would run the dependency tree on # vmlinux. This depmod is only for convenience to give the initial # boot a modules.dep even before / is mounted read-write. However the # boot script depmod is the master version. ifeq "$(strip $(INSTALL_MOD_PATH))" "" depmod_opts := else depmod_opts := -b $(INSTALL_MOD_PATH) -r endif CC = gcc CFLAGS = -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -DMODVERSIONS \ $(SMPFLAGS) $(DEBUGFLAGS) -O2 -Wall \ -Wstrict-prototypes -I$(KERNELSOURCE)/include \ -include $(KERNELSOURCE)/include/linux/modversions.h LIBS = regex/librxspencer.a TARGETS = ktcpvs.o ktcpvs_wlc.o ktcpvs_http.o ktcpvs_phttp.o ktcpvs_chttp.o all: $(TARGETS) make -C userspace ktcpvs.o: tcp_vs_ctl.o tcp_vs_sched.o tcp_vs_srvconn.o tcp_vs.o\ misc.o redirect.o tcp_vs_timer.o $(LIBS) $(LD) -r $^ -o $@ ktcpvs_wlc.o: tcp_vs_wlc.o $(LD) -r $^ -o $@ ktcpvs_http.o: tcp_vs_http.o $(LIBS) $(LD) -r $^ -o $@ ktcpvs_phttp.o: tcp_vs_phttp.o tcp_vs_http_parser.o tcp_vs_http_trans.o $(LIBS) $(LD) -r $^ -o $@ ktcpvs_chttp.o: tcp_vs_chttp.o tcp_vs_http_parser.o tcp_vs_http_trans.o avl.o $(LIBS) $(LD) -r $^ -o $@ avl.o: avl.c avl.h tcp_vs_ctl.o: tcp_vs_ctl.c tcp_vs.h $(LIBS) tcp_vs_http.o: tcp_vs_http.c tcp_vs.h $(LIBS) tcp_vs_phttp.o: tcp_vs_phttp.c tcp_vs.h $(LIBS) tcp_vs_chttp.o: tcp_vs_chttp.c tcp_vs.h $(LIBS) tcp_vs_http_parser.o: tcp_vs_http_parser.c tcp_vs.h $(LIBS) tcp_vs_http_trans.o: tcp_vs_http_trans.c tcp_vs.h $(LIBS) tcp_vs_timer.o: tcp_vs_timer.c tcp_vs.h $(LIBS) $(LIBS): (cd regex && ./configure && make) tcp_vs.o: $(LIBS) install: ktcpvs.o -rmmod ktcpvs insmod ktcpvs.o lsmod modules_install: $(TARGETS) if [ ! -d "$(MODLIB)" ]; then mkdir -p "$(MODLIB)"; fi install -m 600 -c $(TARGETS) "$(MODLIB)" depmod -ae -F $(KERNELSYMS) $(depmod_opts) $(KERNELRELEASE) modules_uninstall: (cd "$(MODLIB)"; rm -f $(TARGETS)) rmdir "$(MODLIB)" clean: rm -f *.o *~ *.bak *.orig *.rej $(NAME)-$(VERSION).tar.gz make -C userspace clean distclean: clean rm -f TAGS tags -make -C regex distclean dist: distclean (cd .. ; tar czvf $(NAME)-$(VERSION).tar.gz --exclude CVS ktcpvs) mv ../$(NAME)-$(VERSION).tar.gz . # # Coding style (Kernighan & Ritchie) plus -i8 and --procnames-start-lines # #indent: # find . -name "*.[ch]" | xargs indent -kr -i8 -psl