forked from pandax381/microps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
52 lines (39 loc) · 1.1 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
APPS = app/udpc.exe \
app/udps.exe \
app/tcpc.exe \
app/tcps.exe \
TESTS = test/test.exe \
DRIVERS = driver/null.o \
driver/loopback.o \
OBJS = util.o \
net.o \
ether.o \
arp.o \
ip.o \
icmp.o \
udp.o \
tcp.o \
sock.o \
CFLAGS := $(CFLAGS) -g -W -Wall -Wno-unused-parameter -iquote .
ifeq ($(shell uname),Linux)
CFLAGS := $(CFLAGS) -pthread -iquote platform/linux
DRIVERS := $(DRIVERS) platform/linux/driver/ether_tap.o platform/linux/driver/ether_pcap.o
LDFLAGS := $(LDFLAGS) -lrt
OBJS := $(OBJS) platform/linux/sched.o platform/linux/intr.o
endif
ifeq ($(shell uname),Darwin)
CFLAGS := $(CFLAGS)
DRIVERS := $(DRIVERS)
endif
.SUFFIXES:
.SUFFIXES: .c .o
.PHONY: all clean
all: $(APPS) $(TESTS)
$(APPS): %.exe : %.o $(OBJS) $(DRIVERS)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
$(TESTS): %.exe : %.o $(OBJS) $(DRIVERS) test/test.h
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
.c.o:
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -rf $(APPS) $(APPS:.exe=.o) $(OBJS) $(DRIVERS) $(TESTS) $(TESTS:.exe=.o)