diff options
| -rw-r--r-- | .gitignore | 3 | ||||
| -rw-r--r-- | Makefile | 62 | ||||
| -rw-r--r-- | aisa/aisa.cpp | 12 | ||||
| -rw-r--r-- | aisa/aisa.h | 7 | ||||
| -rwxr-xr-x | get-git-tag | 15 | ||||
| -rw-r--r-- | git-tag.h | 5 | ||||
| -rw-r--r-- | main.cpp | 11 |
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 @@ | |||
| 1 | OPTIMIZE ?= -O3 | ||
| 2 | DEBUG ?= -g | ||
| 3 | |||
| 4 | AR ?= ar | ||
| 5 | CXX ?= g++ | ||
| 6 | |||
| 7 | CXXFLAGS := -Wall -Werror -std=c++20 -fPIC -iquote . ${OPTIMIZE} ${DEBUG} | ||
| 8 | |||
| 9 | PARTS := $(shell find * -type d -\( -name build -prune -o -print -\)) | ||
| 10 | PARTARS := $(addprefix build/lib, $(addsuffix .a, ${PARTS})) | ||
| 11 | PARTSOS := $(addprefix build/lib, $(addsuffix .so, ${PARTS})) | ||
| 12 | |||
| 13 | MAINOBJS := $(addprefix build/, $(addsuffix .o, $(basename $(wildcard *.cpp)))) | ||
| 14 | MAINOBJS += build/git-tag.o | ||
| 15 | |||
| 16 | all: issim | ||
| 17 | |||
| 18 | issim: build/issim-dynamic | ||
| 19 | @ln -sf $< $@ | ||
| 20 | .PHONY: issim | ||
| 21 | |||
| 22 | issim-static: build/issim-static | ||
| 23 | @ln -sf $< $@ | ||
| 24 | .PHONY: issim-static | ||
| 25 | |||
| 26 | build/issim-dynamic: ${MAINOBJS} ${PARTSOS} | ||
| 27 | @mkdir -p $(dir $@) | ||
| 28 | ${CXX} ${CXXFLAGS} -o $@ $+ | ||
| 29 | |||
| 30 | build/issim-static: ${MAINOBJS} ${PARTARS} | ||
| 31 | @mkdir -p $(dir $@) | ||
| 32 | ${CXX} ${CXXFLAGS} -o $@ $+ | ||
| 33 | |||
| 34 | clean: | ||
| 35 | rm -rf build issim issim-static | ||
| 36 | .PHONY: clean | ||
| 37 | |||
| 38 | build/git-tag.cpp: | ||
| 39 | @mkdir -p $(dir $@) | ||
| 40 | ./get-git-tag > $@ | ||
| 41 | .PHONY: build/git-tag.cpp | ||
| 42 | |||
| 43 | build/%.o: %.cpp Makefile | ||
| 44 | @mkdir -p $(dir $@) | ||
| 45 | ${CXX} ${CXXFLAGS} -c -o $@ $< | ||
| 46 | |||
| 47 | build/%.o: build/%.cpp Makefile | ||
| 48 | @mkdir -p $(dir $@) | ||
| 49 | ${CXX} ${CXXFLAGS} -c -o $@ $< | ||
| 50 | |||
| 51 | .SUFFIXES: | ||
| 52 | .SECONDARY: | ||
| 53 | |||
| 54 | .SECONDEXPANSION: | ||
| 55 | |||
| 56 | build/lib%.a: $$(addprefix build/, $$(addsuffix .o, $$(basename $$(wildcard %/*.cpp)))) | ||
| 57 | @mkdir -p $(dir $@) | ||
| 58 | ${AR} cr $@ $+ | ||
| 59 | |||
| 60 | build/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 | |||
| 5 | namespace 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 | |||
| 3 | namespace 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 | |||
| 3 | set -u | ||
| 4 | |||
| 5 | TAG="$(git describe --always --tags --long --dirty 2> /dev/null)" | ||
| 6 | |||
| 7 | if [[ "$TAG" == "" ]]; then | ||
| 8 | TAG="unknown" | ||
| 9 | fi | ||
| 10 | |||
| 11 | cat <<END | ||
| 12 | #include <string> | ||
| 13 | |||
| 14 | std::string GIT_TAG = "$TAG"; | ||
| 15 | END | ||
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 | |||
| 5 | extern 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 | |||
| 6 | int main(int argc, const char *argv[]) | ||
| 7 | { | ||
| 8 | std::cout << "Version " << GIT_TAG << "\n"; | ||
| 9 | aisa::do_something(); | ||
| 10 | return 0; | ||
| 11 | } | ||
