Debian Codegraph @

Makefile

raw symbols SCIP
1 # BUILD SETTINGS ###############################################################
2
3 ifneq ($(filter Msys Cygwin, $(shell uname -o)), )
4 PLATFORM := WIN32
5 TYRIAN_DIR = C:\\TYRIAN
6 else
7 PLATFORM := UNIX
8 TYRIAN_DIR = $(gamesdir)/tyrian
9 endif
10
11 WITH_NETWORK := true
12
13 ################################################################################
14
15 # see https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html
16
17 SHELL = /bin/sh
18
19 CC ?= gcc
20 INSTALL ?= install
21 PKG_CONFIG ?= pkg-config
22
23 VCS_IDREV ?= (git describe --tags || git rev-parse --short HEAD)
24
25 INSTALL_PROGRAM ?= $(INSTALL)
26 INSTALL_DATA ?= $(INSTALL) -m 644
27
28 prefix ?= /usr/local
29 exec_prefix ?= $(prefix)
30
31 bindir ?= $(exec_prefix)/bin
32 datarootdir ?= $(prefix)/share
33 datadir ?= $(datarootdir)
34 docdir ?= $(datarootdir)/doc/opentyrian
35 mandir ?= $(datarootdir)/man
36 man6dir ?= $(mandir)/man6
37 man6ext ?= .6
38 desktopdir ?= $(datarootdir)/applications
39 icondir ?= $(datarootdir)/icons
40
41 # see https://www.pathname.com/fhs/pub/fhs-2.3.html
42
43 gamesdir ?= $(datadir)/games
44
45 ###
46
47 TARGET := opentyrian
48
49 SRCS := $(wildcard src/*.c)
50 OBJS := $(SRCS:src/%.c=obj/%.o)
51 DEPS := $(SRCS:src/%.c=obj/%.d)
52
53 ###
54
55 ifeq ($(WITH_NETWORK), true)
56 EXTRA_CPPFLAGS += -DWITH_NETWORK
57 endif
58
59 OPENTYRIAN_VERSION := $(shell $(VCS_IDREV) 2>/dev/null && \
60 touch src/opentyrian_version.h)
61 ifneq ($(OPENTYRIAN_VERSION), )
62 EXTRA_CPPFLAGS += -DOPENTYRIAN_VERSION='"$(OPENTYRIAN_VERSION)"'
63 endif
64
65 CPPFLAGS ?= -MMD
66 CPPFLAGS += -DNDEBUG
67 CFLAGS ?= -pedantic \
68 -Wall \
69 -Wextra \
70 -Wno-format-truncation \
71 -Wno-missing-field-initializers \
72 -O2
73 LDFLAGS ?=
74 LDLIBS ?=
75
76 ifeq ($(WITH_NETWORK), true)
77 SDL_CPPFLAGS := $(shell $(PKG_CONFIG) sdl2 SDL2_net --cflags)
78 SDL_LDFLAGS := $(shell $(PKG_CONFIG) sdl2 SDL2_net --libs-only-L --libs-only-other)
79 SDL_LDLIBS := $(shell $(PKG_CONFIG) sdl2 SDL2_net --libs-only-l)
80 else
81 SDL_CPPFLAGS := $(shell $(PKG_CONFIG) sdl2 --cflags)
82 SDL_LDFLAGS := $(shell $(PKG_CONFIG) sdl2 --libs-only-L --libs-only-other)
83 SDL_LDLIBS := $(shell $(PKG_CONFIG) sdl2 --libs-only-l)
84 endif
85
86 ALL_CPPFLAGS = -DTARGET_$(PLATFORM) \
87 -DTYRIAN_DIR='"$(TYRIAN_DIR)"' \
88 $(EXTRA_CPPFLAGS) \
89 $(SDL_CPPFLAGS) \
90 $(CPPFLAGS)
91 ALL_CFLAGS = -std=iso9899:1999 \
92 $(CFLAGS)
93 ALL_LDFLAGS = $(SDL_LDFLAGS) \
94 $(LDFLAGS)
95 ALL_LDLIBS = -lm \
96 $(SDL_LDLIBS) \
97 $(LDLIBS)
98
99 ###
100
101 .PHONY : all
102 all : $(TARGET)
103
104 .PHONY : debug
105 debug : CPPFLAGS += -UNDEBUG
106 debug : CFLAGS += -Werror
107 debug : CFLAGS += -O0
108 debug : CFLAGS += -g3
109 debug : all
110
111 .PHONY : installdirs
112 installdirs :
113 mkdir -p $(DESTDIR)$(bindir)
114 mkdir -p $(DESTDIR)$(docdir)
115 mkdir -p $(DESTDIR)$(man6dir)
116 mkdir -p $(DESTDIR)$(desktopdir)
117 mkdir -p $(DESTDIR)$(icondir)/hicolor/22x22/apps
118 mkdir -p $(DESTDIR)$(icondir)/hicolor/24x24/apps
119 mkdir -p $(DESTDIR)$(icondir)/hicolor/32x32/apps
120 mkdir -p $(DESTDIR)$(icondir)/hicolor/48x48/apps
121 mkdir -p $(DESTDIR)$(icondir)/hicolor/128x128/apps
122
123 .PHONY : install
124 install : $(TARGET) installdirs
125 $(INSTALL_PROGRAM) $(TARGET) $(DESTDIR)$(bindir)/
126 $(INSTALL_DATA) NEWS README $(DESTDIR)$(docdir)/
127 $(INSTALL_DATA) linux/man/opentyrian.6 $(DESTDIR)$(man6dir)/opentyrian$(man6ext)
128 $(INSTALL_DATA) linux/opentyrian.desktop $(DESTDIR)$(desktopdir)/
129 $(INSTALL_DATA) linux/icons/tyrian-22.png $(DESTDIR)$(icondir)/hicolor/22x22/apps/opentyrian.png
130 $(INSTALL_DATA) linux/icons/tyrian-24.png $(DESTDIR)$(icondir)/hicolor/24x24/apps/opentyrian.png
131 $(INSTALL_DATA) linux/icons/tyrian-32.png $(DESTDIR)$(icondir)/hicolor/32x32/apps/opentyrian.png
132 $(INSTALL_DATA) linux/icons/tyrian-48.png $(DESTDIR)$(icondir)/hicolor/48x48/apps/opentyrian.png
133 $(INSTALL_DATA) linux/icons/tyrian-128.png $(DESTDIR)$(icondir)/hicolor/128x128/apps/opentyrian.png
134
135 .PHONY : uninstall
136 uninstall :
137 rm -f $(DESTDIR)$(bindir)/$(TARGET)
138 rm -f $(DESTDIR)$(docdir)/NEWS $(DESTDIR)$(docdir)/README
139 rm -f $(DESTDIR)$(man6dir)/opentyrian$(man6ext)
140 rm -f $(DESTDIR)$(desktopdir)/opentyrian.desktop
141 rm -f $(DESTDIR)$(icondir)/hicolor/22x22/apps/opentyrian.png
142 rm -f $(DESTDIR)$(icondir)/hicolor/24x24/apps/opentyrian.png
143 rm -f $(DESTDIR)$(icondir)/hicolor/32x32/apps/opentyrian.png
144 rm -f $(DESTDIR)$(icondir)/hicolor/48x48/apps/opentyrian.png
145 rm -f $(DESTDIR)$(icondir)/hicolor/128x128/apps/opentyrian.png
146
147 .PHONY : clean
148 clean :
149 rm -f $(OBJS)
150 rm -f $(DEPS)
151 rm -f $(TARGET)
152
153 $(TARGET) : $(OBJS)
154 $(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) -o $@ $^ $(ALL_LDLIBS)
155
156 -include $(DEPS)
157
158 obj/%.o : src/%.c
159 @mkdir -p "$(dir $@)"
160 $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -o $@ $<