femtoTCP/Makefile

88 lines
2 KiB
Makefile
Raw Normal View History

2024-10-27 13:23:31 +01:00
CC?=gcc
CFLAGS:=-Wall -Werror -Wextra -I.
CFLAGS+=-g -ggdb
LDFLAGS+=-pthread
2024-11-16 07:34:11 +01:00
OBJ=build/femtotcp.o \
build/port/posix/linux_tap.o
2024-11-17 12:59:48 +01:00
EXE=build/tcpecho build/tcp_netcat_poll build/tcp_netcat_select \
build/test-evloop
LIB=libfemtotcp.so
2024-10-27 13:23:31 +01:00
2024-11-28 12:44:58 +01:00
PREFIX=/usr/local
2024-10-27 13:23:31 +01:00
all: $(EXE) $(LIB)
2024-10-27 13:23:31 +01:00
#Static library
static: CFLAGS+=-static
static: libtcpip.a
2024-10-27 13:23:31 +01:00
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
2024-10-27 13:23:31 +01:00
clean:
2024-11-16 07:34:11 +01:00
@rm -rf build
2024-10-27 13:23:31 +01:00
asan: $(EXE) $(LIB)
2024-10-27 13:23:31 +01:00
asan:CFLAGS+=-fsanitize=address
asan:LDFLAGS+=-static-libasan
# Test
2024-12-15 01:51:33 +01:00
unit:LDFLAGS+=-lcheck -lm -lpthread -lrt -ldl -lsubunit
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
2024-11-16 07:34:11 +01:00
@echo "[LD] $@"
@$(CC) $(CFLAGS) $(LDFLAGS) -o $@ -Wl,--start-group $(^) -Wl,--end-group
2024-10-27 13:23:31 +01:00
2024-11-17 12:59:48 +01:00
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
2024-10-27 13:23:31 +01:00
build/%.o: src/%.c
2024-11-16 07:34:11 +01:00
@mkdir -p `dirname $@` || true
@echo "[CC] $<"
2024-10-27 13:23:31 +01:00
@$(CC) $(CFLAGS) -c $< -o $@
build/pie/%.o: src/%.c
@mkdir -p `dirname $@` || true
@echo "[CC] $<"
@$(CC) $(CFLAGS) -c $< -o $@
2024-12-15 01:51:33 +01:00
unit: build/test/unit
build/test/unit:
2024-11-16 07:34:11 +01:00
@mkdir -p build/test/
2024-12-15 01:51:33 +01:00
@echo "[CC] unit.c"
@$(CC) $(CFLAGS) -c src/test/unit/unit.c -o build/test/unit.o
@echo "[LD] $@"
@$(CC) -o build/test/unit build/test/unit.o $(LDFLAGS)
2024-10-27 13:23:31 +01:00
2024-11-28 12:44:58 +01:00
# Install dynamic library to re-link linux applications
#
install:
install libfemtotcp.so $(PREFIX)/lib
ldconfig
2024-10-27 13:23:31 +01:00
.PHONY: clean all static