📄 makefile
字号:
DISTFILES=divdi3.c hal.c iw_ndis.c iw_ndis.h loader.c loader.h \ longlong.h Makefile crt.c ndis.c ndis.h \ ndiswrapper.h ntoskernel.c ntoskernel.h ntoskernel_io.c \ pe_linker.c pe_linker.h pnp.c pnp.h proc.c rtl.c usb.c usb.h \ winnt_types.h workqueue.c wrapmem.h wrapmem.c wrapper.c \ wrapndis.h wrapndis.c lin2win.h win2lin_stubs.SKVERS ?= $(shell uname -r)KPSUB := $(shell echo $(KVERS) | sed -e 's/\([^\.]*\)\.\([^\.]*\)\..*/\1\2/')# distros use different paths for kernel include filesKBUILD ?= /lib/modules/$(KVERS)/buildKSRC ?= $(shell if \ [ -f /lib/modules/$(KVERS)/source/include/linux/kernel.h ]; then \ echo /lib/modules/$(KVERS)/source ; \ else \ echo $(KBUILD); \ fi)ifdef DIST_DESTDIRDESTDIR = $(DIST_DESTDIR)elseDESTDIR ?= /endifINST_DIR ?= $(shell echo $(DESTDIR)/lib/modules/$(KVERS)/misc | sed 's^//^/^g')SRC_DIR=$(shell pwd)KREV := $(shell echo $(KVERS) | sed -e 's/[^\.]*\.[^\.]*\.\([0-9]*\).*/\1/')-include $(KBUILD)/.configCFLAGS += $(shell [ -f $(KSRC)/include/linux/modversions.h ] && \ echo -DEXPORT_SYMTAB -DMODVERSIONS \ -include $(KSRC)/include/linux/modversions.h)ifndef DISABLE_USBCFLAGS += $(shell if grep -q 'struct module \*owner;' \ $(KSRC)/include/linux/usb.h ; then \ echo -DUSB_DRIVER_OWNER; \ fi)endif# returns of structs and unions in registers when possible, like Windows CFLAGS += -freg-struct-return# to produce debug trace, add option "DEBUG=<n>" where <n> is 1 to 6ifdef DEBUGCFLAGS += -DDEBUG=$(DEBUG) -gendif# to debug timers, add option "TIMER_DEBUG=1 DEBUG=<n>"ifdef TIMER_DEBUGCFLAGS += -DTIMER_DEBUGendif# to debug event layer, add option "EVENT_DEBUG=1 DEBUG=<n>"ifdef EVENT_DEBUGCFLAGS += -DEVENT_DEBUGendif# to debug USB layer, add option "USB_DEBUG=1 DEBUG=<n>"ifdef USB_DEBUGCFLAGS += -DUSB_DEBUGendif# to debug I/O layer, add option "USB_DEBUG=1 DEBUG=<n>"ifdef IO_DEBUGCFLAGS += -DIO_DEBUGendif# to debug worker threadsifdef WORK_DEBUGCFLAGS += -DWORK_DEBUGendif# if ALLOC_DEGUG=1 is defined, memory leak information is printed#if ALLOC_DEBUG=2, details about individual allocations leaking is printed#if ALLOC_DEBUG=3, tags in ExAllocatePoolWithTag leaking printedifdef ALLOC_DEBUGCFLAGS += -DALLOC_DEBUG=$(ALLOC_DEBUG)endif.PHONY: prereq_check gen_exports clean dist_clean install stack_checkall : prereq_check win2lin_stubs.h gen_exports default stack_checkOBJS := crt.o hal.o iw_ndis.o loader.o ndis.o ntoskernel.o ntoskernel_io.o \ pe_linker.o pnp.o proc.o rtl.o wrapmem.o wrapndis.o wrapper.o# by default, USB layer is compiled in if USB support is in kernel;# to disable USB support in ndiswrapper even if USB support is in kenrel,# add option "DISABLE_USB=1"ifdef DISABLE_USBusb_exports.h:CFLAGS += -DDISABLE_USBelseusb_exports.h: usb.cifeq ($(CONFIG_USB),y)OBJS += usb.oendififeq ($(CONFIG_USB),m)OBJS += usb.oendifendififeq ($(KPSUB),24)CFLAGS += -DUSE_OWN_WQOBJS += workqueue.oendifCFLAGS += $(shell if grep -s -A1 'ndiswrapper' $(KSRC)/kernel/module.c | \ grep -q 'add_taint_module' ; then \ echo -DUSE_OWN_WQ; \ fi)ifdef USE_OWN_WQCFLAGS += -DUSE_OWN_WQOBJS += workqueue.oendifntoskernel.h: lin2win.hndis.h: ntoskernel.hiw_ndis.h: ntoskernel.hpnp.h: ntoskernel.h ndis.hwrapndis.h: ndis.h pnp.husb.h: ntoskernel.hdivdi3.o: divdi3.c longlong.hhal.o: hal.c ntoskernel.hiw_ndis.o: iw_ndis.c iw_ndis.h wrapndis.hloader.o: loader.c loader.h ndis.h wrapndis.hcrt.o: crt.c ndis.hndis.o: ndis.c ndis.h iw_ndis.h wrapndis.hwrapndis.o: wrapndis.c wrapndis.hntoskernel.o: ntoskernel.c ndis.h usb.hntoskernel_io.o: ntoskernel_io.c ndis.h usb.hpe_linker.o: pe_linker.cpnp.o: pnp.cproc.o: proc.c ndis.h iw_ndis.h wrapndis.hrtl.o: rtl.c ndis.husb.o: usb.c usb.h ndis.hwrapper.o: wrapper.c wrapndis.h iw_ndis.h ntoskernel.h loader.hifeq ($(CONFIG_X86_64),y)OBJS += win2lin_stubs.owin2lin_stubs.o: win2lin_stubs.h win2lin_stubs.Sifdef DISABLE_USBwin2lin_stubs.h: hal.c crt.c ndis.c ntoskernel.c ntoskernel_io.c \ pnp.c rtl.c wrapndis.celsewin2lin_stubs.h: hal.c crt.c ndis.c ntoskernel.c ntoskernel_io.c \ pnp.c rtl.c usb.c wrapndis.cendif @for file in $^; do \ echo; \ echo "# automatically generated from $$file"; \ sed -n \ -e 's/.*WIN_FUNC(\([^\,]\+\) *\, *\([0-9]\+\)).*/\ win2lin(\1, \2)/p' \ -e 's/.*WIN_FUNC_PTR(\([^\,]\+\) *\, *\([0-9]\+\)).*/\ win2lin(\1, \2)/p' \ $$file | sed -e 's/[ \t ]\+//' | sort -u; \ done > $@elsewin2lin_stubs.h:OBJS += divdi3.oendif# generate exports symbol table from C files%_exports.h: %.c @if :; then \ echo "/* automatically generated from $< */"; \ echo "#ifdef CONFIG_X86_64"; \ sed -n \ -e 's/.*WIN_FUNC(\([^\,]\+\) *\, *\([0-9]\+\)).*/\ WIN_FUNC_DECL(\1, \2)/p' \ -e 's/.*WIN_FUNC_PTR(\([^\,]\+\) *\, *\([0-9]\+\)).*/\ WIN_FUNC_DECL(\1, \2)/p' \ $< | sed -e 's/[ \t ]\+//' | sort -u; \ echo "#endif"; \ echo "struct wrap_export $(basename $<)_exports[] = {";\ sed -n \ -e 's/.*WIN_FUNC(_win_\([^\,]\+\) *\, *\([0-9]\+\)).*/\ WIN_WIN_SYMBOL(\1,\2),/p' \ -e 's/.*WIN_FUNC(\([^\,]\+\) *\, *\([0-9]\+\)).*/\ WIN_SYMBOL(\1,\2),/p' \ -e 's/.*WIN_SYMBOL_MAP(\("[^"]\+"\)[ ,\n]\+\([^)]\+\)).*/\ {\1,(generic_func)\2},/p' \ $< | sed -e 's/[ \t ]*/ /' | sort -u; \ echo " {NULL, NULL}"; \ echo "};"; \ fi > $@gen_exports: crt_exports.h ndis_exports.h hal_exports.h ntoskernel_exports.h \ ntoskernel_io_exports.h rtl_exports.h usb_exports.hprereq_check: @if [ ! -f $(KBUILD)/include/linux/version.h ]; then \ echo "Can't find kernel build files in $(KBUILD);"; \ echo " give the path to kernel build directory with " ; \ echo " KBUILD=<path> argument to make";\ exit 1;\ fi @if [ ! -f $(KSRC)/include/linux/kernel.h ]; then \ echo "Can't find kernel build files in $(KSRC);"; \ echo " give the path to kernel build directory with " ; \ echo " KSRC=<path> argument to make";\ exit 1;\ ficlean: rm -rf $(MODULE) ndiswrapper.o $(OBJS) usb.o win2lin_stubs.o \ divdi3.o workqueue.o .*.ko.cmd .*.o.cmd \ ndiswrapper.mod.[oc] *~ .tmp_versions Modules.symvers Module.symversdistclean: clean rm -f *_exports.h .\#* win2lin_stubs.h built-in.oifeq ($(KPSUB),24)MODULE := ndiswrapper.oCFLAGS += -DLINUX -D__KERNEL__ -DMODULE -I$(KSRC)/include \ -Wall -Wstrict-prototypes -fomit-frame-pointer \ -fno-strict-aliasing -pipe -O2ifneq ($(CONFIG_X86_64),y)CFLAGS += -mpreferred-stack-boundary=2 endifdefault: $(OBJS) $(LD) -r -o $(MODULE) $(OBJS)elseMODULE := ndiswrapper.koobj-m := ndiswrapper.o ndiswrapper-objs := $(OBJS)default: $(MAKE) -C $(KBUILD) SUBDIRS=$(SRC_DIR)endifstack_check: @if [ "x$(CONFIG_X86_64)" = "x" -a $(KPSUB) -eq 26 ] && \ ! grep -q CONFIG_4KSTACKS $(KBUILD)/.config || \ grep -q "CONFIG_4KSTACKS=y" $(KBUILD)/.config; then \ echo; echo; \ echo "*** WARNING: This kernel seems to use 4K stack size"\ "option (CONFIG_4KSTACKS); many Windows drivers will"\ "not work with this option enabled. Disable"\ "CONFIG_4KSTACKS option, recompile and install kernel";\ echo; echo; \ fiinstall: prereq_check win2lin_stubs.h gen_exports default stack_check echo $(INST_DIR) mkdir -p $(INST_DIR) install -m 0644 $(MODULE) $(INST_DIR) -@/bin/rm -rf $(SRC_DIR)/.tmp_versionsifndef DIST_DESTDIR -/sbin/depmod -a $(KVERS) -b $(DESTDIR)endifdist: @for file in $(DISTFILES); do \ cp $$file $(distdir)/$$file; \ done
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -