diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6d8be14 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/hans +/build diff --git a/gpl.txt b/LICENSE similarity index 100% rename from gpl.txt rename to LICENSE diff --git a/Makefile b/Makefile index ab853d0..cf4b2dc 100644 --- a/Makefile +++ b/Makefile @@ -4,50 +4,59 @@ TUN_DEV_FILE = `sh osflags dev $(MODE)` GCC = gcc GPP = g++ +.PHONY: directories + all: hans -hans: tun.o sha1.o main.o client.o server.o auth.o worker.o time.o tun_dev.o echo.o exception.o utility.o - $(GPP) -o hans tun.o sha1.o main.o client.o server.o auth.o worker.o time.o tun_dev.o echo.o exception.o utility.o $(LDFLAGS) +directories: build_dir -utility.o: utility.cpp utility.h - $(GPP) -c utility.cpp $(CFLAGS) +build_dir: + mkdir -p build -exception.o: exception.cpp exception.h - $(GPP) -c exception.cpp $(CFLAGS) +tunemu.o: directories build/tunemu.o -echo.o: echo.cpp echo.h exception.h - $(GPP) -c echo.cpp $(CFLAGS) +hans: directories build/tun.o build/sha1.o build/main.o build/client.o build/server.o build/auth.o build/worker.o build/time.o build/tun_dev.o build/echo.o build/exception.o build/utility.o + $(GPP) -o hans build/tun.o build/sha1.o build/main.o build/client.o build/server.o build/auth.o build/worker.o build/time.o build/tun_dev.o build/echo.o build/exception.o build/utility.o $(LDFLAGS) -tun.o: tun.cpp tun.h exception.h utility.h tun_dev.h - $(GPP) -c tun.cpp $(CFLAGS) +build/utility.o: src/utility.cpp src/utility.h + $(GPP) -c src/utility.cpp -o $@ -o $@ $(CFLAGS) -tun_dev.o: - $(GCC) -c $(TUN_DEV_FILE) -o tun_dev.o $(CFLAGS) +build/exception.o: src/exception.cpp src/exception.h + $(GPP) -c src/exception.cpp -o $@ $(CFLAGS) -sha1.o: sha1.cpp sha1.h - $(GPP) -c sha1.cpp $(CFLAGS) +build/echo.o: src/echo.cpp src/echo.h src/exception.h + $(GPP) -c src/echo.cpp -o $@ $(CFLAGS) -main.o: main.cpp client.h server.h exception.h worker.h auth.h time.h echo.h tun.h tun_dev.h - $(GPP) -c main.cpp $(CFLAGS) +build/tun.o: src/tun.cpp src/tun.h src/exception.h src/utility.h src/tun_dev.h + $(GPP) -c src/tun.cpp -o $@ $(CFLAGS) -client.o: client.cpp client.h server.h exception.h config.h worker.h auth.h time.h echo.h tun.h tun_dev.h - $(GPP) -c client.cpp $(CFLAGS) +build/tun_dev.o: + $(GCC) -c $(TUN_DEV_FILE) -o build/tun_dev.o -o $@ $(CFLAGS) -server.o: server.cpp server.h client.h utility.h config.h worker.h auth.h time.h echo.h tun.h tun_dev.h - $(GPP) -c server.cpp $(CFLAGS) +build/sha1.o: src/sha1.cpp src/sha1.h + $(GPP) -c src/sha1.cpp -o $@ $(CFLAGS) -auth.o: auth.cpp auth.h sha1.h utility.h - $(GPP) -c auth.cpp $(CFLAGS) +build/main.o: src/main.cpp src/client.h src/server.h src/exception.h src/worker.h src/auth.h src/time.h src/echo.h src/tun.h src/tun_dev.h + $(GPP) -c src/main.cpp -o $@ $(CFLAGS) -worker.o: worker.cpp worker.h tun.h exception.h time.h echo.h tun_dev.h config.h - $(GPP) -c worker.cpp $(CFLAGS) +build/client.o: src/client.cpp src/client.h src/server.h src/exception.h src/config.h src/worker.h src/auth.h src/time.h src/echo.h src/tun.h src/tun_dev.h + $(GPP) -c src/client.cpp -o $@ $(CFLAGS) -time.o: time.cpp time.h - $(GPP) -c time.cpp $(CFLAGS) +build/server.o: src/server.cpp src/server.h src/client.h src/utility.h src/config.h src/worker.h src/auth.h src/time.h src/echo.h src/tun.h src/tun_dev.h + $(GPP) -c src/server.cpp -o $@ $(CFLAGS) + +build/auth.o: src/auth.cpp src/auth.h src/sha1.h src/utility.h + $(GPP) -c src/auth.cpp -o $@ $(CFLAGS) + +build/worker.o: src/worker.cpp src/worker.h src/tun.h src/exception.h src/time.h src/echo.h src/tun_dev.h src/config.h + $(GPP) -c src/worker.cpp -o $@ $(CFLAGS) + +build/time.o: src/time.cpp src/time.h + $(GPP) -c src/time.cpp -o $@ $(CFLAGS) clean: - rm -f tun.o sha1.o main.o client.o server.o auth.o worker.o time.o tun_dev.o echo.o exception.o utility.o tunemu.o hans + rm -f build/tun.o build/sha1.o build/main.o build/client.o build/server.o build/auth.o build/worker.o build/time.o build/tun_dev.o build/echo.o build/exception.o build/utility.o build/tunemu.o hans + rm -df build - -tunemu.o: tunemu.h tunemu.c - $(GCC) -c tunemu.c -o tunemu.o +build/tunemu.o: src/tunemu.h src/tunemu.c + $(GCC) -c src/tunemu.c -o build/tunemu.o diff --git a/osflags b/osflags index a0dacb6..80b117b 100644 --- a/osflags +++ b/osflags @@ -8,7 +8,7 @@ ld) case $OS in DARWIN) if [ "$MODE" == TUNEMU ]; then - echo tunemu.o -lpcap + echo build/tunemu.o -lpcap fi ;; esac @@ -28,23 +28,23 @@ c) dev) case $OS in LINUX) - echo tun_dev_linux.c + echo src/tun_dev_linux.c ;; FREEBSD) - echo tun_dev_freebsd.c + echo src/tun_dev_freebsd.c ;; OPENBSD) - echo tun_dev_openbsd.c + echo src/tun_dev_openbsd.c ;; DARWIN) if [ "$MODE" == TUNEMU ]; then - echo tun_dev_darwin_emu.c + echo src/tun_dev_darwin_emu.c else - echo tun_dev_generic.c + echo src/tun_dev_generic.c fi ;; *) - echo tun_dev_generic.c + echo src/tun_dev_generic.c ;; esac ;; diff --git a/auth.cpp b/src/auth.cpp similarity index 100% rename from auth.cpp rename to src/auth.cpp diff --git a/auth.h b/src/auth.h similarity index 100% rename from auth.h rename to src/auth.h diff --git a/client.cpp b/src/client.cpp similarity index 100% rename from client.cpp rename to src/client.cpp diff --git a/client.h b/src/client.h similarity index 100% rename from client.h rename to src/client.h diff --git a/config.h b/src/config.h similarity index 100% rename from config.h rename to src/config.h diff --git a/echo.cpp b/src/echo.cpp similarity index 100% rename from echo.cpp rename to src/echo.cpp diff --git a/echo.h b/src/echo.h similarity index 100% rename from echo.h rename to src/echo.h diff --git a/exception.cpp b/src/exception.cpp similarity index 100% rename from exception.cpp rename to src/exception.cpp diff --git a/exception.h b/src/exception.h similarity index 100% rename from exception.h rename to src/exception.h diff --git a/main.cpp b/src/main.cpp similarity index 100% rename from main.cpp rename to src/main.cpp diff --git a/server.cpp b/src/server.cpp similarity index 100% rename from server.cpp rename to src/server.cpp diff --git a/server.h b/src/server.h similarity index 100% rename from server.h rename to src/server.h diff --git a/sha1.cpp b/src/sha1.cpp similarity index 100% rename from sha1.cpp rename to src/sha1.cpp diff --git a/sha1.h b/src/sha1.h similarity index 100% rename from sha1.h rename to src/sha1.h diff --git a/sha1 license.txt b/src/sha1_license.txt similarity index 100% rename from sha1 license.txt rename to src/sha1_license.txt diff --git a/time.cpp b/src/time.cpp similarity index 100% rename from time.cpp rename to src/time.cpp diff --git a/time.h b/src/time.h similarity index 100% rename from time.h rename to src/time.h diff --git a/tun.cpp b/src/tun.cpp similarity index 100% rename from tun.cpp rename to src/tun.cpp diff --git a/tun.h b/src/tun.h similarity index 100% rename from tun.h rename to src/tun.h diff --git a/tun_dev.h b/src/tun_dev.h similarity index 100% rename from tun_dev.h rename to src/tun_dev.h diff --git a/tun_dev_darwin_emu.c b/src/tun_dev_darwin_emu.c similarity index 100% rename from tun_dev_darwin_emu.c rename to src/tun_dev_darwin_emu.c diff --git a/tun_dev_freebsd.c b/src/tun_dev_freebsd.c similarity index 100% rename from tun_dev_freebsd.c rename to src/tun_dev_freebsd.c diff --git a/tun_dev_generic.c b/src/tun_dev_generic.c similarity index 100% rename from tun_dev_generic.c rename to src/tun_dev_generic.c diff --git a/tun_dev_linux.c b/src/tun_dev_linux.c similarity index 100% rename from tun_dev_linux.c rename to src/tun_dev_linux.c diff --git a/tun_dev_openbsd.c b/src/tun_dev_openbsd.c similarity index 100% rename from tun_dev_openbsd.c rename to src/tun_dev_openbsd.c diff --git a/tun_dev_svr4.c b/src/tun_dev_svr4.c similarity index 100% rename from tun_dev_svr4.c rename to src/tun_dev_svr4.c diff --git a/tunemu.c b/src/tunemu.c similarity index 100% rename from tunemu.c rename to src/tunemu.c diff --git a/tunemu.h b/src/tunemu.h similarity index 100% rename from tunemu.h rename to src/tunemu.h diff --git a/utility.cpp b/src/utility.cpp similarity index 100% rename from utility.cpp rename to src/utility.cpp diff --git a/utility.h b/src/utility.h similarity index 100% rename from utility.h rename to src/utility.h diff --git a/worker.cpp b/src/worker.cpp similarity index 100% rename from worker.cpp rename to src/worker.cpp diff --git a/worker.h b/src/worker.h similarity index 100% rename from worker.h rename to src/worker.h