posaune
authorMichael J.M. Wagner <michael@wagnertech.de>
Fri, 23 Sep 2022 16:58:04 +0000 (18:58 +0200)
committerMichael J.M. Wagner <michael@wagnertech.de>
Fri, 23 Sep 2022 16:58:04 +0000 (18:58 +0200)
tools/make/configure
tools/make/mMakefile
tools/make/mconfigure
tools/make/rules

index f83750e..acf16cb 100755 (executable)
@@ -3,22 +3,28 @@ set -e
 
 function echo_usage {
        echo "usage: configure [options] <package>"
-       echo "  -a <arch>"
-       echo "  -b : extern build in ../build directory"
-       echo "  -c <compile_dir>"
-       echo "  -C <cross environment>"
-       echo "  -i : install dir. default: /"
-       echo "  -I : print this info"
-       echo "  -t <compile type: NONE, CPP, CMAKE, PDF> default: NONE"
-       echo "  -v : set version"
-       echo "  -V : version set by project"
+       echo "--- general options ---"
+       echo "  -h : print this info"
+       echo "--- compile options ---"
+       echo "  -a <arch>"
+       echo "  -c <compile type: NONE|CPP|CMAKE|PDF|ANY> default: NONE"
+       echo "  -C <cross environment>"
+       echo "  -d <compile_dir>"
+       echo "  -e <compile_target>"
+       echo "--- build target options ---"
+       echo "  -i : install dir. default: /, nec. for make install"
+       echo "  -n <target_name>: default: <package>"
+       echo "  -t <target_type: FILE|DEB|ZIP>, nec. for make pack"
+       echo "  -v : set version"
+       echo "  -V : version set by project"
 }
 
 function create_build {
        pushd $BUILD_DIR >/dev/null
                if [ "$compile_type" == "PDF" ]
                then
-                       echo "make $compile_target" > debian/$paket.build
+                       echo "cd $compile_dir" >  debian/$paket.build
+                       echo "make $compile_target" >> debian/$paket.build
                        chmod 755 debian/$paket.build
                else
                        echo "build for compile_type not implemented."
@@ -138,6 +144,23 @@ function check_version {
        fi
 }
 
+function add_sources {
+       echo "Anz: $#"
+       for suf in $*
+       do
+               find . -name "*.$suf" -exec echo "  "{}" \\" >> make.pre \;
+       done
+       if [ $# -eq 2 ]
+       then
+               rm make.tmp || true
+               find . -name "*.$2" -exec echo {} >> make.tmp \;
+               while read line
+               do
+                       echo "  ${line/\.$2/\.$1}  \\" >> make.pre
+               done < make.tmp
+       fi
+}
+
 ##############################################################################
 # Main program
 ##############################################################################
@@ -148,23 +171,29 @@ extern_build=0
 
 while [ $OPTIND -le "$#" ]
 do
-       if getopts "a:bB:C:i:It:v:V" opt
+       if getopts "ha:bc:C:d:e:i:n:t:v:V" opt
        then
                case $opt in
+                       h)      echo_usage
+                               exit 0
+                               ;;
                        a) ARCH=$OPTARG
                                ;;
                        b) extern_build=1
                                ;;
-                       c) compile_dir=$OPTARG
+                       c) compile_type=$OPTARG
                                ;;
                        C) cross=$OPTARG
                                ;;
+                       d) compile_dir=$OPTARG
+                               ;;
+                       d) compile_target=$OPTARG
+                               ;;
                        i)      install_dir=$OPTARG
                                ;;
-                       I)      echo_usage
-                               exit 0
+                       n)      target_name=$OPTARG
                                ;;
-                       t) compile_type=$OPTARG
+                       t) target_type=$OPTARG
                                ;;
                        v)      optversion=$OPTARG
                                ;;
@@ -328,23 +357,30 @@ else
        fi
 
        # .build
-       if [ "$compile_type" != "CMAKE" -a "$compile_type" != "OLD" ]
+       if [ "$compile_type" != "CMAKE" -a "$compile_type" != "ANY" ]
        then
                cp debian/rules.pre $BUILD_DIR/$compile_dir/make.pre
                pushd $BUILD_DIR/$compile_dir >/dev/null
                        ln -sf /usr/share/mbuild/makefile .
