added make install and uninstall targets

C linkage for state and generator mutation
lib
Avril 4 years ago
parent bc7186028e
commit 11cc8d666d
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -1,5 +1,10 @@
PROJECT=sm PROJECT=sm
AUTHOR=Avril (Flanchan) <flanchan@cumallover.me> AUTHOR=Avril (Flanchan) <flanchan@cumallover.me>
VERSION=1.0.0
ifeq ($(PREFIX),)
PREFIX := /usr/local
endif
SRC_C = $(wildcard src/*.c) SRC_C = $(wildcard src/*.c)
SRC_CXX = $(wildcard src/*.cpp) SRC_CXX = $(wildcard src/*.cpp)
@ -9,7 +14,9 @@ TEST_SRC_CXX = $(wildcard src/test/*.cpp)
INCLUDE=include INCLUDE=include
COMMON_FLAGS= -W -Wall -pedantic -fno-strict-aliasing $(addprefix -I,$(INCLUDE)) HEADERS=$(INCLUDE)/*.h
COMMON_FLAGS= -D_VERSION=$(VERSION) -W -Wall -pedantic -fno-strict-aliasing $(addprefix -I,$(INCLUDE))
OPT_FLAGS?= -march=native -fgraphite -fopenmp -floop-parallelize-all -ftree-parallelize-loops=4 \ OPT_FLAGS?= -march=native -fgraphite -fopenmp -floop-parallelize-all -ftree-parallelize-loops=4 \
-floop-interchange -ftree-loop-distribution -floop-strip-mine -floop-block \ -floop-interchange -ftree-loop-distribution -floop-strip-mine -floop-block \
@ -52,6 +59,9 @@ debug: | dirs lib$(PROJECT)-debug.so lib$(PROJECT)-debug.a
.PHONY: test .PHONY: test
test: | dirs $(PROJECT)-test test: | dirs $(PROJECT)-test
.PHONY: install
.PHONY: uninstall
# Targets # Targets
dirs: dirs:
@ -102,3 +112,15 @@ clean-rebuild:
clean: clean-rebuild clean: clean-rebuild
rm -f lib$(PROJECT){-debug,}.{so,a} rm -f lib$(PROJECT){-debug,}.{so,a}
rm -f $(PROJECT)-test rm -f $(PROJECT)-test
install: | dirs lib$(PROJECT).a lib$(PROJECT).so
install -d $(DESTDIR)$(PREFIX)/lib/
install -m 644 lib$(PROJECT).a $(DESTDIR)$(PREFIX)/lib/
install -m 755 lib$(PROJECT).so $(DESTDIR)$(PREFIX)/lib/
install -d $(DESTDIR)$(PREFIX)/include/$(PROJECT)/
install -m 644 $(HEADERS) $(DESTDIR)$(PREFIX)/include/$(PROJECT)/
uninstall:
rm $(DESTDIR)$(PREFIX)/lib/lib$(PROJECT).{a,so}
ls $(HEADERS) | xargs -I {} basename {} | xargs -I {} rm "$(DESTDIR)$(PREFIX)/include/$(PROJECT)/{}"
rmdir $(DESTDIR)$(PREFIX)/include/$(PROJECT)

@ -112,5 +112,7 @@ inline sm_yield sm_continue() { return (sm_yield)_sm_noop; }
// --- // ---
sm_state* sm_new_state(); extern "C" {
void sm_free_state(sm_state* state); sm_state* sm_new_state();
void sm_free_state(sm_state* state);
}

@ -3,11 +3,15 @@
#ifdef __cplusplus #ifdef __cplusplus
#define EX_C extern "C"
#include <cstdio> #include <cstdio>
#define restrict __restrict__ #define restrict __restrict__
[[noreturn]] [[noreturn]]
#else #else
#define EX_C
#include <stdio.h> #include <stdio.h>
__attribute__((noreturn)) __attribute__((noreturn))

@ -1,6 +1,5 @@
#include <gen.h> #include <gen.h>
#include "dev.h"
#define EX_C extern "C"
struct sm_generator struct sm_generator
{ {

@ -13,7 +13,7 @@ sm_yield _sm_noop(sm_state*)
return (sm_yield)nullptr; return (sm_yield)nullptr;
} }
sm_state* sm_new_state() EX_C sm_state* sm_new_state()
{ {
auto state = box<sm_state>(); auto state = box<sm_state>();
state->current = box<_sm_frame, true>(); state->current = box<_sm_frame, true>();
@ -54,7 +54,7 @@ inline static void _sm_free_all_pages(_sm_user_page* page)
} }
} }
void sm_free_state(sm_state* state) EX_C void sm_free_state(sm_state* state)
{ {
_sm_frame* frame = unbox(state).current; _sm_frame* frame = unbox(state).current;

Loading…
Cancel
Save