-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Makefile
90 lines (70 loc) · 2.03 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
CC=gcc
WINDRES=windres
OBJ_SUFFIX = .o
EXE_NAME = softgpu
EXE_SUFFIX = .exe
LDFLAGS=-static
ifdef DEBUG
LIBS=-lgdi32 -luser32 -ladvapi32 -lkernel32 -lshell32 -lversion -Wl,-subsystem,console
CFLAGS=-std=c99 -Wall -Wextra -g -O0 -march=pentium2 -fdata-sections -ffunction-sections
else
LIBS=-lgdi32 -luser32 -ladvapi32 -lkernel32 -lshell32 -lversion -Wl,-subsystem,windows
CFLAGS=-std=c99 -Wall -Wextra -Os -march=pentium2 -fdata-sections -ffunction-sections
endif
SOFTGPU_PATCH=2024
ifdef EXTRA_INFO
CFLAGS += -DEXTRA_INFO="$(EXTRA_INFO)"
endif
ifdef EXTRA_ICO
RES_FLAGS += -DEXTRA_ICO="$(EXTRA_ICO)"
endif
NULLOUT=$(if $(filter $(OS),Windows_NT),NUL,/dev/null)
GIT ?= git
GIT_IS := $(shell $(GIT) rev-parse --is-inside-work-tree 2> $(NULLOUT))
ifeq ($(GIT_IS),true)
VERSION_BUILD := $(shell $(GIT) rev-list --count main)
endif
NOCRT=1
all: $(EXE_NAME)$(EXE_SUFFIX)
.PHONY: all clean
SOURCES = \
actions.c \
filecopy.c \
softgpu.c \
winini.c \
windrv.c \
winreg.c \
winres.c \
setuperr.c \
window.c \
settings.c \
gpudetect.c \
resource/softgpu.rc
ifdef NOCRT
SOURCES += \
nocrt/nocrt.c \
nocrt/nocrt_exe.c \
nocrt/nocrt_file_win.c \
nocrt/nocrt_mem_win.c \
nocrt/nocrt_math.c
LDFLAGS += -nostdlib -nodefaultlibs -lgcc
CFLAGS += -Inocrt -DNOCRT -DNOCRT_FILE -DNOCRT_FLOAT -DNOCRT_MEM -ffreestanding -nostdlib
endif
CFLAGS += -DSOFTGPU_PATCH=$(SOFTGPU_PATCH)
RES_FLAGS += -DSOFTGPU_PATCH=$(SOFTGPU_PATCH)
ifdef VERSION_BUILD
CFLAGS += -DSOFTGPU_BUILD=$(VERSION_BUILD)
RES_FLAGS += -DSOFTGPU_BUILD=$(VERSION_BUILD)
endif
DEPS := Makefile softgpu.h
%.c.o: %.c $(DEPS)
$(CC) $(CFLAGS) -c -o $@ $<
%.rc.res: %.rc
$(WINDRES) $(RES_FLAGS) --input $< --output $@ --output-format=coff
OBJS := $(SOURCES:.c=.c$(OBJ_SUFFIX))
OBJS := $(OBJS:.rc=.rc.res)
$(EXE_NAME)$(EXE_SUFFIX): $(OBJS)
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $@ $(LIBS)
clean:
-$(RM) $(OBJS)
-$(RM) $(EXE_NAME)$(EXE_SUFFIX)