summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2015-04-05 22:26:57 +0600
committerDaniil Baturin <daniil@baturin.org>2015-04-05 22:26:57 +0600
commit7ffcf4d622e4f9608574033c328cba1f7f7c9ca5 (patch)
treefe5b69775b33bc94be796ee1345653a080ea3812
parentdf3476d7b8b2653cf09abd6c4d310ab8d6598097 (diff)
downloadhvinfo-7ffcf4d622e4f9608574033c328cba1f7f7c9ca5.tar.gz
hvinfo-7ffcf4d622e4f9608574033c328cba1f7f7c9ca5.zip
Build scripts revamp.
-rw-r--r--.gitignore3
-rw-r--r--Makefile24
-rw-r--r--README.md9
-rw-r--r--VERSION1
-rwxr-xr-xmkconfig.sh24
-rw-r--r--src/config.ads.in8
-rw-r--r--src/hvinfo_util.adb2
-rw-r--r--src/hvinfo_util.ads2
8 files changed, 61 insertions, 12 deletions
diff --git a/.gitignore b/.gitignore
index b4d7039..f3a4f1e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,6 @@
# Ada Library Information
*.ali
+
+# Generated files
+src/config.ads
diff --git a/Makefile b/Makefile
index 968bd76..901ea1c 100644
--- a/Makefile
+++ b/Makefile
@@ -1,14 +1,24 @@
PREFIX = /usr
-BINDIR = bin/
+BINDIR = bin
-all: hvinfo
+TARGET_DIR = $(PREFIX)/$(BINDIR)
-hvinfo:
- gnatmake src/hvinfo.adb
+GPRBUILD = gprbuild
+GPRCLEAN = gprclean
+GPRINSTALL = gprinstall
+GNATPREP = gnatprep
+
+INSTALL = install
+
+all: src/hvinfo
+
+src/hvinfo:
+ ./mkconfig.sh
+ $(GPRBUILD) -Phvinfo
clean:
- gnatclean hvinfo hypervisor_check
+ $(GPRCLEAN)
install:
- mkdir -p $(PREFIX)/$(BINDIR)
- cp hvinfo $(PREFIX)/$(BINDIR)
+ $(INSTALL) -d $(TARGET_DIR)
+ $(INSTALL) src/hvinfo $(TARGET_DIR)
diff --git a/README.md b/README.md
index d55d7df..5603bcf 100644
--- a/README.md
+++ b/README.md
@@ -2,12 +2,13 @@
Yet another hypervisor detection tool, this time in a high level language and
doesn't want root privileges.
-To build it, you need GNAT 4.x or higher (Ada 2005 support required).
-Just use "make" in the top level dir.
-Alternatively, you can use gnatmake directly, from the top level dir do
+To build it, you need GNAT 4.x or higher (Ada 2005 support required) and gprbuild.
+Build setup is rather simplistic at this time.
```
-gnatmake ./src/hvinfo
+cd hvinfo
+make
+make install PREFIX=<some dir>
```
There is no proper build system yet, so if you are building on FreeBSD,
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..49d5957
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+0.1
diff --git a/mkconfig.sh b/mkconfig.sh
new file mode 100755
index 0000000..1abfa94
--- /dev/null
+++ b/mkconfig.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+HVINFO_LINUX=False
+HVINFO_FREEBSD=False
+
+VERSION=$(cat VERSION)
+
+OS=$(uname)
+case $OS in
+ Linux)
+ HVINFO_LINUX=True
+ ;;
+ FreeBSD)
+ HVINFO_FREEBSD=True
+ ;;
+ *)
+ echo "Operating system $OS is not supported"
+ exit 1
+esac
+
+gnatprep -D LINUX=$HVINFO_LINUX \
+ -D FREEBSD=$HVINFO_FREEBSD \
+ -D VERSION=\"$VERSION\" \
+ src/config.ads.in src/config.ads
diff --git a/src/config.ads.in b/src/config.ads.in
new file mode 100644
index 0000000..386ad60
--- /dev/null
+++ b/src/config.ads.in
@@ -0,0 +1,8 @@
+package Config is
+
+ Linux : constant Boolean := $LINUX;
+ FreeBSD : constant Boolean := $FREEBSD;
+
+ Version : constant String := $VERSION;
+
+end Config;
diff --git a/src/hvinfo_util.adb b/src/hvinfo_util.adb
index daad56d..d4e3f20 100644
--- a/src/hvinfo_util.adb
+++ b/src/hvinfo_util.adb
@@ -11,7 +11,7 @@ package body HVInfo_Util is
procedure Print_Version is
begin
- IO.Put_Line ("hvinfo 0.1");
+ IO.Put_Line ("hvinfo " & Config.Version);
IO.Put_Line ("Copyright 2015 Daniil Baturin <daniil@baturin.org>");
IO.Put_Line ("");
IO.Put_Line ("This program is free software, distributed under the terms");
diff --git a/src/hvinfo_util.ads b/src/hvinfo_util.ads
index d45667e..b2530e9 100644
--- a/src/hvinfo_util.ads
+++ b/src/hvinfo_util.ads
@@ -1,6 +1,8 @@
with Ada.Command_line;
with Ada.Text_IO;
+with Config;
+
package HVInfo_Util is
package IO renames Ada.Text_IO;