summaryrefslogtreecommitdiff
path: root/Makefile
blob: 0802007129b099fc655a9b3b5e1126784a239813 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

SRC_DIR = src
BUILD_DIR = build
OBJ_DIR = $(BUILD_DIR)/artifacts
INCLUDE_DIR = ./include

SRCS = $(notdir $(wildcard $(SRC_DIR)/*.c))
OBJS = $(addsuffix .o, $(basename $(SRCS)))

CFLAGS ?= -Werror -Wall

build: build_dir $(OBJS)
	$(CC) -shared -o $(BUILD_DIR)/libopensmarts.so $(addprefix $(OBJ_DIR)/, $(OBJS))

install: build
	install -m 755 ./build/libopensmarts.so /usr/lib/libopensmarts.so
	rm -rf /usr/include/osm
	mkdir -p /usr/include/osm
	cp -r ./include/osm /usr/include

remove:
	rm -rf /usr/include/osm
	rm -rf /usr/lib/libopensmarts.so

%.o: $(SRC_DIR)/%.c
	$(CC) $(CFLAGS) -c -fpic -I$(INCLUDE_DIR) -o $(BUILD_DIR)/artifacts/$@ $<

build_dir:
	mkdir -p $(BUILD_DIR)
	mkdir -p $(OBJ_DIR)