File: Makerules

package info (click to toggle)
mupdf 1.14.0+ds1-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 56,832 kB
  • sloc: ansic: 314,734; java: 2,498; python: 655; makefile: 494; sh: 206; sed: 13; awk: 6
file content (194 lines) | stat: -rw-r--r-- 5,954 bytes parent folder | download
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# Configuration for the Makefile

OS := $(shell uname)
OS := $(OS:MINGW%=MINGW)
OS := $(OS:MSYS%=MINGW)
OS := $(OS:Windows_NT=MINGW)
OS := $(OS:Darwin=MACOS)

PKG_CONFIG ?= pkg-config
CC_FOR_BUILD ?= $(CC)

HAVE_LIBDL ?= yes

ifeq ($(findstring -fembed-bitcode,$(XCFLAGS)),)
  # clang does not support these in combination with -fembed-bitcode
  CFLAGS += -ffunction-sections -fdata-sections
endif

ifeq ($(OS),MACOS)
  LDREMOVEUNREACH := -Wl,-dead_strip
else
  LDREMOVEUNREACH := -Wl,--gc-sections
endif

SANITIZE_FLAGS += -fsanitize=address
SANITIZE_FLAGS += -fsanitize=leak

ifeq ($(build),debug)
  CFLAGS += -pipe -g
  LDFLAGS += -g $(LDREMOVEUNREACH)
else ifeq "$(build)" "debian"
  CFLAGS += -pipe -O2 -DNDEBUG -fomit-frame-pointer
  LDFLAGS += $(LDREMOVEUNREACH)
else ifeq ($(build),release)
  CFLAGS += -pipe -O2 -DNDEBUG -fomit-frame-pointer
  LDFLAGS += $(LDREMOVEUNREACH) -Wl,-s
else ifeq ($(build),small)
  CFLAGS += -pipe -Os -DNDEBUG -fomit-frame-pointer
  LDFLAGS += $(LDREMOVEUNREACH) -Wl,-s
else ifeq ($(build),valgrind)
  CFLAGS += -pipe -O2 -DNDEBUG -DPACIFY_VALGRIND -fno-omit-frame-pointer
  LDFLAGS += $(LDREMOVEUNREACH) -Wl,-s
else ifeq ($(build),sanitize)
  CFLAGS += -pipe -g -fno-omit-frame-pointer $(SANITIZE_FLAGS)
  LDFLAGS += -g $(SANITIZE_FLAGS)
else ifeq ($(build),sanitize-release)
  CFLAGS += -pipe -O2 -DNDEBUG -fno-omit-frame-pointer $(SANITIZE_FLAGS)
  LDFLAGS += $(LDREMOVEUNREACH) -Wl,-s $(SANITIZE_FLAGS)
else ifeq ($(build),profile)
  CFLAGS += -pipe -O2 -DNDEBUG -pg
  LDFLAGS += -pg
else ifeq ($(build),coverage)
  CFLAGS += -pipe -g -pg -fprofile-arcs -ftest-coverage
  LIBS += -lgcov
else ifeq ($(build),native)
  CFLAGS += -pipe -O2 -DNDEBUG -fomit-frame-pointer -march=native
  LDFLAGS += $(LDREMOVEUNREACH) -Wl,-s
else ifeq ($(build),memento)
  CFLAGS += -pipe -g -DMEMENTO
  LDFLAGS += -g -d -rdynamic
  ifneq ($(HAVE_LIBDL),no)
    CFLAGS += -DHAVE_LIBDL
    LIBS += -ldl
  endif
else ifeq ($(build),gperf)
  CFLAGS += -pipe -O2 -DNDEBUG -fomit-frame-pointer -DGPERF
  LIBS += -lprofiler
else
  $(error unknown build setting: '$(build)')
endif

# Default system libraries
SYS_FREETYPE_LIBS := -lfreetype2
SYS_HARFBUZZ_LIBS := -lharfbuzz
SYS_JBIG2DEC_LIBS := -ljbig2dec
SYS_JPEGXR_LIBS := -ljpegxr
SYS_LCMS2_LIBS := -llcms2-art
SYS_LIBJPEG_LIBS := -ljpeg
SYS_MUJS_LIBS := -lmujs
SYS_OPENJPEG_LIBS := -lopenjp2
SYS_ZLIB_LIBS := -lz

ifeq ($(OS),MINGW)
  WINDRES := windres
  HAVE_WIN32 := yes

else ifeq ($(OS),MACOS)
  HAVE_GLUT := yes
  SYS_GLUT_CFLAGS := -Wno-deprecated-declarations
  SYS_GLUT_LIBS := -framework GLUT -framework OpenGL
  CC = xcrun cc
  AR = xcrun ar
  LD = xcrun ld
  RANLIB = xcrun ranlib

