File: Makefile

package info (click to toggle)
opentyrian 2.1.20130907+dfsg-3
  • links: PTS, VCS
  • area: contrib
  • in suites: bullseye, buster, sid
  • size: 2,012 kB
  • sloc: ansic: 37,693; python: 185; objc: 67; makefile: 64; sh: 12
file content (75 lines) | stat: -rw-r--r-- 1,585 bytes parent folder | download | duplicates (2)
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
# BUILD SETTINGS ###########################################

ifneq ($(filter Msys Cygwin, $(shell uname -o)), )
    PLATFORM := WIN32
else
    PLATFORM := UNIX
endif

TARGET := opentyrian

WITH_NETWORK := true

############################################################

STRIP := strip

SDL_CONFIG := sdl-config

SRCS := $(wildcard src/*.c)
OBJS := $(SRCS:src/%.c=obj/%.o)

# FLAGS ####################################################

ifneq ($(MAKECMDGOALS), release)
    EXTRA_CFLAGS += -g3 -O0 -Werror
else
    EXTRA_CFLAGS += -g0 -O2 -DNDEBUG
endif
EXTRA_CFLAGS += -MMD -pedantic -Wall -Wextra -Wno-missing-field-initializers
ifeq ($(WITH_NETWORK), true)
    EXTRA_CFLAGS += -DWITH_NETWORK
endif

# HG_REV := $(shell hg id -ib && touch src/hg_revision.h)
HG_REV := 2.1.20130907
ifneq ($(HG_REV), )
    EXTRA_CFLAGS += '-DHG_REV="$(HG_REV)"'
endif

EXTRA_LDLIBS += -lm

SDL_CFLAGS := $(shell $(SDL_CONFIG) --cflags)
SDL_LDLIBS := $(shell $(SDL_CONFIG) --libs)
ifeq ($(WITH_NETWORK), true)
    SDL_LDLIBS += -lSDL_net
endif

ALL_CFLAGS += -std=c99 -I./src -DTARGET_$(PLATFORM) $(EXTRA_CFLAGS) $(SDL_CFLAGS) $(CFLAGS) $(CPPFLAGS)
ALL_LDFLAGS += $(LDFLAGS)
LDLIBS += $(EXTRA_LDLIBS) $(SDL_LDLIBS)

# RULES ####################################################

.PHONY : all release clean

all : $(TARGET)

release : all
	$(STRIP) $(TARGET)

clean :
	rm -rf obj/*
	rm -f $(TARGET)

ifneq ($(MAKECMDGOALS), clean)
    -include $(OBJS:.o=.d)
endif

$(TARGET) : $(OBJS)
	$(CC) -o $@ $(ALL_LDFLAGS) $^ $(LDLIBS)

obj/%.o : src/%.c
	@mkdir -p "$(dir $@)"
	$(CC) -c -o $@ $(ALL_CFLAGS) $<