-
Notifications
You must be signed in to change notification settings - Fork 25
/
Makefile
207 lines (160 loc) · 5.07 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
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
195
196
197
198
199
200
201
202
203
204
205
206
207
##
## Makefile
## $Id: Makefile,v 1.22 2007-05-12 20:13:04 bobi Exp $
##
## Copyright 2004 Bobi B., w1zard0f07@yahoo.com
##
## This file is part of hdl_dump.
##
## hdl_dump is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## hdl_dump is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with hdl_dump; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##
# NOTE: this Makefile REQUIRES GNU make (gmake)
###############################################################################
# configuration start
# NOTE: don't forget, that changing some options REQUIRES `make clean' next!
# `yes' - debug build; something else - release build
# `RELEASE=yes make' makes a release build no matter what DEBUG flag is
DEBUG ?= yes
RELEASE ?= no
# whether to use memory-mapped I/O when reading from optical drives
# currently appears to work on Linux only
IIN_OPTICAL_MMAP ?= no
# whether to use iin (ISO inputs) tuned for "streaming" (obsoletes mmap)
USE_THREADED_IIN ?= yes
# hdl_dump current version/release
VER_MAJOR = 0
VER_MINOR = 9
VER_PATCH = 2
# https://mxe.cc/
MXE_TARGETS ?= i686-w64-mingw32.static
# configuration end
###############################################################################
CFLAGS = -Wall -ansi -pedantic -Wno-long-long
LDFLAGS =
# iin_hdloader.c iin_net.c
SOURCES = hdl_dump.c \
apa.c common.c progress.c hdl.c isofs.c aligned.c \
iin_img_base.c iin_optical.c iin_iso.c iin_cdrwin.c \
iin_nero.c iin_gi.c iin_iml.c iin_probe.c iin_hio.c \
hio_probe.c hio_win32.c hio_dbg.c hio_trace.c \
net_common.c byteseq.c dict.c hio_udpnet2.c
# "autodetect" Windows builds
ifdef SYSTEMROOT
WINDOWS = yes
else
WINDOWS = no
endif
# Windows cross-compilation with mingw32* on Debian
# make XC=win ...
WINDRES = windres
ifeq ($(XC), win)
WINDOWS = yes
CC = $(MXE_TARGETS)-gcc
WINDRES = $(MXE_TARGETS)-windres
endif
# Windows/Unix/Linux build
ifeq ($(WINDOWS), yes)
SOURCES += iin_spti.c iin_aspi.c aspi_hlio.c osal_win32.c
OBJECTS += rsrc.o
CFLAGS += -D_BUILD_WIN32
CXXFLAGS += -D_BUILD_WIN32
LDFLAGS += -lwsock32 -lwinmm
EXESUF = .exe
# make it compile with latest cygwin/mingw
# however, that would probably not work under older versions of Windows...?
CFLAGS += -D_WIN32_WINNT=0x0500
# it looks like Windows doesn't support memory-mapping on optical drives
IIN_OPTICAL_MMAP = no
else
SOURCES += osal_unix.c
CFLAGS += -D_GNU_SOURCE -D_BUILD_UNIX
CXXFLAGS += -D_GNU_SOURCE -D_BUILD_UNIX
LDFLAGS += -lpthread
EXESUF =
endif
# whether to make debug or release build
ifeq ($(RELEASE), yes)
DEBUG = no
endif
# Even on debug we need optimization for _FORTIFY_SOURCE
ifeq ($(DEBUG), yes)
CFLAGS += -O2 -g -D_DEBUG
CXXFLAGS += -O2 -g -D_DEBUG
else
CFLAGS += -O2 -DNDEBUG
CXXFLAGS += -O2 -DNDEBUG
endif
ifeq ($(USE_THREADED_IIN), yes)
SOURCES += thd_iin.c
CFLAGS += -DUSE_THREADED_IIN
CXXFLAGS += -DUSE_THREADED_IIN
endif
# version number
VERSION = -DVER_MAJOR=$(VER_MAJOR) \
-DVER_MINOR=$(VER_MINOR) \
-DVER_PATCH=$(VER_PATCH)
VERSION += -DVERSION=\"$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH)\"
CFLAGS += $(VERSION)
CXXFLAGS += $(VERSION)
ifeq ($(IIN_OPTICAL_MMAP), yes)
CFLAGS += -DIIN_OPTICAL_MMAP
endif
OBJECTS += $(SOURCES:.c=.o)
DEPENDS += $(SOURCES:.c=.d)
OBJECTS := $(OBJECTS:.cpp=.o)
DEPENDS := $(DEPENDS:.cpp=.d)
BINARY = hdl_dump$(EXESUF)
###############################################################################
# make commands below...
.PHONY: all clean rmdeps
all: $(BINARY)
clean:
@rm -f $(BINARY) $(OBJECTS)
@rm -f $(DEPENDS)
@rm -f *.d *.o *.exe
rmdeps:
@rm -f $(DEPENDS)
LINT_OFF = +posixlib +unixlib \
-fixedformalarray -exitarg -predboolint -boolops +boolint +partial \
+matchanyintegral
lint:
for src in $(SOURCES:osal_unix.c=); do \
@splint -D_LINT -D_BUILD_UNIX -DVERSION="" $(LINT_OFF) $$src; \
done
lint2:
@splint -D_LINT -D_BUILD_UNIX -DVERSION="" $(LINT_OFF) \
-weak -bufferoverflowhigh +longintegral +ignoresigns -ifempty \
-varuse -initallelements $(SOURCES:osal_unix.c=)
format:
find . -type f -a \( -iname \*.h -o -iname \*.c \) | xargs clang-format -i
format-check:
@! find . -type f -a \( -iname \*.h -o -iname \*.c \) | xargs clang-format -style=file -output-replacements-xml | grep "<replacement "
# rules below
rsrc.o: rsrc.rc
@echo -e "\tRES $<"
@$(WINDRES) $(VERSION) -o $@ -i $<
$(BINARY): $(OBJECTS)
@echo -e "\tLNK $@"
@$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
%.o : %.c
@echo -e "\tCC $<"
@$(CC) -c $(CFLAGS) -o $@ $<
%.d : %.c
@echo -e "\tDEP $<"
@$(CC) -MM $(CFLAGS) $< > $@
GOALS := rmdeps format clean format-check lint lint2
ifeq (,$(filter $(GOALS),$(MAKECMDGOALS)))
-include $(DEPENDS)
endif