summaryrefslogtreecommitdiff
path: root/external/mit/libuv/dist/docs/code/Makefile
blob: 0526e8c2eea651db1848ac85ef0c812e6081a3fc (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
76
77
78
79
80
81
82
examples=\
	helloworld\
	default-loop\
	idle-basic\
	uvcat\
	uvtee\
	onchange\
	thread-create\
	queue-work\
	progress\
	tcp-echo-server\
	dns\
	udp-dhcp\
	idle-compute\
	ref-timer\
	spawn\
	detach\
	proc-streams\
	cgi\
	pipe-echo-server\
	multi-echo-server\
	tty\
	tty-gravity\
	interfaces\
	locks \
	signal \
	uvstop \
	queue-cancel

UV_PATH=$(shell pwd)/../..
UV_LIB=$(UV_PATH)/.libs/libuv.a
CFLAGS=-g -Wall -I$(UV_PATH)/include
LIBS=

uname_S=$(shell uname -s)

ifeq (Darwin, $(uname_S))
CFLAGS+=-framework CoreServices
SHARED_LIB_FLAGS=-bundle -undefined dynamic_lookup -o plugin/libhello.dylib
endif

ifeq (Linux, $(uname_S))
LIBS=-lrt -ldl -lm -pthread -lcurl
SHARED_LIB_FLAGS=-shared -Wl,-soname,libhello.so -o plugin/libhello.so
PLUGIN_EXE_FLAGS=-Wl,-export-dynamic
endif


all: $(examples) plugin/plugin proc-streams/test cgi/tick multi-echo-server/worker uvwget/uvwget

$(examples): % : %/main.c
	gcc $(CFLAGS) -o $@/$@  $< $(UV_LIB) $(LIBS)

plugin: plugin/plugin
plugin/plugin: plugin/*.c
	gcc $(CFLAGS) $(PLUGIN_EXE_FLAGS) -o plugin/plugin plugin/main.c $(UV_LIB) $(LIBS)
	gcc -g -Wall -c -fPIC -o plugin/hello.o plugin/hello.c
	gcc $(SHARED_LIB_FLAGS) plugin/hello.o

proc-streams/test: proc-streams/test.c
	gcc -g -Wall -o proc-streams/test proc-streams/test.c

cgi/tick: cgi/tick.c
	gcc -g -Wall -o cgi/tick cgi/tick.c

multi-echo-server/worker: multi-echo-server/worker.c
	gcc $(CFLAGS) -o multi-echo-server/worker multi-echo-server/worker.c $(UV_LIB) $(LIBS)

uvwget: uvwget/uvwget
uvwget/uvwget: uvwget/main.c
	gcc $(CFLAGS) `curl-config --cflags --libs` -o uvwget/uvwget uvwget/main.c $(UV_LIB) $(LIBS)

clean:
	for dir in $(examples); do cd $$dir; rm -f $$dir; rm -rf $$dir.dSYM; cd ..; done
	rm -rf plugin/*.o plugin/libhello.*
	rm -rf plugin/plugin plugin/plugin.dSYM
	rm -rf proc-streams/test proc-streams/test.dSYM
	rm -rf cgi/tick cgi/tick.dSYM
	rm -rf multi-echo-server/worker multi-echo-server/worker.dSYM
	rm -rf uvwget/uvwget uvwget/uvwget.dSYM

.PHONY: clean all $(examples) plugin uvwget