File: Makefile.in

package info (click to toggle)
lfanew 0~20230825%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 540 kB
  • sloc: sh: 3,390; ansic: 1,321; makefile: 170; awk: 21
file content (202 lines) | stat: -rw-r--r-- 5,686 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
195
196
197
198
199
200
201
202
# Copyright (c) 2023 TK Chia
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

DESTDIR =
abs_srcdir = @abs_srcdir@
srcdir = @srcdir@
objdir = .
VPATH = $(srcdir)
mkinstalldirs = $(SHELL) $(srcdir)/mkinstalldirs

prefix = @prefix@
exec_prefix = @exec_prefix@

bindir = @bindir@
includedir = @includedir@
libdir = @libdir@
build3dir = 3rd-party.build

INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
AWK = @AWK@

CC = @CC@
CPPFLAGS = @CPPFLAGS@ -I$(srcdir)/h -I$(objdir)/h
CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
OBJEXT = @OBJEXT@
EXEEXT = @EXEEXT@
AR = @AR@
RANLIB = @RANLIB@
OBJCOPY = @OBJCOPY@
UPX = @UPX@

WINCC = @WINCC@
WINCXX = @WINCXX@
HOSTRUN = @HOSTRUN@

lfanew_cv_prog_wincc_ldscripts_i386pe_x \
= @lfanew_cv_prog_wincc_ldscripts_i386pe_x@
lfanew_cv_prog_wincc_ldscripts_i386pep_x \
= @lfanew_cv_prog_wincc_ldscripts_i386pep_x@

PROGRAMS = $(LFANEW)
LIBRARIES = a/libfanew.a
HEADERS = h/lfanew/dirent.h \
	  h/lfanew/io.h \
	  h/lfanew/_config.h \
	  h/lfanew/_version.h \
	  h/nexgen/mzendian.h \
	  h/nexgen/mzhdr.h
LIBOBJS = a/direntdup.$(OBJEXT)
SCRIPTS =
ifeq "no" "@ac_cv_func_scandir@"
  LIBOBJS += a/scandir.$(OBJEXT)
endif
ifneq "none" "$(lfanew_cv_prog_wincc_ldscripts_i386pe_x)"
  SCRIPTS += ldscripts/i386pebc.x
endif
ifneq "none" "$(lfanew_cv_prog_wincc_ldscripts_i386pep_x)"
  SCRIPTS += ldscripts/i386pepbc.x
endif
DATA = $(build3dir)/msdos_i486.pe

LFANEW = lfanew$(EXEEXT)

default: $(PROGRAMS) $(HEADERS) $(LIBRARIES) $(SCRIPTS) $(DATA)
.PHONY: default

all: default
.PHONY: all

