buildconf.mk 3.34 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
# build environment
ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
BUILD    ?= $(ROOT_DIR)/build
OS ?= LINUX
BUILD_BINDIR := $(BUILD)/bin
BUILD_SBINDIR := $(BUILD)/sbin
BUILD_LIBDIR := $(BUILD)/lib
BUILD_USRBIN := $(BUILD)/usr/bin
BUILD_USRSHARE := $(BUILD)/usr/share
BUILD_USRSBIN := $(BUILD)/usr/sbin
11
BUILD_INCLUDEDIR := $(BUILD)/include
12
BUILD_ETCDIR := $(BUILD)/etc
Jude Nelson's avatar
Jude Nelson committed
13
BUILD_PKGCONFIG := $(BUILD)/usr/share/pkgconfig
14
BUILD_MAN8DIR = $(BUILD)/usr/share/man/man8
15 16

# install environment
17 18
ifeq ($(shell arch),i686)
ARCH ?= i386
19 20
else ifeq ($(shell arch),amd64)
ARCH ?= x86_64
21 22 23
else
ARCH ?= $(shell arch)
endif
Ralph Ronnquist's avatar
Ralph Ronnquist committed
24
PREFIX         ?= 
25
INCLUDE_PREFIX ?= $(PREFIX)/usr
fbt's avatar
fbt committed
26 27 28 29 30
BINDIR         ?= $(PREFIX)/bin
SBINDIR        ?= $(PREFIX)/sbin
LIBDIR         ?= $(PREFIX)/lib
INCLUDEDIR     ?= $(INCLUDE_PREFIX)/include
ETCDIR         ?= $(PREFIX)/etc
31
ETCDIR_VDEV    ?= $(ETCDIR)/vdev
32 33
SHAREDIR       ?= $(INCLUDE_PREFIX)/share
PKGCONFIG      ?= $(INCLUDE_PREFIX)/share/pkgconfig
34
RUNDIR         ?= $(PREFIX)/run
fbt's avatar
fbt committed
35
RUNDIR_VDEV    ?= $(RUNDIR)/vdev
36 37
LOGDIR         ?= $(PREFIX)/var/log
LOGDIR_VDEV    ?= $(LOGDIR)/vdev
38
MAN8DIR	       ?= $(SHAREDIR)/man/man8
39

Jude Nelson's avatar
Jude Nelson committed
40
# libvdev (NOTE: not an installable target; just common code)
41
LIBVDEV_ROOT := $(ROOT_DIR)/libvdev 
42
BUILD_LIBVDEV := $(BUILD_LIBDIR)
43
BUILD_LIBVDEV_HEADERS := $(BUILD_INCLUDEDIR)
44 45
BUILD_LIBVDEV_DIRS := $(BUILD_LIBVDEV) $(BUILD_LIBVDEV_HEADERS)

46 47
# libudev-compat 
BUILD_LIBUDEV_COMPAT := $(BUILD)/libudev-compat
48
BUILD_LIBUDEV_COMPAT_HEADERS := $(BUILD_INCLUDEDIR)
49
BUILD_LIBUDEV_COMPAT_DIRS := $(BUILD_LIBUDEV_COMPAT) $(BUILD_LIBUDEV_COMPAT_HEADERS)
50
INSTALL_LIBUDEV_COMPAT := $(DESTDIR)$(LIBDIR)/$(ARCH)-linux-gnu
fbt's avatar
fbt committed
51
INSTALL_LIBUDEV_COMPAT_HEADERS := $(DESTDIR)$(INCLUDEDIR)
Jude Nelson's avatar
Jude Nelson committed
52
LIBUDEV_VERSION := 219
53

54 55 56
# vdevd 
BUILD_VDEVD := $(BUILD_SBINDIR)
BUILD_VDEVD_HELPERS := $(BUILD_LIBDIR)/vdev
57
BUILD_VDEVD_DIRS := $(BUILD_VDEVD) $(BUILD_VDEVD_HELPERS) $(BUILD_MAN8DIR)
fbt's avatar
fbt committed
58 59
INSTALL_VDEVD := $(DESTDIR)$(SBINDIR)
INSTALL_VDEVD_HELPERS := $(DESTDIR)$(LIBDIR)/vdev
60
INSTALL_MAN8DIR := $(DESTDIR)$(MAN8DIR)
61 62 63 64

# vdevfs 
BUILD_VDEVFS := $(BUILD_USRSBIN)
BUILD_VDEVFS_DIRS := $(BUILD_VDEVFS)
fbt's avatar
fbt committed
65
INSTALL_VDEVFS := $(DESTDIR)$(SBINDIR)
66 67 68 69 70 71

# config
BUILD_VDEV_CONFIG := $(BUILD_ETCDIR)/vdev
BUILD_VDEV_INITSCRIPT := $(BUILD_ETCDIR)/init.d
BUILD_VDEV_INITRAMFS := $(BUILD_USRSHARE)/initramfs-tools
BUILD_VDEV_CONFIG_DIRS := $(BUILD_VDEV_CONFIG)
fbt's avatar
fbt committed
72 73
INSTALL_VDEV_CONFIG := $(DESTDIR)$(ETCDIR)/vdev
INSTALL_VDEV_INITSCRIPT := $(DESTDIR)$(ETCDIR)/init.d
74 75
INSTALL_VDEV_INITRAMFS := $(DESTDIR)$(SHAREDIR)/vdev/initramfs-tools
INSTALL_VDEV_INSTALL_SCRIPT := $(DESTDIR)$(SHAREDIR)/vdev
76

Jude Nelson's avatar
Jude Nelson committed
77 78 79
# hwdb 
BUILD_HWDB := $(BUILD_LIBDIR)/vdev/hwdb
BUILD_HWDB_DIRS := $(BUILD_HWDB)
fbt's avatar
fbt committed
80
INSTALL_HWDB := $(DESTDIR)$(LIBDIR)/vdev/hwdb
Jude Nelson's avatar
Jude Nelson committed
81

82 83
# compiler
CFLAGS     := -Wall -std=c99 -g -fPIC -fstack-protector -fstack-protector-all -pthread -Wno-unused-variable -Wno-unused-but-set-variable
84
LDFLAGS    :=
85
INC      := -I. -I$(ROOT_DIR) -I$(BUILD_INCLUDEDIR)
86
DEFS     := -D_THREAD_SAFE -D__STDC_FORMAT_MACROS -D_VDEV_OS_$(OS) -D_XOPEN_SOURCE=700
87
LIBINC   := 
88
CC       ?= cc
89 90

# build setup
91
BUILD_DIRS   := $(sort $(BUILD_VDEVD_DIRS) \
92
                $(BUILD_VDEVFS_DIRS) \
93
					 $(BUILD_LIBUDEV_COMPAT_DIRS) \
Jude Nelson's avatar
Jude Nelson committed
94 95
					 $(BUILD_LIBVDEV_DIRS) \
					 $(BUILD_HWDB))
96 97 98 99 100 101

all:

build_setup: $(BUILD_DIRS)

$(BUILD_DIRS):
Jude Nelson's avatar
Jude Nelson committed
102
	@mkdir -p "$@"
103

104 105 106
# rule to make an archive member from an object file
(%.o): %.o ;    $(AR) cr $@ $*.o

107 108
# debugging...
print-%: ; @echo $*=$($*)