Commits

shl...@7081e830-ea04-0410-ae62-fb6148e2d9db  committed cdc147f

Made more progress in the install.

  • Participants
  • Parent commits 42a83c5
  • Branches conversion-to-cmake

Comments (0)

Files changed (9)

File src/Common.cmake

     INSTALL_RENAME_MAN ("${BASENAME}.1" 1 "wml_aux_${BASENAME}")
 ENDMACRO(DEFINE_WML_AUX_C_PROG BASENAME)
 
+MACRO(DEFINE_WML_PERL_BACKEND BASENAME DEST_BASENAME)
+    PREPROCESS_PATH_PERL(
+        "${BASENAME}_preproc" "${BASENAME}.src" "${BASENAME}.pl"
+    )    
+    INST_POD2MAN("${BASENAME}_pod" "${BASENAME}.src" "${BASENAME}" "1")
+    INSTALL(
+        PROGRAMS "${BASENAME}.pl"
+        DESTINATION "${WML_LIBEXE_DIR}"
+        RENAME "${DEST_BASENAME}"
+    )    
+ENDMACRO(DEFINE_WML_PERL_BACKEND)

File src/wml_backend/p1_ipp/CMakeLists.txt

-PREPROCESS_PATH_PERL("ipp_preproc" "ipp.src" "ipp.pl")
-INST_POD2MAN("ipp_pod" "ipp.src" "ipp" "1")
-INSTALL(
-    PROGRAMS "ipp.pl"
-    DESTINATION "${WML_LIBEXE_DIR}"
-    RENAME "wml_p1_ipp"
-)
+DEFINE_WML_PERL_BACKEND("ipp" "wml_p1_ipp")

File src/wml_backend/p5_divert/CMakeLists.txt

-PREPROCESS_PATH_PERL("divert_preproc" "divert.src" "divert.pl")
-INST_POD2MAN("divert_pod" "divert.src" "divert" "1")
-INSTALL(
-    PROGRAMS "divert.pl"
-    DESTINATION "${WML_LIBEXE_DIR}"
-    RENAME "wml_p5_divert"
-)
+DEFINE_WML_PERL_BACKEND("divert" "wml_p5_divert")

File src/wml_backend/p6_asubst/CMakeLists.txt

-PREPROCESS_PATH_PERL("asubst_preproc" "asubst.src" "asubst.pl")
-INST_POD2MAN("asubst_pod" "asubst.src" "asubst" "1")
-INSTALL(
-    PROGRAMS "asubst.pl"
-    DESTINATION "${WML_LIBEXE_DIR}"
-    RENAME "wml_p6_asubst"
-)
+DEFINE_WML_PERL_BACKEND("asubst" "wml_p6_asubst")

File src/wml_backend/p7_htmlfix/CMakeLists.txt

-PREPROCESS_PATH_PERL("htmlfix_preproc" "htmlfix.src" "htmlfix.pl")
-INST_POD2MAN("htmlfix_pod" "htmlfix.src" "htmlfix" "1")
-INSTALL(
-    PROGRAMS "htmlfix.pl"
-    DESTINATION "${WML_LIBEXE_DIR}"
-    RENAME "wml_p7_htmlfix"
-)
+DEFINE_WML_PERL_BACKEND("htmlfix" "wml_p7_htmlfix")

File src/wml_backend/p8_htmlstrip/CMakeLists.txt

-PREPROCESS_PATH_PERL("htmlstrip_preproc" "htmlstrip.src" "htmlstrip.pl")
-INST_POD2MAN("htmlstrip_pod" "htmlstrip.src" "htmlstrip" "1")
-INSTALL(
-    PROGRAMS "htmlstrip.pl"
-    DESTINATION "${WML_LIBEXE_DIR}"
-    RENAME "wml_p8_htmlstrip"
-)
+DEFINE_WML_PERL_BACKEND("htmlstrip" "wml_p8_htmlstrip")

File src/wml_backend/p9_slice/CMakeLists.txt

-PREPROCESS_PATH_PERL("slice_preproc" "slice_main.pl" "slice")
-INST_POD2MAN("slice_pod" "slice.pod" "slice" "1")
+SET(BASENAME "slice")
+SET(src "${CMAKE_CURRENT_SOURCE_DIR}/${BASENAME}_main.pl")
+SET(dest "${CMAKE_CURRENT_BINARY_DIR}/${BASENAME}.pl")
+ADD_CUSTOM_COMMAND(
+    OUTPUT "${dest}"
+    COMMAND "${PERL_EXECUTABLE}"
+    ARGS "${CMAKE_CURRENT_SOURCE_DIR}/etc/expand.pl"
+         "${src}"
+         "${dest}"
+    WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+    DEPENDS "${src}"
+)
+ADD_CUSTOM_TARGET(
+    "${BASENAME}_preproc" ALL
+    DEPENDS "${dest}"
+)
+INST_POD2MAN("${BASENAME}_pod" "${dest}" "${BASENAME}" "1")
 INSTALL(
-    PROGRAMS "slice"
+    PROGRAMS "${dest}"
     DESTINATION "${WML_LIBEXE_DIR}"
-    RENAME "wml_p9_slice"
+    RENAME "wml_p9_${BASENAME}"
 )

File src/wml_backend/p9_slice/etc/expand.in

-#!@PATH_PERL@
-##
-##  expand -- recursive filter to substitute each Perl
-##            'require' command with the contents of the file
-##
-##  Copyright (c) 1995 Ralf S. Engelschall, <rse@engelschall.com>
-##
-##  Usage: unrequire file.pl >file
-##
-
-sub ProcessFile {
-    local ($file) = @_[0];
-
-    open($file, "<$file");
-    while(<$file>) {
-        #   include a file
-        if (m|^(.*)require[ \"\(]+([^ \"\(]+)[ \"\)]+;(.*)$|) {
-            print $1;
-            &ProcessFile($2);
-            print $3;
-            break;
-        }
-        #   remove a require result code
-        if (m|^1;$|) {
-            next;
-        }
-        print;
-    }
-    close($file);
-}
-
-&ProcessFile($ARGV[0]);
-
-##EOF##

File src/wml_backend/p9_slice/etc/expand.pl

+##
+##  expand -- recursive filter to substitute each Perl
+##            'require' command with the contents of the file
+##
+##  Copyright (c) 1995 Ralf S. Engelschall, <rse@engelschall.com>
+##
+##  Usage: perl unrequire file.pl new_file
+##
+
+use strict;
+use warnings;
+
+my ($input_fn, $output_fn) = @ARGV;
+
+open my $out_fh, ">", $output_fn
+    or die "Could not open '$output_fn' for writing";
+
+ProcessFile($input_fn);
+
+close($out_fh);
+
+sub ProcessFile {
+    my ($filename) = @_;
+
+    open(my $fh, "<", $filename)
+        or die "Could not open filename.";
+
+    while(my $l = <$fh>) {
+        #   include a file
+        if (my ($pre, $new_fn, $suf) = 
+            $l =~ m|^(.*)require[ \"\(]+([^ \"\(]+)[ \"\)]+;(.*)$|) {
+            print {$out_fh} $pre;
+            ProcessFile($new_fn);
+            print {$out_fh} $suf;
+        }
+        #   remove a require result code
+        if ($l =~ m|^1;$|) {
+            next;
+        }
+        print {$out_fh} $l;
+    }
+    close($fh);
+}
+
+
+##EOF##