-
Notifications
You must be signed in to change notification settings - Fork 34
/
mingw-makefile
63 lines (49 loc) · 1.32 KB
/
mingw-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
SHELL = /bin/sh
CC = i486-mingw32-gcc
EXEC_NCURSES = curseofwar.exe
EXEC_SDL = curseofwar-sdl.exe
GAME_TITLE = $(EXEC_NCURSES)
MINGWPATH=/usr/i486-mingw32/
# Sources
SRCS_INDEP = grid.c state.c king.c output-common.c path.c main-common.c
SRCS_NCURSES = output.c main.c
SRCS_SDL = output-sdl.c main-sdl.c
HDRS_INDEP = common.h messaging.h $(SRCS_INDEP:.c=.h)
HDRS_NCURSES = output.h
HDRS_SDL = output-sdl.h
OBJS_INDEP = $(SRCS_INDEP:.c=.o)
OBJS_NCURSES = $(SRCS_NCURSES:.c=.o)
OBJS_SDL = $(SRCS_SDL:.c=.o)
EXECS = $(EXEC_NCURSES) $(EXEC_SDL)
CFLAGS += -Wall -O2
LDLIBS += -lm
# Common sources and header
OBJS = $(OBJS_INDEP)
HDRS = $(HDRS_INDEP)
# SDL or ncurses
SDL ?= y
ifdef SDL
OBJS += $(OBJS_SDL)
HDRS += $(HDRS_SDL)
CFLAGS += $(shell $(MINGWPATH)bin/sdl-config --cflags)
LDLIBS += $(shell $(MINGWPATH)bin/sdl-config --libs)
EXEC = $(EXEC_SDL)
else
OBJS += $(OBJS_NCURSES)
HDRS += $(HDRS_NCURSES)
LDLIBS += -lncurses
EXEC = $(EXEC_NCURSES)
endif
VERSION=$(shell cat VERSION)
CPPFLAGS += -DVERSION="\"$(VERSION)\"" -DMINGW32=1
.PHONY: all clean cleanall
# Build
all: $(EXEC)
clean:
-rm -f $(OBJS_INDEP) $(OBJS_NCURSES) $(OBJS_SDL) $(EXECS)
%.o: %.c $(HDRS)
$(CC) $(CPPFLAGS) $(CFLAGS) -c $<
$(EXEC): $(OBJS) $(HDRS)
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LDLIBS) -o $(EXEC)
show-path:
@echo would install to ${BINDIR}