summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--.gitignore3
-rw-r--r--Makefile62
-rw-r--r--aisa/aisa.cpp12
-rw-r--r--aisa/aisa.h7
-rwxr-xr-xget-git-tag15
-rw-r--r--git-tag.h5
-rw-r--r--main.cpp11
7 files changed, 115 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..02eb89a
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
1/build
2/issim
3/issim-static
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..6d3a4ab
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,62 @@
1OPTIMIZE ?= -O3
2DEBUG ?= -g
3
4AR ?= ar
5CXX ?= g++
6
7CXXFLAGS := -Wall -Werror -std=c++20 -fPIC -iquote . ${OPTIMIZE} ${DEBUG}
8
9PARTS := $(shell find * -type d -\( -name build -prune -o -print -\))
10PARTARS := $(addprefix build/lib, $(addsuffix .a, ${PARTS}))
11PARTSOS := $(addprefix build/lib, $(addsuffix .so, ${PARTS}))
12
13MAINOBJS := $(addprefix build/, $(addsuffix .o, $(basename $(wildcard *.cpp))))
14MAINOBJS += build/git-tag.o
15
16all: issim
17
18issim: build/issim-dynamic
19 @ln -sf $< $@
20.PHONY: issim
21
22issim-static: build/issim-static
23 @ln -sf $< $@
24.PHONY: issim-static
25
26build/issim-dynamic: ${MAINOBJS} ${PARTSOS}
27 @mkdir -p $(dir $@)
28 ${CXX} ${CXXFLAGS} -o $@ $+
29
30build/issim-static: ${MAINOBJS} ${PARTARS}
31 @mkdir -p $(dir $@)
32 ${CXX} ${CXXFLAGS} -o $@ $+
33
34clean:
35 rm -rf build issim issim-static
36.PHONY: clean
37
38build/git-tag.cpp:
39 @mkdir -p $(dir $@)
40 ./get-git-tag > $@
41.PHONY: build/git-tag.cpp
42
43build/%.o: %.cpp Makefile
44 @mkdir -p $(dir $@)
45 ${CXX} ${CXXFLAGS} -c -o $@ $<
46
47build/%.o: build/%.cpp Makefile
48 @mkdir -p $(dir $@)
49 ${CXX} ${CXXFLAGS} -c -o $@ $<
50
51.SUFFIXES:
52.SECONDARY:
53
54.SECONDEXPANSION:
55
56build/lib%.a: $$(addprefix build/, $$(addsuffix .o, $$(basename $$(wildcard %/*.cpp))))
57 @mkdir -p $(dir $@)
58 ${AR} cr $@ $+
59
60build/lib%.so: $$(addprefix build/, $$(addsuffix .o, $$(basename $$(wildcard %/*.cpp))))
61 @mkdir -p $(dir $@)
62 ${CXX} ${CXXFLAGS} -shared -o $@ $+
diff --git a/aisa/aisa.cpp b/aisa/aisa.cpp
new file mode 100644
index 0000000..0c806de
--- /dev/null
+++ b/aisa/aisa.cpp
@@ -0,0 +1,12 @@
1#include <iostream>
2
3#include "aisa/aisa.h"
4
5namespace aisa {
6
7 void do_something()
8 {
9 std::cout << "Hello, world!\n";
10 }
11
12}
diff --git a/aisa/aisa.h b/aisa/aisa.h
new file mode 100644
index 0000000..b570d6b
--- /dev/null
+++ b/aisa/aisa.h
@@ -0,0 +1,7 @@
1#pragma once
2
3namespace aisa {
4
5 void do_something();
6
7}
diff --git a/get-git-tag b/get-git-tag
new file mode 100755
index 0000000..cb4e2fa
--- /dev/null
+++ b/get-git-tag
@@ -0,0 +1,15 @@
1#!/bin/bash
2
3set -u
4
5TAG="$(git describe --always --tags --long --dirty 2> /dev/null)"
6
7if [[ "$TAG" == "" ]]; then
8 TAG="unknown"
9fi
10
11cat <<END
12#include <string>
13
14std::string GIT_TAG = "$TAG";
15END
diff --git a/git-tag.h b/git-tag.h
new file mode 100644
index 0000000..280f0c7
--- /dev/null
+++ b/git-tag.h
@@ -0,0 +1,5 @@
1#pragma once
2
3#include <string>
4
5extern const std::string GIT_TAG;
diff --git a/main.cpp b/main.cpp
new file mode 100644
index 0000000..6b7b0f4
--- /dev/null
+++ b/main.cpp
@@ -0,0 +1,11 @@
1#include <iostream>
2
3#include "aisa/aisa.h"
4#include "git-tag.h"
5
6int main(int argc, const char *argv[])
7{
8 std::cout << "Version " << GIT_TAG << "\n";
9 aisa::do_something();
10 return 0;
11}