forked from mvdhout1992/cnc-ddraw
-
Notifications
You must be signed in to change notification settings - Fork 148
/
Makefile
48 lines (36 loc) · 1.31 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
-include config.mk
TARGET ?= ddraw.dll
LDFLAGS ?= -Wl,--enable-stdcall-fixup -s -static -shared
CFLAGS ?= -Iinc -O2 -Wall -std=c99
LIBS = -lgdi32 -lwinmm -lole32 -lMsimg32
COMMIT := $(shell git describe --match=NeVeRmAtCh --always --dirty || echo UNKNOWN)
BRANCH := $(shell git rev-parse --abbrev-ref HEAD || echo UNKNOWN)
ECHOTEST := $(shell echo \"\")
ifeq ($(ECHOTEST),\"\")
# Windows
HASH := \#
ECOMMIT := $(shell echo $(HASH)define GIT_COMMIT "$(COMMIT)" > inc/git.h)
EBRANCH := $(shell echo $(HASH)define GIT_BRANCH "$(BRANCH)" >> inc/git.h)
else
# Either *nix or Windows with BusyBox (e.g. w64devkit)
ECOMMIT := $(shell echo "#define GIT_COMMIT" \"$(COMMIT)\" > inc/git.h)
EBRANCH := $(shell echo "#define GIT_BRANCH" \"$(BRANCH)\" >> inc/git.h)
endif
ifdef DEBUG
CFLAGS += -D _DEBUG -D _DEBUG_X
endif
ifdef _WIN32_WINNT
CFLAGS += -march=i486 -D _WIN32_WINNT=$(_WIN32_WINNT)
endif
CC = i686-w64-mingw32-gcc
WINDRES ?= i686-w64-mingw32-windres
SRCS := $(wildcard src/*.c) $(wildcard src/*/*.c) res.rc
OBJS := $(addsuffix .o, $(basename $(SRCS)))
.PHONY: clean all
all: $(TARGET)
%.o: %.rc
$(WINDRES) -J rc $< $@ || windres -J rc $< $@
$(TARGET): $(OBJS)
$(CC) $(LDFLAGS) -o $@ $^ exports.def $(LIBS)
clean:
$(RM) $(TARGET) $(OBJS) || del $(TARGET) $(subst /,\\,$(OBJS))