-                       if [ -n "$sources_suffix" ]
-                       then
-                               echo "SOURCES = \\" >> make.pre
-                               for suf in $sources_suffix
-                               do
-                                       find . -name "*.$suf" -exec echo "  "{}" \\" >> make.pre \;
-                               done
-                               echo >> make.pre
+#                      if [ -n "$sources_suffix" ]
+#                      then
+#                              echo "SOURCES = \\" >> make.pre
+#                              for suf in $sources_suffix
+#                              do
+#                                      find . -name "*.$suf" -exec echo "  "{}" \\" >> make.pre \;
+#                              done
+#                              echo >> make.pre
                        fi
                popd >/dev/null
        fi
-               
+
+       if [ "$compile_type" == "PDF" ]
+       then
+               pushd $BUILD_DIR/$compile_dir >/dev/null
+                       echo "SOURCES = \\" >> make.pre
+                       add_sources tex xml
+                       echo >> make.pre
+               popd >/dev/null
        if [ -x debian/$paket.prebuild ]
        then
                pushd $BUILD_DIR >/dev/null
index de84bb8..22101bf 100644 (file)
@@ -37,3 +37,6 @@ clean:
        pdflatex $< && pdflatex $<
        cp $*.pdf ~/build
 
+%.tex : %.xml
+       mdoc-extract $< ${DOC_CLASS}
+
index 4f0410a..e091ca6 100755 (executable)
@@ -16,7 +16,7 @@ function create_conf {
                then
                        echo "compile_type=CPP" > debian/$paket.conf
                else
-                       echo "compile_type=OLD" > debian/$paket.conf
+                       echo "compile_type=ANY" > debian/$paket.conf
                fi
        else
                echo "compile_type=NONE" > debian/$paket.conf
@@ -99,19 +99,23 @@ then
                rm -rf ~/build
                mkdir ~/build
        fi
-       configure_args="$configure_args -b"
+       configure_args="$configure_args -d ~/build"
 fi
 
 # perform configure
 . debian/$paket.conf
-if [ -n "$compile_dir" ]
-then
-       configure_args="$configure_args -b $compile_dir"
-fi
-if [ -z "$compile_type" ]
+if [ "$compile_type" != "NONE" ]
 then
-       echo "compile_type required in $paket.conf"
-       exit 51
+       configure_args="$configure_args -b"
+       if [ -n "$compile_dir" ]
+       then
+               configure_args="$configure_args -d $compile_dir"
+       fi
+       if [ -z "$compile_type" ]
+       then
+               echo "compile_type required in $paket.conf"
+               exit 51
+       fi
 fi
 if [ "$target_type" == "FILE" ]
 then
@@ -177,14 +181,20 @@ then
 elif [ "$target_type" == "FILE" ]
 then
        echo "PACK=version" >> debian/rules.pre
-       if [ "$compile_type" != "OLD" ]
+       if [ "$compile_type" != "ANY" ]
        then
                if [ -z "$compile_target" ]
                then
                        echo "compile_target is needed for target_type FILE"
                        exit 12
                fi
-               echo "TARGET = $compile_target" >> debian/rules.pre
+               echo "COMPILE_TARGET = $compile_target" >> debian/rules.pre
+               if [ -n "$target_name" ]
+               then
+                       echo "TARGET = $target_name" >> debian/rules.pre
+               else
+                       echo "TARGET = $paket" >> debian/rules.pre
+               fi
        fi
 else
        echo "Unknown target type: $target_type"
index 7d0fa32..e54228c 100755 (executable)
@@ -58,6 +58,9 @@ version: $(BUILD_DIR)/$(TARGET)
        $(INSERT_BUILD) $(BUILD_DIR)/$(TARGET) $(build)
        cp $(BUILD_DIR)/*$(build)* ../
 
+$(BUILD_DIR)/$(TARGET): $(BUILD_DIR)/$(COMPILE_TARGET)
+       cp $(BUILD_DIR)/$(COMPILE_TARGET) $(BUILD_DIR)/$(TARGET)
+
 $(BUILD_DIR):
        mkdir $(BUILD_DIR)