diff options
-rw-r--r-- | Makefile | 38 |
1 files changed, 20 insertions, 18 deletions
@@ -6,13 +6,14 @@ CFLAGS = -Wall -O3 -fomit-frame-pointer | |||
6 | 6 | ||
7 | ifeq ($(BUILD_SHARED),yes) | 7 | ifeq ($(BUILD_SHARED),yes) |
8 | TARGETS += libdl.dll | 8 | TARGETS += libdl.dll |
9 | SHFLAGS += -Wl,--out-implib,libdl.dll.a | 9 | SHFLAGS += -Wl,--out-implib,libdl.dll.a -DSHARED |
10 | CFLAGS += -DSHARED | ||
11 | INSTALL += shared-install | 10 | INSTALL += shared-install |
11 | TESTS += test.exe | ||
12 | endif | 12 | endif |
13 | ifeq ($(BUILD_STATIC),yes) | 13 | ifeq ($(BUILD_STATIC),yes) |
14 | TARGETS += libdl.a | 14 | TARGETS += libdl.a |
15 | INSTALL += static-install | 15 | INSTALL += static-install |
16 | TESTS += test-static.exe | ||
16 | endif | 17 | endif |
17 | ifeq ($(BUILD_MSVC),yes) | 18 | ifeq ($(BUILD_MSVC),yes) |
18 | TARGETS += libdl.lib | 19 | TARGETS += libdl.lib |
@@ -20,20 +21,18 @@ ifeq ($(BUILD_MSVC),yes) | |||
20 | INSTALL += lib-install | 21 | INSTALL += lib-install |
21 | endif | 22 | endif |
22 | 23 | ||
23 | LIB_OBJS := dlfcn.o | 24 | SOURCES := dlfcn.c |
24 | HEADERS := dlfcn.h | 25 | HEADERS := dlfcn.h |
25 | 26 | ||
26 | all: $(TARGETS) | 27 | all: $(TARGETS) |
27 | 28 | ||
28 | %.o: %.c | 29 | libdl.a: $(SOURCES) |
29 | $(CC) -o $@ -c $< $(CFLAGS) | 30 | $(CC) $(CFLAGS) -c $^ |
31 | $(AR) cru $@ $(SOURCES:%.c=%.o) | ||
32 | $(RANLIB) $@ | ||
30 | 33 | ||
31 | libdl.a: $(LIB_OBJS) | 34 | libdl.dll: $(SOURCES) |
32 | $(AR) cru $@ $^ | 35 | $(CC) $(CFLAGS) $(SHFLAGS) -shared -o $@ $^ |
33 | $(RANLIB) libdl.a | ||
34 | |||
35 | libdl.dll: $(LIB_OBJS) | ||
36 | $(CC) $(SHFLAGS) -shared -o $@ $^ | ||
37 | 36 | ||
38 | libdl.lib: libdl.dll | 37 | libdl.lib: libdl.dll |
39 | $(LIBCMD) /machine:i386 /def:libdl.def | 38 | $(LIBCMD) /machine:i386 /def:libdl.def |
@@ -59,27 +58,30 @@ lib-install: | |||
59 | 58 | ||
60 | install: $(INSTALL) | 59 | install: $(INSTALL) |
61 | 60 | ||
62 | test.exe: test.o $(TARGETS) | 61 | test.exe: test.c $(TARGETS) |
63 | $(CC) -o $@ $< -L. -ldl | 62 | $(CC) $(CFLAGS) -o $@ $< libdl.dll.a |
63 | |||
64 | test-static.exe: test.c $(TARGETS) | ||
65 | $(CC) $(CFLAGS) -o $@ $< libdl.a | ||
64 | 66 | ||
65 | testdll.dll: testdll.c | 67 | testdll.dll: testdll.c |
66 | $(CC) -shared -o $@ $^ | 68 | $(CC) $(CFLAGS) -shared -o $@ $^ |
67 | 69 | ||
68 | testdll2.dll: testdll2.c $(TARGETS) | 70 | testdll2.dll: testdll2.c $(TARGETS) |
69 | $(CC) -shared -o $@ $< -L. -ldl | 71 | $(CC) $(CFLAGS) -shared -o $@ $< -L. -ldl |
70 | 72 | ||
71 | testdll3.dll: testdll3.c | 73 | testdll3.dll: testdll3.c |
72 | $(CC) -shared -o $@ $^ | 74 | $(CC) -shared -o $@ $^ |
73 | 75 | ||
74 | test: $(TARGETS) test.exe testdll.dll testdll2.dll testdll3.dll | 76 | test: $(TARGETS) $(TESTS) testdll.dll testdll2.dll testdll3.dll |
75 | $(WINE) test.exe | 77 | for test in $(TESTS); do $(WINE) $$test || exit 1; done |
76 | 78 | ||
77 | clean:: | 79 | clean:: |
78 | rm -f \ | 80 | rm -f \ |
79 | dlfcn.o \ | 81 | dlfcn.o \ |
80 | libdl.dll libdl.a libdl.def libdl.dll.a libdl.lib libdl.exp \ | 82 | libdl.dll libdl.a libdl.def libdl.dll.a libdl.lib libdl.exp \ |
81 | tmptest.c tmptest.dll \ | 83 | tmptest.c tmptest.dll \ |
82 | test.exe testdll.dll testdll2.dll testdll3.dll | 84 | test.exe test-static.exe testdll.dll testdll2.dll testdll3.dll |
83 | 85 | ||
84 | distclean: clean | 86 | distclean: clean |
85 | rm -f config.mak | 87 | rm -f config.mak |