-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
32 lines (24 loc) · 759 Bytes
/
Makefile
File metadata and controls
32 lines (24 loc) · 759 Bytes
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
PROJECT=switch
SOURCES=lib/queue.c lib/list.c lib/lib.c
LIBRARY=nope
INCPATHS=include
LIBPATHS=.
LDFLAGS=
CFLAGS=-c -Wall -Werror -Wno-error=unused-variable
CC=gcc
SWITCH_ID ?= 1
# Automatic generation of some important lists
OBJECTS=$(SOURCES:.c=.o)
INCFLAGS=$(foreach TMP,$(INCPATHS),-I$(TMP))
LIBFLAGS=$(foreach TMP,$(LIBPATHS),-L$(TMP))
# Set up the output file names for the different output types
BINARY=$(PROJECT)
all: $(SOURCES) $(BINARY)
$(BINARY): $(OBJECTS)
$(CC) $(LIBFLAGS) -shared $(OBJECTS) $(LDFLAGS) -o dlink.so
.c.o:
$(CC) $(INCFLAGS) $(CFLAGS) -fPIC $< -o $@
clean:
rm -rf $(OBJECTS) hosts_output router_* dlink.so
run_switch: all
python3 switch.py $(SWITCH_ID) $$(ifconfig -a | grep -o '^[^ :]*' | grep -v 'lo' | tr '\n' ' ')