install: $(PROGRAMS) $(HEADERS) $(LIBRARIES)
	$(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(libdir) \
	  $(sort $(dir $(HEADERS:h/%=$(DESTDIR)$(includedir)/%)))
	$(INSTALL_PROGRAM) $(filter-out %.h %.a,$^) $(DESTDIR)$(bindir)
	set -e; \
	for h in $(HEADERS:h/%=%); do \
	  if test -f h/"$$h"; then \
	    $(INSTALL_DATA) h/"$$h" $(DESTDIR)$(includedir)/"$$h"; \
	  else \
	    $(INSTALL_DATA) $(srcdir)/h/"$$h" $(DESTDIR)$(includedir)/"$$h"; \
	  fi; \
	done
	for a in $(LIBRARIES:a/%=%); do \
	  if test -f a/"$$a"; then \
	    $(INSTALL_DATA) a/"$$a" $(DESTDIR)$(libdir)/"$$a"; \
	  else \
	    $(INSTALL_DATA) $(srcdir)/a/"$$a" $(DESTDIR)$(libdir)/"$$a"; \
	  fi; \
	done
.PHONY: install

clean mostlyclean:
	$(RM) *.[oa] $(PROGRAMS) $(SCRIPTS) $(OBJS) $(LIBRARIES) \
	      $(build3dir) *~
.PHONY: clean mostlyclean

distclean maintainer-clean: clean
	$(RM) Makefile config.cache config.log config.status h/lfanew/_*.h
.PHONY: distclean maintainer-clean

check check-local: tests/testsuite
	exec $< -C tests $(TESTSUITEFLAGS)
.PHONY: check check-local

installcheck installcheck-local: tests/testsuite
	exec $< --x-installcheck -C tests $(TESTSUITEFLAGS)
.PHONY: installcheck installcheck-local

helpcheck: tests/testsuite
	exec $< -C tests --help $(TESTSUITEFLAGS)
.PHONY: helpcheck

listcheck: tests/testsuite
	exec $< -C tests --list $(TESTSUITEFLAGS)
.PHONY: listcheck

lfanew$(EXEEXT): lfanew.$(OBJEXT)

%.$(OBJEXT): %.c $(HEADERS)
	mkdir -p $(@D)
	$(CC) $(CPPFLAGS) $(CFLAGS) $(TARGET_ARCH) -c $< -o $@

# NOTE: $(LIBRARIES) is for any library files built in this project, while
# $(LDLIBS) & $(LIBS) are for pre-existing system libraries.  GNU autoconf &
# automake apparently use the names $(LIBRARIES) & $(LIBS) the same ways.
%$(EXEEXT): %.$(OBJEXT) $(LIBRARIES)
	$(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LOADLIBES) $(LDLIBS) $(LIBS) -o $@

a/libfanew.a: $(LIBOBJS)
	$(RM) $@
	$(AR) cq $@ $^
	$(RANLIB) $@

# Cancel GNU make's built-in implicit rules.
%.$(OBJEXT): %.c
%$(EXEEXT): %.$(OBJEXT)

ldscripts/i386pebc.x: patch-lds.awk $(lfanew_cv_prog_wincc_ldscripts_i386pe_x)
	mkdir -p $(@D)
	$(AWK) -f $< $(lfanew_cv_prog_wincc_ldscripts_i386pe_x) >$@.tmp
	mv $@.tmp $@

ldscripts/i386pepbc.x: patch-lds.awk \
		       $(lfanew_cv_prog_wincc_ldscripts_i386pep_x)
	mkdir -p $(@D)
	$(AWK) -f $< $(lfanew_cv_prog_wincc_ldscripts_i386pep_x) >$@.tmp
	mv $@.tmp $@

$(build3dir)/msdos_i486.pe: $(build3dir)/msdos_i486.exe $(LFANEW)
	$(HOSTRUN) '$(abspath $(LFANEW))' -U -o $@ $<

$(build3dir)/msdos_i486.exe: 3rd-party/msdos.7z msdos.baseofcode.patch \
			     $(build3dir)/msdos-opts.bin $(SCRIPTS)
	mkdir -p $(@D)
	$(RM) -r $(@D)/msdos
	7z x -o$(@D) $<
	dos2unix $(@D)/msdos/source/*.*
	LC_ALL=C patch -d$(@D)/msdos -p1 <$(filter %.patch,$^)
	$(MAKE) -C $(@D)/msdos/source -f Makefile.mingw \
		CC='$(WINCC)' CXX='$(WINCXX)' LDFLAGS_EXTRA='$(LDFLAGS_EXTRA)'\
		i486
ifeq "/bin/false" "$(UPX)"
	cp $(@D)/msdos/binary/msdos_i486.exe $@.tmp
else
	$(OBJCOPY) -R .slack $(@D)/msdos/binary/msdos_i486.exe $@.tmp
	$(UPX) -9 $@.tmp
endif
	$(OBJCOPY) --add-section .msdos=$(filter %.bin,$^) $@.tmp
	mv $@.tmp $@

$(build3dir)/msdos_i486.exe \
 : LDFLAGS_EXTRA = -T$(abspath $(SCRIPTS)) \
		   -Wl,--defsym=__base_of_code__=0x80000

$(build3dir)/msdos-opts.bin:
	mkdir -p $(@D)
	dd if=/dev/zero of=$@.tmp bs=17 count=1
	mv $@.tmp $@

# Copy the generated tests/testsuite from the source directory to the build
# directory, or create a symlink from the latter to the former --- but only
# if the two directories are different.
tests/testsuite: $(abs_srcdir)/tests/testsuite
	set -e; \
	if test \! $@ -ef $<; then \
	  $(RM) $@.tmp; \
	  ln -s $< $@.tmp || cp $< $@.tmp; \
	  mv $@.tmp $@; \
	fi
.PRECIOUS: tests/testsuite

$(abs_srcdir)/tests/testsuite: $(abs_srcdir)/tests/testsuite.at \
			       $(wildcard $(abs_srcdir)/tests/*.at \
					  $(abs_srcdir)/tests/*.in)
	cd $(abs_srcdir)/tests && exec autom4te --language=autotest -o $@ $<
.PRECIOUS: $(abs_srcdir)/tests/testsuite