From 8aa3f75cc1f16a25491abc5cd8a4ed554ad26f0d Mon Sep 17 00:00:00 2001 From: gnublin Date: Sat, 12 Mar 2016 22:46:23 +0100 Subject: [PATCH] gnublin1 --- tools/make/c_configure.sh | 65 +++++++++++++++++++++++++++++++++++++++ tools/make/configure | 25 +++++++++------ tools/make/cpp.make | 23 ++++++++++++++ tools/make/makefile | 10 +----- 4 files changed, 104 insertions(+), 19 deletions(-) create mode 100755 tools/make/c_configure.sh create mode 100644 tools/make/cpp.make diff --git a/tools/make/c_configure.sh b/tools/make/c_configure.sh new file mode 100755 index 0000000..16a0822 --- /dev/null +++ b/tools/make/c_configure.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +# util routines for a C/C++ - build + +function check_arch { + case $1 in + armel) ;; + i386) ;; + *) echo "unknown architecture $1" + exit 1 + esac +} + +function install_cpp_make { +# $1: dir to install + src=$(pwd); + pushd $1 + if [ -f makefile ]; then rm makefile; fi + if [ -f make.post ]; then rm make.post; fi + ln -s $cwd/Make/cpp.make makefile + echo "SOURCE = \\" > make.pre + for file in $(ls *.cpp) + do + echo " $file \\" >> make.pre + done + echo >> make.pre + if [ "$ARCH" = "armel" ] + then + echo "CXX = arm-linux-gnueabi-g++" >> make.pre + echo "CC = arm-linux-gnueabi-g++" >> make.pre + echo "CXXFLAGS += -D_ARMEL" >> make.pre + echo 'export PATH := /opt/eldk-5.0/armv5te/sysroots/i686-oesdk-linux/usr/bin/armv5te-linux-gnueabi/:/opt/eldk-5.0/armv5te/sysroots/i686-oesdk-linux/bin/armv5te-linux-gnueabi/:$(PATH)' >> make.pre + fi + echo "CXXFLAGS += -std=c++0x -I$src/util" >> make.pre + popd +} + +function append_dependency { +# parameter: +# $1: main directory +# $2: dependency directory +# $3: dependency artefact + + src=$(pwd) + echo "DEPS += $3" >> $1/make.pre + echo "$3:" >> $1/make.post + echo " cd $src/$2 && make TARGET=$3" >> $1/make.post + echo "" >> $1/make.post +} + +function append_library { +# parameter: +# $1: main directory +# $2: dependency directory +# $3: dependency artefact + + src=$(pwd) + echo "DEPS += $3" >> $1/make.pre + echo "LDLIBS += $3" >> $1/make.pre + echo "$3:" >> $1/make.post + echo " cd $src/$2 && make TARGET=$3" >> $1/make.post + echo " ln -sf $src/$2/$3 ." >> $1/make.post + echo "" >> $1/make.post +} + diff --git a/tools/make/configure b/tools/make/configure index 9064c93..0771d51 100755 --- a/tools/make/configure +++ b/tools/make/configure @@ -10,7 +10,7 @@ function echo_usage { # to build a package you need ... # .co: checkout commands # .cp (optional): copy step for package production -# .cpp (optional): commands to setup the C++ compile environment +# .cpp.sh (optional): commands to setup the C++ compile environment if [ $# -lt 2 ] then @@ -41,19 +41,13 @@ then echo " this file is necessary for any package production." fi -# load util functions for C/C++ - build -if [ -f $paket.cpp ] -then - cpp_build=1 - . Make/c_configure.sh -fi - # clean dirs and check out if [ -e $paket ] then rm -rf $paket fi rm *.stamp || true +rm make.pre || true mkdir -p src cwd=$(pwd) @@ -63,6 +57,14 @@ pushd src >/dev/null ../$paket.co $build popd >/dev/null +# load util functions for C/C++ - build +if [ -f $paket.cpp.sh ] +then + cpp_build=1 + . projects/tools/make/c_configure.sh + . $paket.cpp.sh +fi + # copy package control control=$(find src -name $paket.control) if [ -z "$control" ] @@ -70,13 +72,14 @@ then echo "warning: control file not found" echo " this file is necessary for any package production." else - sed "s/%BUILD%/$build/" $control >$paket.control + sed "s/%BUILD%/$build/" $control |sed "s/%ARCH%/$ARCH/" >$paket.control echo "$paket.control written." # extract version version=$(grep Version $paket.control |sed "s/Version: //") fi + # check for postinst postinst=$(find src -name $paket.postinst) if [ -n "$postinst" ] @@ -90,9 +93,11 @@ then cat >>make.pre <> make.pre + diff --git a/tools/make/cpp.make b/tools/make/cpp.make new file mode 100644 index 0000000..1b4d863 --- /dev/null +++ b/tools/make/cpp.make @@ -0,0 +1,23 @@ +# Generic cpp makefile for mBuild build process + +# default parameters +CC = g++ + +include make.pre + +# All Target +all: $(DEPS) $(SOURCE:%.cpp=%.o) $(TARGET) + +# Other Targets +clean: + -rm *.o + -rm $(TARGET) + +.PHONY: all make.post + +%.a: $(SOURCE:%.cpp=%.o) + ar r $(TARGET) *.o + +%.so: $(SOURCE:%.cpp=%.o) $(LDLIBS) + $(CXX) -shared -o $(TARGET) *.o $(LDLIBS) +-include make.post diff --git a/tools/make/makefile b/tools/make/makefile index 7fadac9..60e6780 100644 --- a/tools/make/makefile +++ b/tools/make/makefile @@ -12,7 +12,6 @@ DEB = fakeroot dpkg-deb --build $(project) project = default SOURCES = COPY_PRE = -TEX = pdflatex # Load project specification include make.pre @@ -65,7 +64,7 @@ $(project).zip: copy.stamp $(project) $(project).deb: copy.stamp control.stamp $(DEB) - cp $(project).deb $(project)_$(version).deb + cp $(project).deb $(project)_$(version)$(_arch).deb #----------------------------------------------------------------- # utilities @@ -75,10 +74,3 @@ clean: if [ -e $(project).zip ]; then rm $(project).zip; fi if [ -e $(project) ]; then rm -rf $(project); fi -#----------------------------------------------------------------- -# generische Regeln -#----------------------------------------------------------------- -%.pdf:%.tex - $(TEX) $< - --include make.post -- 2.20.1