aboutsummaryrefslogtreecommitdiff
path: root/Makefile2
blob: 4d11de8a638dcdcbc08de995cb5a467385e5983e (plain)
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
#
# dlfcn-win32 Makefile
#
include config.mak

ifeq ($(BUILD_SHARED),yes)
	TARGETS += libdl.dll libdl.dll.a
	SHFLAGS += -Wl,--out-implib,libdl.dll.a
	INSTALL += shared-install
endif
ifeq ($(BUILD_STATIC),yes)
	TARGETS += libdl.a
	INSTALL += static-install
endif
ifeq ($(BUILD_MSVC),yes)
    TARGETS += libdl.lib
	SHFLAGS += -Wl,--output-def,libdl.def
	INSTALL += lib-install
endif

LIB_OBJS := dlfcn.o
HEADERS  := dlfcn.h

all: $(TARGETS)

%.o: %.c
	$(CC) -o $@ -c $< -Wall -O3 -fomit-frame-pointer

libdl.a: $(LIB_OBJS)
	$(AR) cru $@ $^
	$(RANLIB) libdl.a

libdl.dll libdl.dll.a: $(LIB_OBJS)
	$(CC) $(SHFLAGS) -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: $(LIBS)
	mkdir -p $(DESTDIR)$(libdir)
	cp libdl.lib $(DESTDIR)$(libdir)

install: $(INSTALL)

test.exe: test.o $(TARGETS)
	$(CC) -o $@ $< -L. -ldl

testdll.dll: testdll.c
	$(CC) -shared -o $@ $^

test: $(TARGETS) test.exe testdll.dll
	$(WINE) test.exe

clean::
	rm -f dlfcn.o libdl.dll libdl.a libdl.def libdl.dll.a libdl.lib libdl.exp test.exe testdll.dll

distclean: clean
	rm -f config.mak

.PHONY: clean distclean install test