even/Makefile

68 lines
1.4 KiB
Makefile
Raw Normal View History

2024-04-01 03:23:51 +08:00
TARGET = x86_64-w64-mingw32
2024-04-01 02:23:11 +08:00
2024-04-01 03:23:51 +08:00
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
2024-04-01 02:23:11 +08:00
LDFLAGS = -Wl,--subsystem,native \
-Wl,--image-base,0x10000 \
-Wl,--file-alignment,0x1000 \
-Wl,--section-alignment,0x1000 \
-Wl,--entry,DriverEntry@8 \
2024-04-01 03:04:58 +08:00
-mdll -nostartfiles -nostdlib
2024-04-01 02:23:11 +08:00
2024-04-01 04:05:36 +08:00
VERSION = $(shell git describe --tags --dirty | sed 's/^v//' 2> /dev/null)
2024-04-01 02:23:11 +08:00
ifneq ($(VERSION),)
CFLAGS += -DEVEN_VERSION=\"$(VERSION)\"
RCFLAGS += -DEVEN_VERSION=\\\"$(VERSION)\\\"
2024-03-31 17:31:50 +08:00
endif
2024-04-01 02:23:11 +08:00
# Kernel-mode libs:
2024-03-30 14:28:40 +08:00
# libntoskrnl = basic kernel-mode environment
# libhal = WRITE_PORT_UCHAR et al.
#KRNLIBS = -lntoskrnl -lhal
KRNLIBS = -lntoskrnl
2024-04-01 02:23:11 +08:00
LDFLAGS += $(KRNLIBS)
2024-03-30 14:28:40 +08:00
2024-04-01 02:23:11 +08:00
.SUFFIXES: .sys
2024-03-30 14:28:40 +08:00
2024-04-01 04:18:49 +08:00
.PHONY: clean third_party docker dist
2024-03-30 14:28:40 +08:00
2024-04-01 02:23:11 +08:00
all: even.sys
2024-03-30 14:28:40 +08:00
2024-04-01 02:23:11 +08:00
even.o: even_names.h even_ioctl.h even_peb.h third_party/utlist.h
2024-03-30 14:28:40 +08:00
2024-04-01 02:23:11 +08:00
%.res.o: %.rc
$(RC) -i $< -o $@ $(RCFLAGS)
2024-03-30 14:28:40 +08:00
2024-04-01 02:23:11 +08:00
%.sys: %.o %.res.o
2024-04-01 03:04:58 +08:00
$(CC) $^ -o $@ $(LDFLAGS) -Wl,--pdb,$*.pdb -s
2024-03-30 14:28:40 +08:00
clean:
2024-04-01 03:04:58 +08:00
$(RM) *.o *.sys *.pdb
2024-04-01 02:23:11 +08:00
third_party/utlist.h: .peru/lastimports
2024-03-30 14:28:40 +08:00
2024-04-01 02:23:11 +08:00
third_party: .peru/lastimports
2024-04-01 02:46:55 +08:00
peru reup --force
2024-03-30 14:28:40 +08:00
2024-04-01 02:23:11 +08:00
.peru/lastimports: peru.yaml
2024-04-01 02:46:55 +08:00
peru sync || :
2024-04-01 04:18:49 +08:00
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