-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMakefile
63 lines (45 loc) · 1.34 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
# GNU makefile for tf2patcher
CC = gcc
CFLAGS += -Wall -Wextra -Werror -Wno-unused-parameter -O2 -std=c11
bindir := bin
objdir := obj
srcdir := src
dirs := $(bindir) $(objdir) $(srcdir)
headers := $(wildcard $(srcdir)/*.h)
sources := $(wildcard $(srcdir)/*.c)
objects := $(sources:$(srcdir)/%.c=$(objdir)/%.o)
appname := tf2patcher
appfile := $(bindir)/$(appname)
ifeq ($(TARGET),64)
restarget := pe-x86-64
cctarget := -m64
else
restarget := pe-i386
cctarget := -m32
endif
ifeq ($(OS),Windows_NT)
RM := del /Q /F
MKDIR := mkdir
slashfix = $(subst /,\,$(1)) # callable function for replacing slashes with backslashes
appfile := $(addsuffix .exe,$(appfile))
LFLAGS += -lpsapi # for mingw support
resfilein := $(srcdir)\winres\$(appname).rc
resfileout := $(objdir)\$(appname).res
else
RM := rm -f
MKDIR := mkdir -p
slashfix = $(1)
endif
all: $(dirs) $(objects) winres
$(CC) $(cctarget) $(CFLAGS) $(objects) $(resfileout) -o $(appfile) $(LFLAGS)
$(objects): $(objdir)/%.o: $(srcdir)/%.c $(headers)
$(CC) $(cctarget) $(CFLAGS) -I$(srcdir) -c $< -o $@
$(dirs):
$(MKDIR) $@
ifeq ($(OS),Windows_NT)
winres: $(resfilein)
windres --input $(resfilein) --output $(resfileout) --output-format=coff --target=$(restarget)
endif
clean:
$(RM) $(call slashfix,$(objects)) $(call slashfix,$(appfile)) $(call slashfix,$(resfileout))
.PHONY: all clean winres