Commits

Shlomi Fish committed d1f7df9

Add more.

  • Participants
  • Parent commits e2f5543

Comments (0)

Files changed (2)

installer/CMakeLists.txt

 ENDIF(WIN32 AND NOT UNIX)
 
 SET(CPACK_PACKAGE_EXECUTABLES
-    "wml" "Website Meta Language Frontend"
+    "latemp-config" "Latemp configuration flags"
+    "latemp-setup" "Set up a latemp site"
 )
 
+FOREACH (name "latemp-config" "latemp-setup")
+    SET (source_script "${name}.pl")
+    SET (SRC_NAME "${CMAKE_CURRENT_SOURCE_DIR}/${source_script}")
+    SET (TARGET_NAME "${CMAKE_CURRENT_BINARY_DIR}/${name}")
+    ADD_CUSTOM_COMMAND(
+        OUTPUT "${TARGET_NAME}"
+        COMMAND "${PERL_EXECUTABLE}"
+        ARGS "${CMAKE_SOURCE_DIR}/cmake/preprocess-prefix-and-version.pl"
+            "--input" "${SRC_NAME}"
+            "--output" "${TARGET_NAME}"
+            "--version" "${VERSION}"
+            "--prefix" "${CMAKE_INSTALL_PREFIX}"
+            COMMAND chmod ARGS "a+x" "${TARGET_NAME}"
+        DEPENDS "${SRC_NAME}"
+    )
+    # The custom command needs to be assigned to a target.
+    ADD_CUSTOM_TARGET(
+        "${name}_preproc" ALL
+        DEPENDS "${TARGET_NAME}"
+    )
+ENDFOREACH (name)
+
 INCLUDE (CPack)

installer/cmake/preprocess-prefix-and-version.pl

+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Getopt::Long;
+
+my $prefix;
+my $version;
+
+my $input_fn;
+my $output_fn;
+
+GetOptions
+(
+    "input=s" => \$input_fn,
+    "output=s" => \$output_fn,
+    "prefix=s" => \$prefix,
+    "version=s" => \$version,
+);
+
+if (!defined($input_fn))
+{
+    die "Input filename not specified!";
+}
+
+if (!defined($output_fn))
+{
+    die "Output filename not specified!";
+}
+
+if (!defined($prefix))
+{
+    die "Prefix not specified!";
+}
+
+if (!defined($version))
+{
+    die "Version not specified!";
+}
+
+open my $in_fh, "<", $input_fn
+    or die "Could not open '$input_fn'";
+
+open my $out_fh, ">", $output_fn
+    or die "Could not open '$output_fn'";
+
+LINES:
+while (my $line = <$in_fh>)
+{
+    if ($line =~ /\A__END__/)
+    {
+        last LINES;
+    }
+    elsif ($line =~ /^=head1/)
+    {
+        DISCARD_POD:
+        while ($line = <$in_fh>)
+        {
+            if ($line =~ /^=cut/)
+            {
+                last DISCARD_POD;
+            }
+        }
+    }
+    else
+    {
+        $line =~ s{<<<PREFIX>>>}[$prefix]eg;
+        $line =~ s{<<<VERSION>>>}[$version]eg;
+        print {$out_fh} $line;
+    }
+}
+close($in_fh);
+close($out_fh);
+
+chmod(0755, $output_fn);
+
+exit(0);