gnublin1
authorgnublin <michael@wagnertech.de>
Sat, 12 Mar 2016 21:46:23 +0000 (22:46 +0100)
committergnublin <michael@wagnertech.de>
Sat, 12 Mar 2016 21:46:23 +0000 (22:46 +0100)
tools/make/c_configure.sh [new file with mode: 0755]
tools/make/configure
tools/make/cpp.make [new file with mode: 0644]
tools/make/makefile

diff --git a/tools/make/c_configure.sh b/tools/make/c_configure.sh
new file mode 100755 (executable)
index 0000000..16a0822
--- /dev/null
@@ -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
+}
+
index 9064c93..0771d51 100755 (executable)
@@ -10,7 +10,7 @@ function echo_usage {
 # to build a package you need ...
 # <package>.co: checkout commands
 # <package>.cp (optional): copy step for package production
-# <package>.cpp (optional): commands to setup the C++ compile environment
+# <package>.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
 # mBuild make.pre script (auto generated)
 project = $paket
-version = $version
 COPY = ./$paket.cp
 MAKE_PRE
        echo "make.pre written."
 fi
 
+# append version to make.pre
+echo "version = $version" >> make.pre
+
diff --git a/tools/make/cpp.make b/tools/make/cpp.make
new file mode 100644 (file)
index 0000000..1b4d863
--- /dev/null
@@ -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
index 7fadac9..60e6780 100644 (file)
@@ -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