82 lines
1.9 KiB
Makefile
82 lines
1.9 KiB
Makefile
CC?=gcc
|
|
CFLAGS:=-Wall -Werror -Wextra -I.
|
|
CFLAGS+=-g -ggdb
|
|
LDFLAGS+=-pthread
|
|
|
|
OBJ=build/femtotcp.o \
|
|
build/port/posix/linux_tap.o
|
|
|
|
EXE=build/tcpecho build/tcp_netcat_poll build/tcp_netcat_select \
|
|
build/test-evloop
|
|
LIB=libfemtotcp.so
|
|
|
|
PREFIX=/usr/local
|
|
|
|
|
|
all: $(EXE) $(LIB)
|
|
|
|
#Static library
|
|
static: CFLAGS+=-static
|
|
static: libtcpip.a
|
|
|
|
|
|
|
|
libtcpip.a: $(OBJ)
|
|
@ar rcs $@ $^
|
|
|
|
libfemtotcp.so:CFLAGS+=-fPIC
|
|
libfemtotcp.so: build/pie/port/posix/bsd_socket.o build/pie/femtotcp.o \
|
|
build/pie/port/posix/linux_tap.o
|
|
@mkdir -p `dirname $@` || true
|
|
@echo "[LD] $@"
|
|
@$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ -Wl,--start-group $(^) -Wl,--end-group
|
|
|
|
|
|
clean:
|
|
@rm -rf build
|
|
@make -C src/test/unit clean
|
|
|
|
asan: $(EXE) $(LIB)
|
|
asan:CFLAGS+=-fsanitize=address
|
|
asan:LDFLAGS+=-static-libasan
|
|
|
|
|
|
# Test
|
|
build/test-evloop: $(OBJ) build/test/test_linux_eventloop.o
|
|
@echo "[LD] $@"
|
|
@$(CC) $(CFLAGS) $(LDFLAGS) -o $@ -Wl,--start-group $(^) -Wl,--end-group
|
|
|
|
build/tcpecho: $(OBJ) build/port/posix/bsd_socket.o build/test/tcp_echo.o
|
|
@echo "[LD] $@"
|
|
@$(CC) $(CFLAGS) $(LDFLAGS) -o $@ -Wl,--start-group $(^) -Wl,--end-group
|
|
|
|
build/tcp_netcat_poll: $(OBJ) build/port/posix/bsd_socket.o build/test/tcp_netcat_poll.o
|
|
@echo "[LD] $@"
|
|
@$(CC) $(CFLAGS) $(LDFLAGS) -o $@ -Wl,--start-group $(^) -Wl,--end-group
|
|
|
|
build/tcp_netcat_select: $(OBJ) build/port/posix/bsd_socket.o build/test/tcp_netcat_select.o
|
|
@echo "[LD] $@"
|
|
@$(CC) $(CFLAGS) $(LDFLAGS) -o $@ -Wl,--start-group $(^) -Wl,--end-group
|
|
|
|
build/%.o: src/%.c
|
|
@mkdir -p `dirname $@` || true
|
|
@echo "[CC] $<"
|
|
@$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
build/pie/%.o: src/%.c
|
|
@mkdir -p `dirname $@` || true
|
|
@echo "[CC] $<"
|
|
@$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
unit:
|
|
@make -C src/test/unit
|
|
@mkdir -p build/test/
|
|
@mv src/test/unit/unit build/test
|
|
|
|
# Install dynamic library to re-link linux applications
|
|
#
|
|
install:
|
|
install libfemtotcp.so $(PREFIX)/lib
|
|
ldconfig
|
|
|
|
.PHONY: clean all static
|