-
Notifications
You must be signed in to change notification settings - Fork 9
/
buildconf.mk
79 lines (68 loc) · 2.39 KB
/
buildconf.mk
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# build environment
ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
BUILD ?= $(ROOT_DIR)/build
VERSION ?= 0.2
OS ?= LINUX
BUILD_BINDIR := $(BUILD)/bin
BUILD_SBINDIR := $(BUILD)/sbin
BUILD_LIBDIR := $(BUILD)/lib
BUILD_USRBIN := $(BUILD)/usr/bin
BUILD_USRLIB := $(BUILD)/usr/lib
BUILD_USRSHARE := $(BUILD)/usr/share
BUILD_PKGCONFIG := $(BUILD)/usr/lib/pkgconfig
BUILD_USRSBIN := $(BUILD)/usr/sbin
BUILD_INCLUDEDIR := $(BUILD)/usr/include/
BUILD_PRIVATE_INCLUDEDIR := $(BUILD)/fskit_private
BUILD_ETCDIR := $(BUILD)/etc
# install environment
DESTDIR ?=
PREFIX ?= /usr/local
INCLUDE_PREFIX ?= $(PREFIX)
BINDIR ?= $(DESTDIR)$(PREFIX)/bin
SBINDIR ?= $(DESTDIR)$(PREFIX)/sbin
LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
INCLUDEDIR ?= $(DESTDIR)$(INCLUDE_PREFIX)/include
PKGCONFIGDIR ?= $(DESTDIR)$(PREFIX)/lib/pkgconfig
ETCDIR ?= $(DESTDIR)$(PREFIX)/etc
# libfskit
BUILD_LIBFSKIT := $(BUILD_USRLIB)
BUILD_LIBFSKIT_HEADERS := $(BUILD_INCLUDEDIR)/fskit
BUILD_LIBFSKIT_DIRS := $(BUILD_LIBFSKIT) $(BUILD_LIBFSKIT_HEADERS)
INSTALL_LIBFSKIT := $(LIBDIR)
INSTALL_LIBFSKIT_HEADERS := $(INCLUDEDIR)/fskit
LIBFSKIT_MAJOR := 1
LIBFSKIT_MINOR := 0
LIBFSKIT_PATCH := 2
# libfskit_fuse
BUILD_LIBFSKIT_FUSE := $(BUILD_USRLIB)
BUILD_LIBFSKIT_FUSE_HEADERS := $(BUILD_INCLUDEDIR)/fskit/fuse
BUILD_LIBFSKIT_FUSE_DIRS := $(BUILD_LIBFSKIT_FUSE) $(BUILD_LIBFSKIT_FUSE_HEADERS)
INSTALL_LIBFSKIT_FUSE := $(LIBDIR)
INSTALL_LIBFSKIT_FUSE_HEADERS := $(INCLUDEDIR)/fskit/fuse
LIBFSKIT_FUSE_MAJOR := 1
LIBFSKIT_FUSE_MINOR := 0
LIBFSKIT_FUSE_PATCH := 2
# special defs
REPL ?= 1
REPL_DEF := 1
ifeq ($(REPL),1)
REPL_DEF := -D_FSKIT_REPL
endif
# compiler
CCFLAGS := -Wall -std=c11 -g -fPIC -fstack-protector -fstack-protector-all -pthread -Wno-unused-variable -Wno-unused-but-set-variable
CXXFLAGS := -Wall -g -fPIC -fstack-protector -fstack-protector-all -pthread -Wno-unused-variable -Wno-unused-but-set-variable
INC := -I. -I$(ROOT_DIR) -I$(BUILD_INCLUDEDIR) -I$(BUILD)
DEFS := -D_THREAD_SAFE -D__STDC_FORMAT_MACROS $(REPL_DEF)
LIBINC := -L. -L$(BUILD_USRLIB)
CC ?= cc
CXX ?= c++
# build setup
BUILD_DIRS := $(sort $(BUILD_LIBFSKIT_DIRS) $(BUILD_LIBFSKIT_FUSE_DIRS) $(BUILD_PRIVATE_INCLUDEDIR))
all:
build_setup: $(BUILD_DIRS)
$(BUILD_DIRS):
@mkdir -p "$@"
# rule to make an archive member from an object file
(%.o): %.o ; $(AR) cr $@ $*.o
# debugging...
print-%: ; @echo $*=$($*)