aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Gu <timothygu99@gmail.com>2014-02-07 05:14:03 +0000
committerTimothy Gu <timothygu99@gmail.com>2014-02-07 05:14:03 +0000
commit3982987839821826b5c9fa2addc960692ee12f53 (patch)
tree81e7bf0dcdf12dcf506f4cf51c308e662755dfec
parentf92c77180839e46e85d01c2507af6e5859542990 (diff)
downloaddlfcn-win32-3982987839821826b5c9fa2addc960692ee12f53.tar.gz
dlfcn-win32-3982987839821826b5c9fa2addc960692ee12f53.tar.bz2
dlfcn-win32-3982987839821826b5c9fa2addc960692ee12f53.zip
Makefile: some rework with better dependency tracking
More to come later
-rw-r--r--Makefile42
1 files changed, 24 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index e8cb005..42fb310 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@
4include config.mak 4include config.mak
5 5
6ifeq ($(BUILD_SHARED),yes) 6ifeq ($(BUILD_SHARED),yes)
7 TARGETS+=libdl.dll 7 TARGETS+=libdl.dll libdl.dll.a
8 SHFLAGS+=-Wl,--out-implib,libdl.dll.a 8 SHFLAGS+=-Wl,--out-implib,libdl.dll.a
9 INSTALL+=shared-install 9 INSTALL+=shared-install
10endif 10endif
@@ -13,49 +13,55 @@ ifeq ($(BUILD_STATIC),yes)
13 INSTALL+=static-install 13 INSTALL+=static-install
14endif 14endif
15ifeq ($(BUILD_MSVC),yes) 15ifeq ($(BUILD_MSVC),yes)
16 TARGETS+=libdl.lib
16 SHFLAGS+=-Wl,--output-def,libdl.def 17 SHFLAGS+=-Wl,--output-def,libdl.def
17 INSTALL+=lib-install 18 INSTALL+=lib-install
18endif 19endif
19 20
21LIB_OBJS := dlfcn.o
22HEADERS := dlfcn.h
23
20all: $(TARGETS) 24all: $(TARGETS)
21 25
22dlfcn.o: 26%.o: %.c
23 $(CC) -o dlfcn.o -c dlfcn.c -Wall -O3 -fomit-frame-pointer 27 $(CC) -o $@ -c $< -Wall -O3 -fomit-frame-pointer
24 28
25libdl.a: dlfcn.o 29libdl.a: $(LIB_OBJS)
26 $(AR) cru libdl.a dlfcn.o 30 $(AR) cru $@ $^
27 $(RANLIB) libdl.a 31 $(RANLIB) libdl.a
28 32
29libdl.dll: dlfcn.o 33libdl.dll libdl.dll.a: $(LIB_OBJS)
30 $(CC) $(SHFLAGS) -shared -o libdl.dll dlfcn.o 34 $(CC) $(SHFLAGS) -shared -o $@ $^
35
36libdl.lib: libdl.dll
31 $(LIBCMD) /machine:i386 /def:libdl.def 37 $(LIBCMD) /machine:i386 /def:libdl.def
32 38
33shared-install: 39include-install: $(HEADERS)
40 mkdir -p $(DESTDIR)$(incdir)
41 install -m 644 $^ "$(DESTDIR)$(incdir)"
42
43shared-install: include-install
34 mkdir -p $(DESTDIR)$(prefix)/bin 44 mkdir -p $(DESTDIR)$(prefix)/bin
35 cp libdl.dll $(DESTDIR)$(prefix)/bin 45 cp libdl.dll $(DESTDIR)$(prefix)/bin
36 $(STRIP) $(DESTDIR)$(prefix)/bin/libdl.dll 46 $(STRIP) $(DESTDIR)$(prefix)/bin/libdl.dll
37 mkdir -p $(DESTDIR)$(libdir) 47 mkdir -p $(DESTDIR)$(libdir)
38 cp libdl.dll.a $(DESTDIR)$(libdir) 48 cp libdl.dll.a $(DESTDIR)$(libdir)
39 mkdir -p $(DESTDIR)$(incdir)
40 cp dlfcn.h $(DESTDIR)$(incdir)
41 49
42static-install: 50static-install: include-install
43 mkdir -p $(DESTDIR)$(libdir) 51 mkdir -p $(DESTDIR)$(libdir)
44 cp libdl.a $(DESTDIR)$(libdir) 52 cp libdl.a $(DESTDIR)$(libdir)
45 mkdir -p $(DESTDIR)$(incdir)
46 cp dlfcn.h $(DESTDIR)$(incdir)
47 53
48lib-install: 54lib-install: $(LIBS)
49 mkdir -p $(DESTDIR)$(libdir) 55 mkdir -p $(DESTDIR)$(libdir)
50 cp libdl.lib $(DESTDIR)$(libdir) 56 cp libdl.lib $(DESTDIR)$(libdir)
51 57
52install: $(INSTALL) 58install: $(INSTALL)
53 59
54test.exe: 60test.exe: test.o $(TARGETS)
55 $(CC) -o test.exe test.c -L. -ldl 61 $(CC) -o $@ $< -L. -ldl
56 62
57testdll.dll: 63testdll.dll: testdll.c
58 $(CC) -shared -o testdll.dll testdll.c 64 $(CC) -shared -o $@ $^
59 65
60test: $(TARGETS) test.exe testdll.dll 66test: $(TARGETS) test.exe testdll.dll
61 test.exe 67 test.exe