diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..dc5dac3 --- /dev/null +++ b/.dockerignore @@ -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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..beaa9fc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +# start with ubuntu +FROM ubuntu:20.04 + +# it me! +LABEL maintainer="coditva@gmail.com" + +# 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"] diff --git a/Makefile b/Makefile index 9d3e624..620aa13 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/README.md b/README.md index 7207be8..0e13c51 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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. diff --git a/progs/Makefile b/progs/Makefile index 98d1248..a3a857f 100644 --- a/progs/Makefile +++ b/progs/Makefile @@ -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 diff --git a/src/Makefile b/src/Makefile index fe4f40a..596c129 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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 \ @@ -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 $<