mirror of
https://gitea.tendokyu.moe/self/even
synced 2024-12-18 10:35:57 +01:00
81 lines
2.1 KiB
Makefile
81 lines
2.1 KiB
Makefile
#
|
|
# by Frank Rysanek <rysanek@fccps.cz>
|
|
#
|
|
# Based on the source code of ioperm.c by Marcel Telka <marcel@telka.sk>
|
|
# - thanks a million :-)
|
|
#
|
|
|
|
# See also my_names.h
|
|
# Note that after changing the driver name, you also have
|
|
# to rename $(DRVNAME).c manually in this directory :-)
|
|
DRVNAME = even
|
|
|
|
INCLUDES = -I/usr/x86_64-w64-mingw32/sys-root/mingw/include/ddk
|
|
INCLUDES +=
|
|
|
|
# We could in fact just add -DEVEN_DRIVER_NAME=\"$(DRVNAME)\" to CFLAGS,
|
|
# but we'd have to be careful to "make clean" after changing
|
|
# the driver name here in the makefile...
|
|
#CFLAGS = -Wall $(INCLUDES) -DEVEN_DRIVER_NAME=\"$(DRVNAME)\"
|
|
CFLAGS = -Wall $(INCLUDES)
|
|
|
|
# Kernel-mode libs:
|
|
# libntoskrnl = basic kernel-mode environment
|
|
# libhal = WRITE_PORT_UCHAR et al.
|
|
#KRNLIBS = -lntoskrnl -lhal
|
|
KRNLIBS = -lntoskrnl
|
|
|
|
CC = x86_64-w64-mingw32-gcc
|
|
DLLTOOL = x86_64-w64-mingw32-dlltool
|
|
STRIP = x86_64-w64-mingw32-strip
|
|
|
|
all: $(DRVNAME).sys
|
|
|
|
# Dependencies on header files:
|
|
$(DRVNAME).sys: even_names.h
|
|
$(DRVNAME).sys: even_ioctl.h
|
|
|
|
# This shall get appended to the built-in set of suffixes supported:
|
|
.SUFFIXES: .sys .exe
|
|
# Otherwise the custom inference rules below wouldn't ever kick in.
|
|
|
|
# This is implicit, no need to define this explicitly:
|
|
#.c.o:
|
|
# $(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
# This inference rule allows us to turn an .o into a .sys without
|
|
# much hassle, implicitly.
|
|
# The downside is, that you cannot potentially add further object files
|
|
# to get linked into the .sys driver (such as, some custom ASM routines).
|
|
# Oh wait, maybe you can... try adding your .o after the last $(CC) in the rule...
|
|
.o.sys:
|
|
$(CC) -Wl,--base-file,$*.base \
|
|
-Wl,--entry,DriverEntry@8 \
|
|
-nostartfiles -nostdlib \
|
|
-o junk.tmp \
|
|
$*.o \
|
|
$(KRNLIBS)
|
|
-rm -f junk.tmp
|
|
$(DLLTOOL) --dllname $*.sys \
|
|
--base-file $*.base --output-exp $*.exp
|
|
$(CC) -Wl,--subsystem,native \
|
|
-Wl,--image-base,0x10000 \
|
|
-Wl,--file-alignment,0x1000 \
|
|
-Wl,--section-alignment,0x1000 \
|
|
-Wl,--entry,DriverEntry@8 \
|
|
-Wl,$*.exp \
|
|
-mdll -nostartfiles -nostdlib \
|
|
-o $*.sys \
|
|
$*.o \
|
|
$(KRNLIBS)
|
|
$(STRIP) $*.sys
|
|
|
|
JUNK = *.base *.exp *.o *~ junk.tmp
|
|
|
|
clean:
|
|
rm -f $(JUNK) *.sys
|
|
|
|
semiclean:
|
|
rm -f $(JUNK)
|
|
|