From ab6e4f29feb27878799d44d28c71f8ccfd7a861a Mon Sep 17 00:00:00 2001
From: Kubat <mael.martin31@gmail.com>
Date: Mon, 20 Apr 2020 19:20:28 +0200
Subject: [PATCH] Install rules in meson.build

---
 README.md                    |  7 +++----
 meson.build                  | 19 +++++++++++++------
 init.sql => scripts/init.sql |  0
 scripts/install.sh           | 15 +++++++++++++++
 4 files changed, 31 insertions(+), 10 deletions(-)
 rename init.sql => scripts/init.sql (100%)
 create mode 100755 scripts/install.sh

diff --git a/README.md b/README.md
index 4d2f4de5..a49bf413 100644
--- a/README.md
+++ b/README.md
@@ -32,10 +32,9 @@ The manual way of installing and setting up lektor:
 ```sh
 meson build
 ninja -C build
-./build/lktadm --init                   # Modify mkv, if the metadata ar already set do not do this.
-# Create and modify the ini file manually, must be at ~/.config/lektor/config at the moment.
-sqlite3 /home/kara/kara.db < init.sql   # Create the database.
-./build/lktadm --populate-all           # Populate the sqlite database.
+./build/lktadm init database            # Create the database
+./build/lktadm init metadata            # Modify mkv, if the metadata ar already set do not do this
+./build/lktadm init populate            # Papulate the database with karas on the filesystem
 ```
 
 You may need to put the `lib_window_x11.so` in the right directory to have the
diff --git a/meson.build b/meson.build
index 11840510..cd546e9d 100644
--- a/meson.build
+++ b/meson.build
@@ -13,16 +13,11 @@ project( 'lektor'
                           ]
        )
 
-add_project_arguments('-march=native', language : 'c')
-
-cc      = meson.get_compiler('c')
-libdl   = cc.find_library('dl')
+libdl   = meson.get_compiler('c').find_library('dl')
 dep_x11 = dependency('x11', required : false)
 dep_mpv = dependency('mpv', required : false)
 dep_sdl = dependency('sdl2', required : false)
 
-# Sources
-
 ## Sources for the server
 core_sources =  [ 'src/mkv/bufferfd.c'
                 , 'src/mkv/write.c'
@@ -70,6 +65,7 @@ srv = executable( meson.project_name() + 'd'
                 , files('src/main/server.c')
                 , include_directories : includes
                 , dependencies : [ bin_deps ]
+                , install : true
                 )
 
 # Admin executable
@@ -77,12 +73,14 @@ metadata = executable( 'lktadm'
                      , files('src/main/lktadm.c', 'src/cmd.c')
                      , include_directories : includes
                      , dependencies : bin_deps
+                     , install : true
                      )
 
 # Client executable
 lkt = executable( 'lkt'
                 , files('src/main/lkt.c', 'src/cmd.c')
                 , include_directories : includes
+                , install : true
                 )
 
 # X11 window module
@@ -92,6 +90,8 @@ if dep_x11.found() and dep_mpv.found()
                                , include_directories : includes
                                , dependencies : [ dep_x11, dep_mpv ]
                                , link_with : lib
+                               , install : true
+                               , install_dir : 'lib/lektor'
                                )
 endif
 
@@ -102,5 +102,12 @@ if dep_sdl.found() and dep_mpv.found()
                                , include_directories : includes
                                , dependencies : [ dep_sdl, dep_mpv ]
                                , link_with : lib
+                               , install : true
+                               , install_dir : 'lib/lektor'
                                )
 endif
+
+# Install
+install_data('scripts/init.sql', install_dir : 'share/lektor')
+install_man('doc/lektord.1')
+meson.add_install_script('scripts/install.sh')
diff --git a/init.sql b/scripts/init.sql
similarity index 100%
rename from init.sql
rename to scripts/init.sql
diff --git a/scripts/install.sh b/scripts/install.sh
new file mode 100755
index 00000000..6efd7597
--- /dev/null
+++ b/scripts/install.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Usefull things
+alias die='exit 1'
+
+# Verify lktadm
+LKTADM=$MESON_INSTALL_PREFIX/bin/lktadm
+type $LKTADM
+[ $? -ne 0 ] && echo "$LKTADM not found" && exit 1
+
+# Install files
+$LKTADM conf > $MESON_INSTALL_PREFIX/etc/lektor.ini || die
+mkdir /home/kara                                    || echo '/home/kara already exists'
+echo -ne "Enter the name of the user that will launch lektor: "
+$LKTADM init database                               || die
-- 
GitLab