From 66cff2e98d5eb3aac96f586f2fa882b803dbebd0 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Tue, 3 Dec 2013 14:11:43 -0800 Subject: Create common Makefile that automatically loads make rules on a per-OS basis. --- .gitignore | 1 - Makefile | 11 +++++++++++ Makefile.linux | 48 ------------------------------------------------ Makefile.mac | 47 ----------------------------------------------- make-linux.mk | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ make-mac.mk | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 106 insertions(+), 96 deletions(-) create mode 100644 Makefile delete mode 100644 Makefile.linux delete mode 100644 Makefile.mac create mode 100644 make-linux.mk create mode 100644 make-mac.mk diff --git a/.gitignore b/.gitignore index 2fb0a651..1cdc1ba8 100755 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ /zerotier-* /build-ZeroTierUI-* /ZeroTierUI/*.user -/Makefile *.o .DS_Store .Apple* diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..ac50884c --- /dev/null +++ b/Makefile @@ -0,0 +1,11 @@ +# Common makefile -- loads make rules for each platform + +OSTYPE=$(shell uname -s) + +ifeq ($(OSTYPE),Darwin) + include make-mac.mk +endif + +ifeq ($(OSTYPE),Linux) + include make-linux.mk +endif diff --git a/Makefile.linux b/Makefile.linux deleted file mode 100644 index a432d912..00000000 --- a/Makefile.linux +++ /dev/null @@ -1,48 +0,0 @@ -CC=gcc -CXX=g++ - -INCLUDES= -DEFS= -LIBS= - -# Uncomment for a release optimized build -CFLAGS=-Wall -O3 -fno-unroll-loops -fvisibility=hidden -fstack-protector -pthread $(INCLUDES) -DNDEBUG $(DEFS) -STRIP=strip --strip-all - -# Uncomment for a debug build -#CFLAGS=-Wall -g -pthread $(INCLUDES) -DZT_TRACE $(DEFS) -#STRIP=echo - -# Uncomment for gprof profile build -#CFLAGS=-Wall -g -pg -pthread $(INCLUDES) $(DEFS) -#STRIP=echo - -CXXFLAGS=$(CFLAGS) -fno-rtti - -include objects.mk - -all: one - -one: $(OBJS) - $(CXX) $(CXXFLAGS) -o zerotier-one main.cpp $(OBJS) $(LIBS) - $(STRIP) zerotier-one - ln -sf zerotier-one zerotier-cli - -selftest: $(OBJS) - $(CXX) $(CXXFLAGS) -o zerotier-selftest selftest.cpp $(OBJS) $(LIBS) - $(STRIP) zerotier-selftest - -idtool: $(OBJS) - $(CXX) $(CXXFLAGS) -o zerotier-idtool idtool.cpp $(OBJS) $(LIBS) - $(STRIP) zerotier-idtool - -file2lz4c: ext/lz4/lz4hc.o FORCE - $(CXX) $(CXXFLAGS) -o file2lz4c file2lz4c.cpp node/Utils.cpp node/Salsa20.cpp ext/lz4/lz4hc.o - -installer: one FORCE - ./buildinstaller.sh - -clean: - rm -rf $(OBJS) file2lz4c zerotier-* zt1-*-install installer-build build-ZeroTierUI-* - -FORCE: diff --git a/Makefile.mac b/Makefile.mac deleted file mode 100644 index f0f56810..00000000 --- a/Makefile.mac +++ /dev/null @@ -1,47 +0,0 @@ -CC=clang -CXX=clang++ - -INCLUDES= -DEFS= -LIBS=-lm - -# Uncomment for a release optimized universal binary build -CFLAGS=-arch i386 -arch x86_64 -Wall -O4 -pthread -mmacosx-version-min=10.6 -DNDEBUG -Wno-unused-private-field $(INCLUDES) $(DEFS) -STRIP=strip - -# Uncomment for a debug build -#CFLAGS=-Wall -g -pthread -DZT_TRACE -DZT_LOG_STDOUT $(INCLUDES) $(DEFS) -#STRIP=echo - -CXXFLAGS=$(CFLAGS) -fno-rtti - -include objects.mk - -all: one - -one: $(OBJS) - $(CXX) $(CXXFLAGS) -o zerotier-one main.cpp $(OBJS) $(LIBS) - $(STRIP) zerotier-one - ln -sf zerotier-one zerotier-cli - -selftest: $(OBJS) - $(CXX) $(CXXFLAGS) -o zerotier-selftest selftest.cpp $(OBJS) $(LIBS) - $(STRIP) zerotier-selftest - -idtool: $(OBJS) - $(CXX) $(CXXFLAGS) -o zerotier-idtool idtool.cpp $(OBJS) $(LIBS) - $(STRIP) zerotier-idtool - -install-mac-tap: FORCE - mkdir -p /Library/Application\ Support/ZeroTier/One - rm -rf /Library/Application\ Support/ZeroTier/One/tap.kext - cp -R ext/bin/tap-mac//tap.kext /Library/Application\ Support/ZeroTier/One - chown -R root:wheel /Library/Application\ Support/ZeroTier/One/tap.kext - -file2lz4c: ext/lz4/lz4hc.o FORCE - $(CXX) $(CXXFLAGS) -o file2lz4c file2lz4c.cpp node/Utils.cpp node/Salsa20.cpp ext/lz4/lz4hc.o - -clean: - rm -rf *.dSYM build-ZeroTierUI-* $(OBJS) file2lz4c zerotier-* - -FORCE: diff --git a/make-linux.mk b/make-linux.mk new file mode 100644 index 00000000..a432d912 --- /dev/null +++ b/make-linux.mk @@ -0,0 +1,48 @@ +CC=gcc +CXX=g++ + +INCLUDES= +DEFS= +LIBS= + +# Uncomment for a release optimized build +CFLAGS=-Wall -O3 -fno-unroll-loops -fvisibility=hidden -fstack-protector -pthread $(INCLUDES) -DNDEBUG $(DEFS) +STRIP=strip --strip-all + +# Uncomment for a debug build +#CFLAGS=-Wall -g -pthread $(INCLUDES) -DZT_TRACE $(DEFS) +#STRIP=echo + +# Uncomment for gprof profile build +#CFLAGS=-Wall -g -pg -pthread $(INCLUDES) $(DEFS) +#STRIP=echo + +CXXFLAGS=$(CFLAGS) -fno-rtti + +include objects.mk + +all: one + +one: $(OBJS) + $(CXX) $(CXXFLAGS) -o zerotier-one main.cpp $(OBJS) $(LIBS) + $(STRIP) zerotier-one + ln -sf zerotier-one zerotier-cli + +selftest: $(OBJS) + $(CXX) $(CXXFLAGS) -o zerotier-selftest selftest.cpp $(OBJS) $(LIBS) + $(STRIP) zerotier-selftest + +idtool: $(OBJS) + $(CXX) $(CXXFLAGS) -o zerotier-idtool idtool.cpp $(OBJS) $(LIBS) + $(STRIP) zerotier-idtool + +file2lz4c: ext/lz4/lz4hc.o FORCE + $(CXX) $(CXXFLAGS) -o file2lz4c file2lz4c.cpp node/Utils.cpp node/Salsa20.cpp ext/lz4/lz4hc.o + +installer: one FORCE + ./buildinstaller.sh + +clean: + rm -rf $(OBJS) file2lz4c zerotier-* zt1-*-install installer-build build-ZeroTierUI-* + +FORCE: diff --git a/make-mac.mk b/make-mac.mk new file mode 100644 index 00000000..f0f56810 --- /dev/null +++ b/make-mac.mk @@ -0,0 +1,47 @@ +CC=clang +CXX=clang++ + +INCLUDES= +DEFS= +LIBS=-lm + +# Uncomment for a release optimized universal binary build +CFLAGS=-arch i386 -arch x86_64 -Wall -O4 -pthread -mmacosx-version-min=10.6 -DNDEBUG -Wno-unused-private-field $(INCLUDES) $(DEFS) +STRIP=strip + +# Uncomment for a debug build +#CFLAGS=-Wall -g -pthread -DZT_TRACE -DZT_LOG_STDOUT $(INCLUDES) $(DEFS) +#STRIP=echo + +CXXFLAGS=$(CFLAGS) -fno-rtti + +include objects.mk + +all: one + +one: $(OBJS) + $(CXX) $(CXXFLAGS) -o zerotier-one main.cpp $(OBJS) $(LIBS) + $(STRIP) zerotier-one + ln -sf zerotier-one zerotier-cli + +selftest: $(OBJS) + $(CXX) $(CXXFLAGS) -o zerotier-selftest selftest.cpp $(OBJS) $(LIBS) + $(STRIP) zerotier-selftest + +idtool: $(OBJS) + $(CXX) $(CXXFLAGS) -o zerotier-idtool idtool.cpp $(OBJS) $(LIBS) + $(STRIP) zerotier-idtool + +install-mac-tap: FORCE + mkdir -p /Library/Application\ Support/ZeroTier/One + rm -rf /Library/Application\ Support/ZeroTier/One/tap.kext + cp -R ext/bin/tap-mac//tap.kext /Library/Application\ Support/ZeroTier/One + chown -R root:wheel /Library/Application\ Support/ZeroTier/One/tap.kext + +file2lz4c: ext/lz4/lz4hc.o FORCE + $(CXX) $(CXXFLAGS) -o file2lz4c file2lz4c.cpp node/Utils.cpp node/Salsa20.cpp ext/lz4/lz4hc.o + +clean: + rm -rf *.dSYM build-ZeroTierUI-* $(OBJS) file2lz4c zerotier-* + +FORCE: -- cgit v1.2.3