forked from dlfcn-win32/dlfcn-win32
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
96 lines (74 loc) · 2.41 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
#
# dlfcn-win32 Makefile
#
include config.mak
CFLAGS = -Wall -O3 -fomit-frame-pointer -Isrc
ifeq ($(BUILD_SHARED),yes)
TARGETS += libdl.dll
SHFLAGS += -Wl,--out-implib,libdl.dll.a
INSTALL += shared-install
TESTS += test.exe test-dladdr.exe
endif
ifeq ($(BUILD_STATIC),yes)
TARGETS += libdl.a
INSTALL += static-install
TESTS += test-static.exe test-dladdr-static.exe
endif
ifeq ($(BUILD_MSVC),yes)
TARGETS += libdl.lib
SHFLAGS += -Wl,--output-def,libdl.def
INSTALL += lib-install
endif
SOURCES := src/dlfcn.c
HEADERS := src/dlfcn.h
all: $(TARGETS)
libdl.a: $(SOURCES)
$(CC) $(CFLAGS) -o $(^:%.c=%.o) -c $^
$(AR) cru $@ $(SOURCES:%.c=%.o)
$(RANLIB) $@
libdl.dll: $(SOURCES)
$(CC) $(CFLAGS) $(SHFLAGS) -DDLFCN_WIN32_SHARED -shared -o $@ $^
libdl.lib: libdl.dll
$(LIBCMD) /machine:i386 /def:libdl.def
include-install: $(HEADERS)
mkdir -p $(DESTDIR)$(incdir)
install -m 644 $^ "$(DESTDIR)$(incdir)"
shared-install: include-install
mkdir -p $(DESTDIR)$(prefix)/bin
cp libdl.dll $(DESTDIR)$(prefix)/bin
$(STRIP) $(DESTDIR)$(prefix)/bin/libdl.dll
mkdir -p $(DESTDIR)$(libdir)
cp libdl.dll.a $(DESTDIR)$(libdir)
static-install: include-install
mkdir -p $(DESTDIR)$(libdir)
cp libdl.a $(DESTDIR)$(libdir)
lib-install:
mkdir -p $(DESTDIR)$(libdir)
cp libdl.lib $(DESTDIR)$(libdir)
install: $(INSTALL)
test.exe: tests/test.c $(TARGETS)
$(CC) $(CFLAGS) -o $@ $< libdl.dll.a
test-static.exe: tests/test.c $(TARGETS)
$(CC) $(CFLAGS) -o $@ $< libdl.a
test-dladdr.exe: tests/test-dladdr.c $(TARGETS)
$(CC) $(CFLAGS) -Wl,--export-all-symbols -DDLFCN_WIN32_SHARED -o $@ $< libdl.dll.a
test-dladdr-static.exe: tests/test-dladdr.c $(TARGETS)
$(CC) $(CFLAGS) -Wl,--export-all-symbols -o $@ $< libdl.a
testdll.dll: tests/testdll.c
$(CC) $(CFLAGS) -shared -o $@ $^
testdll2.dll: tests/testdll2.c $(TARGETS)
$(CC) $(CFLAGS) -shared -o $@ $< -L. -ldl
testdll3.dll: tests/testdll3.c
$(CC) -shared -o $@ $^
test: $(TARGETS) $(TESTS) testdll.dll testdll2.dll testdll3.dll
for test in $(TESTS); do $(WINE) $$test || exit 1; done
clean::
rm -f \
src/dlfcn.o \
libdl.dll libdl.a libdl.def libdl.dll.a libdl.lib libdl.exp \
tmptest.c tmptest.dll \
test-dladdr.exe test-dladdr-static.exe \
test.exe test-static.exe testdll.dll testdll2.dll testdll3.dll
distclean: clean
rm -f config.mak
.PHONY: clean distclean install test