-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
46 lines (36 loc) · 1.2 KB
/
Makefile
File metadata and controls
46 lines (36 loc) · 1.2 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
################################################################################
# libunix++: C++ wrapper for Linux system calls
# Build rules
#
# © 2019—2023, Sauron
################################################################################
NAME=unix++
CC=$(if $(TOOLCHAIN), /usr/bin/$(TOOLCHAIN)-)gcc
CXX=$(if $(TOOLCHAIN), /usr/bin/$(TOOLCHAIN)-)g++
INCLUDEDIR=$(if $(TOOLCHAIN), /usr/$(TOOLCHAIN)/libc/usr/include, /usr/include)
CFLAGS=-fPIC -Os -Wall -Wextra -Wno-unused-parameter
CXXFLAGS=$(CFLAGS)
LIBRARIES=-lrt -lstdc++
SOURCES=*.cpp
HEADERS=*.hpp
OUTPUT=lib$(NAME).so
PLATFORM?=STD
all: $(OUTPUT)
compat.o: compat.c
$(CC) -c $(CFLAGS) -DPLATFORM_$(PLATFORM) -o $@ compat.c
$(OUTPUT): $(SOURCES) $(HEADERS) compat.o
$(CXX) -shared $(CXXFLAGS) -DPLATFORM_$(PLATFORM) -o $@ $(SOURCES) compat.o $(LIBRARIES)
unittest: $(SOURCES) $(HEADERS) ut/*.cpp ut/*.hpp
$(CXX) -g $(CXXFLAGS) -DPLATFORM_$(PLATFORM) -o $@ $(SOURCES) ut/*.cpp $(LIBRARIES)
clean:
rm -f *.o *.so unittest
release: all
strip $(OUTPUT)
install: all
install -s $(OUTPUT) /usr/local/lib64
mkdir -p $(INCLUDEDIR)/$(NAME)
cp $(HEADERS) $(INCLUDEDIR)/$(NAME)
test: unittest
./unittest
.PHONY:
all release install clean test