Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app
test/run_tests
progs/server
progs/client
progs/sendfile
progs/recvfile

# Temporary things
temp/
assets/recvfile

# Tags
tags

# Git
.git/
.gitignore
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# start with ubuntu
FROM ubuntu:20.04

# it me!
LABEL maintainer="[email protected]"

# install deps and cleanup
RUN apt-get update && \
apt-get -y install --no-install-recommends \
gcc build-essential && \
rm -rf /var/lib/apt/lists/*

# setup environment
ENV app /root/app/
ENV BUILD_TYPE release

# copy source to app dir
ADD . $app

# change to app dir
WORKDIR $app

# export the library path
RUN echo 'export LD_LIBRARY_PATH=./src/:$LD_LIBRARY_PATH' >> ~/.bashrc

# compile it
RUN make

# drop me in a shell
ENTRYPOINT ["/bin/bash"]
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
CC = g++
CC_FLAGS = -Wall -pedantic
CC = gcc
CC_FLAGS ?= -Wall -pedantic

BUILD_TYPE ?= 'debug'

ifeq ($(BUILD_TYPE), 'debug')
CC_FLAGS := $(CC_FLAGS) -g
endif

.PHONY : all

all :
$(MAKE) --directory src
$(MAKE) --directory progs
$(MAKE) --directory src CC_FLAGS="${CC_FLAGS}" CC="${CC}"
$(MAKE) --directory progs CC_FLAGS="${CC_FLAGS}" CC="${CC}"

clean :
$(MAKE) --directory src clean
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The documentation can be found in the header files (see `include/udt.h`).
```bash
make # compile
make clean # cleanup
make BUILD_TYPE='debug' # to create dev build with symbols for gdb

export LD_LIBRARY_PATH=./src/:$LD_LIBRARY_PATH # export the library path

Expand All @@ -22,6 +23,12 @@ progs/sendfile # start the sendfile server
progs/recvfile "file/to/get" "file/to/saveas" # receive the file
```

##### You can also use the dockerfile!
```bash
docker build --tag udt . # build the container
docker run -it udt
```

### Progress
- [x] Implement architecture.
- [x] Implement basic API.
Expand Down
4 changes: 2 additions & 2 deletions progs/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CC = gcc
CC_FLAGS = -Wall -pedantic
CC ?= gcc
CC_FLAGS ?= -Wall -pedantic
CL_FLAGS = -L../src -ludt-c -lpthread
INC = ../include/udt.h
TARGETS = server client sendfile recvfile
Expand Down
10 changes: 6 additions & 4 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
TARGET = libudt-c.so
CC = gcc
CC_FLAGS = -Wall -g -pedantic -shared -fPIC
CC ?= gcc
CC_FLAGS ?= -Wall -pedantic
C_FLAGS = $(CC_FLAGS) -fPIC
LD_FLAGS = -shared
INC_DIR = ../include
INC = ../include/config.h \
../include/udt.h \
Expand All @@ -20,10 +22,10 @@ OBJS = api.o \
util.o

$(TARGET): $(OBJS)
$(CC) $(CC_FLAGS) $(OBJS) -o $@
$(CC) $(C_FLAGS) $(LD_FLAGS) $(OBJS) -o $@

clean:
rm -f *.o $(OBJS) $(TARGET)

$(OBJS):%.o: %.c $(INC) Makefile
$(CC) $(CC_FLAGS) -I$(INC_DIR) -c $<
$(CC) $(C_FLAGS) -I$(INC_DIR) -c $<