From 349dac963257d776985bd0b46ff50d0746a9ae51 Mon Sep 17 00:00:00 2001 From: Benny Baumann Date: Thu, 4 Sep 2014 17:10:39 +0200 Subject: [PATCH] add: Initial build system to create binaries from our source --- Makefile | 112 ++++++++++++++++++++++++++++++++++ debian/cassiopeia.install | 1 + debian/control | 2 +- lib/collissiondetect/Makefile | 7 +++ lib/openssl/Makefile | 7 +++ test/Makefile | 7 +++ 6 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 Makefile create mode 100644 debian/cassiopeia.install create mode 100644 lib/collissiondetect/Makefile create mode 100644 lib/openssl/Makefile create mode 100644 test/Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6c98274 --- /dev/null +++ b/Makefile @@ -0,0 +1,112 @@ +INSTALL = ${shell which install} +INSTALL_FILE = $(INSTALL) -p -D -o root -g root -m 644 +INSTALL_PROGRAM = $(INSTALL) -p -D -o root -g root -m 700 +INSTALL_SCRIPT = $(INSTALL) -p -D -o root -g root -m 700 +INSTALL_DIR = $(INSTALL) -p -d -o root -g root -m 755 + +MKDIR = mkdir -p + +ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O2 +endif +ifeq (,$(filter nostrip,$(DEB_BUILD_OPTIONS))) + INSTALL_PROGRAM += -s +endif +ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) + NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) + MAKEFLAGS += -j$(NUMJOBS) +endif + +BIN="bin/cassiopeia" +LIBS=openssl collissiondetect + +LT_CC=libtool --mode=compile gcc +LT_CC_DEP=g++ +LT_CXX=libtool --mode=compile g++ +LT_CXX_DEP=g++ +LT_LD=libtool --mode=link g++ + +CC=${LT_CC} +CC_DEP=${LT_CC_DEP} +CXX=${LT_CXX} +CXX_DEP=${LT_CXX_DEP} +LD=${LT_LD} + +CFLAGS=-O3 -g -flto -Wall -Werror -Wextra -pedantic -std=c++11 +CXXFLAGS=$(CFLAGS) +LDFLAGS=-O3 -g -flto + +SRC_DIR=src +OBJ_DIR=obj +DEP_DIR=dep + +FS_SRC=$(wildcard ${SRC_DIR}/*.cpp) +FS_BIN=$(wildcard ${SRC_DIR}/app/*.cpp) +FS_LIBS=$(wildcard lib/*/) +FS_OBJ=$(FS_SRC:${SRC_DIR}/%.cpp=${OBJ_DIR}/%.lo) +FS_DEP=$(FS_SRC:${SRC_DIR}/%.cpp=${DEP_DIR}/%.d) + +.SUFFIXES: .c .cpp .d + +.PHONY: all +all: build + +.PHONY: clean +clean:: + -rm -rf .libs + -rm -rf *.a + -rm -rf *.d + -rm -rf *.o + -rm -rf *.la + -rm -rf *.lo + -rm -rf *.so + -rm -rf ${OBJ_DIR} + -rm -rf ${DEP_DIR} + ${MAKE} -C lib/openssl clean + ${MAKE} -C lib/collissiondetect clean +ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) + # Code to run the package test suite. + ${MAKE} -C test clean +endif + + +build: cassiopeia +ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) + ${MAKE} -C test +endif + +.PHONY: install +install: build + ${INSTALL_PROGRAM} bin/cassiopeia ${DESTDIR}/usr/bin/cassiopeia + +.PHONY: libs +libs: ${LIBS} + +.PHONY: openssl +openssl: + ${MAKE} -C lib/openssl + +.PHONY: collissiondetect +collissiondetect: + ${MAKE} -C lib/collissiondetect + +# -------- + +cassiopeia: bin/cassiopeia + +bin/cassiopeia: libs ${FS_OBJ} + ${MKDIR} $(shell dirname $@) && ${LT_LD} -o $@ ${FS_OBJ} + +${DEP_DIR}/%.d: ${SRC_DIR}/%.cpp + ${MKDIR} $(shell dirname $@) && $(CXX_DEP) $(CXXFLAGS) -M -MF $@ $< +${DEP_DIR}/%.d: ${SRC_DIR}/%.c + ${MKDIR} $(shell dirname $@) && $(CC) $(CXXFLAGS) -M -MF $@ $< + +${OBJ_DIR}/%.lo ${OBJ_DIR}/%.o: ${SRC_DIR}/%.c ${DEP_DIR}/%.d + ${MKDIR} $(shell dirname $@) && $(CC) $(CFLAGS) -o $@ -c $< +${OBJ_DIR}/%.lo ${OBJ_DIR}/%.o: ${SRC_DIR}/%.cpp ${DEP_DIR}/%.d + ${MKDIR} $(shell dirname $@) && $(CXX) $(CXXFLAGS) -o $@ -c $< + +-include $(FS_DEP) diff --git a/debian/cassiopeia.install b/debian/cassiopeia.install new file mode 100644 index 0000000..85d1e46 --- /dev/null +++ b/debian/cassiopeia.install @@ -0,0 +1 @@ +/usr/bin/cassiopeia diff --git a/debian/control b/debian/control index 0e40186..493d920 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: cassiopeia Section: unknown Priority: extra Maintainer: CAcert Software Team -Build-Depends: debhelper (>= 8.0.0) +Build-Depends: debhelper (>= 8.0.0), libtool Standards-Version: 3.9.4 Homepage: https://cacert.org/ #Vcs-Git: git://git.debian.org/collab-maint/cassiopeia.git diff --git a/lib/collissiondetect/Makefile b/lib/collissiondetect/Makefile new file mode 100644 index 0000000..486754b --- /dev/null +++ b/lib/collissiondetect/Makefile @@ -0,0 +1,7 @@ +.PHONY: all +all: + @echo "Building Collission Detection library ..." + +.PHONY: clean +clean: + @echo "Cleaning Collission Detection library ..." diff --git a/lib/openssl/Makefile b/lib/openssl/Makefile new file mode 100644 index 0000000..527c483 --- /dev/null +++ b/lib/openssl/Makefile @@ -0,0 +1,7 @@ +.PHONY: all +all: + @echo "Building Wide Open SSL ..." + +.PHONY: clean +clean: + @echo "Flensing Wide Open SSL ..." diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000..4618c42 --- /dev/null +++ b/test/Makefile @@ -0,0 +1,7 @@ +.PHONY: all +all: + @echo 'Performing some important tests ...' + +.PHONY: clean +clean: + @echo 'Cleaning up behind us ...' -- 2.39.2