else ifeq ($(OS),Linux)
  HAVE_OBJCOPY ?= yes

  ifeq ($(shell $(PKG_CONFIG) --exists freetype2 && echo yes),yes)
	SYS_FREETYPE_CFLAGS := $(shell $(PKG_CONFIG) --cflags freetype2)
	SYS_FREETYPE_LIBS := $(shell $(PKG_CONFIG) --libs freetype2)
  endif
  ifeq ($(shell $(PKG_CONFIG) --exists harfbuzz && echo yes),yes)
	SYS_HARFBUZZ_CFLAGS := $(shell $(PKG_CONFIG) --cflags harfbuzz)
	SYS_HARFBUZZ_LIBS := $(shell $(PKG_CONFIG) --libs harfbuzz)
  endif
  ifeq ($(shell $(PKG_CONFIG) --exists lcms2 && echo yes),yes)
	SYS_LCMS2_CFLAGS := $(shell $(PKG_CONFIG) --cflags lcms2)
	SYS_LCMS2_LIBS := $(shell $(PKG_CONFIG) --libs lcms2)
  endif
  ifeq ($(shell $(PKG_CONFIG) --exists libjpeg && echo yes),yes)
	SYS_LIBJPEG_CFLAGS := $(shell $(PKG_CONFIG) --cflags libjpeg)
	SYS_LIBJPEG_LIBS := $(shell $(PKG_CONFIG) --libs libjpeg)
  endif
  ifeq ($(shell $(PKG_CONFIG) --exists libopenjp2 && echo yes),yes)
	SYS_OPENJPEG_CFLAGS := $(shell $(PKG_CONFIG) --cflags libopenjp2)
	SYS_OPENJPEG_LIBS := $(shell $(PKG_CONFIG) --libs libopenjp2)
  endif
  ifeq ($(shell $(PKG_CONFIG) --exists zlib && echo yes),yes)
	SYS_ZLIB_CFLAGS := $(shell $(PKG_CONFIG) --cflags zlib)
	SYS_ZLIB_LIBS := $(shell $(PKG_CONFIG) --libs zlib)
  endif

  HAVE_CURL := $(shell $(PKG_CONFIG) --exists libcurl && echo yes)
  ifeq ($(HAVE_CURL),yes)
	SYS_CURL_CFLAGS := $(shell $(PKG_CONFIG) --cflags libcurl)
	SYS_CURL_LIBS := $(shell $(PKG_CONFIG) --libs libcurl)
  endif

  HAVE_GLUT := yes
  ifeq ($(HAVE_GLUT),yes)
	SYS_GLUT_CFLAGS :=
	SYS_GLUT_LIBS := -lglut -lGL
  endif

  HAVE_X11 := $(shell $(PKG_CONFIG) --exists x11 xext && echo yes)
  ifeq ($(HAVE_X11),yes)
	X11_CFLAGS := $(shell $(PKG_CONFIG) --cflags x11 xext)
	X11_LIBS := $(shell $(PKG_CONFIG) --libs x11 xext)
  endif

  HAVE_LIBCRYPTO := $(shell $(PKG_CONFIG) --exists 'libcrypto >= 1.1.0' && echo yes)
  ifeq ($(HAVE_LIBCRYPTO),yes)
	LIBCRYPTO_CFLAGS := $(shell $(PKG_CONFIG) --cflags libcrypto) -DHAVE_LIBCRYPTO
	LIBCRYPTO_LIBS := $(shell $(PKG_CONFIG) --libs libcrypto)
  endif

  HAVE_PTHREAD := yes
  ifeq ($(HAVE_PTHREAD),yes)
	PTHREAD_CFLAGS :=
	PTHREAD_LIBS := -lpthread
  endif

endif

# The following section has various cross compilation configurations.
#
# Invoke these as:
#      make OS=mingw32-cross
#
# This does rely on the generated directory being populated with the font files.
# On a unix-like system, run 'make generate' before doing the cross compile.
# On Windows, run 'nmake -f scripts\fontdump.nmake' in a Visual Studio command prompt.

ifeq "$(OS)" "mingw32-cross"
  OUT := build/$(OS)/$(build)
  CC = i686-w64-mingw32-gcc
  CXX = i686-w64-mingw32-g++
  LD = i686-w64-mingw32-gcc
  AR = i686-w64-mingw32-ar
  WINDRES = i686-w64-mingw32-windres
  HAVE_WIN32=yes
endif

ifeq "$(OS)" "mingw64-cross"
  OUT := build/$(OS)/$(build)
  CC = x86_64-w64-mingw32-gcc
  CXX = x86_64-w64-mingw32-g++
  LD = x86_64-w64-mingw32-gcc
  AR = x86_64-w64-mingw32-ar
  WINDRES = x86_64-w64-mingw32-windres
  HAVE_WIN32=yes
endif

# Most variables when building for iOS are set up in ios/build_libs.sh,
# which is called from the Xcode project as a "Run Script" build step.
# The following section works for both device and simulator builds.
ifeq "$(OS)" "ios"
  CC = xcrun cc
  CXX = xcrun c++
  AR = xcrun ar
  LD = xcrun ld
  RANLIB = xcrun ranlib
endif