femtoTCP/Makefile

83 lines
1.9 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
@make -C src/test/unit clean
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
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-10-27 13:23:31 +01:00
unit:
2024-11-16 07:34:11 +01:00
@make -C src/test/unit
@mkdir -p build/test/
@mv src/test/unit/unit build/test
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