even/Makefile
2024-04-01 04:18:49 +08:00

68 lines
1.4 KiB
Makefile

TARGET = x86_64-w64-mingw32
CC = $(TARGET)-gcc
RC = $(TARGET)-windres
ifdef prefix
PREFIX = $(prefix)
else
PREFIX = /usr/$(TARGET)
endif
CFLAGS = -Wall -Wpedantic -DNDEBUG -I$(PREFIX)/include/ddk -O0 -std=c2x
LDFLAGS = -Wl,--subsystem,native \
-Wl,--image-base,0x10000 \
-Wl,--file-alignment,0x1000 \
-Wl,--section-alignment,0x1000 \
-Wl,--entry,DriverEntry@8 \
-mdll -nostartfiles -nostdlib
VERSION = $(shell git describe --tags --dirty | sed 's/^v//' 2> /dev/null)
ifneq ($(VERSION),)
CFLAGS += -DEVEN_VERSION=\"$(VERSION)\"
RCFLAGS += -DEVEN_VERSION=\\\"$(VERSION)\\\"
endif
# Kernel-mode libs:
# libntoskrnl = basic kernel-mode environment
# libhal = WRITE_PORT_UCHAR et al.
#KRNLIBS = -lntoskrnl -lhal
KRNLIBS = -lntoskrnl
LDFLAGS += $(KRNLIBS)
.SUFFIXES: .sys
.PHONY: clean third_party docker dist
all: even.sys
even.o: even_names.h even_ioctl.h even_peb.h third_party/utlist.h
%.res.o: %.rc
$(RC) -i $< -o $@ $(RCFLAGS)
%.sys: %.o %.res.o
$(CC) $^ -o $@ $(LDFLAGS) -Wl,--pdb,$*.pdb -s
clean:
$(RM) *.o *.sys *.pdb
third_party/utlist.h: .peru/lastimports
third_party: .peru/lastimports
peru reup --force
.peru/lastimports: peru.yaml
peru sync || :
dist/:
mkdir -p $@
docker: Dockerfile .dockerignore dist/
docker build -t even --build-arg VERSION="$(VERSION)" .
docker create --name even-build even
docker export even-build | tar x -C dist
docker rm -f even-build