-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
64 lines (53 loc) · 1.79 KB
/
Makefile
File metadata and controls
64 lines (53 loc) · 1.79 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Compiler to use. gcc is recommended but any compiler implementing the C11 standard should work.
# clang is a good alternative on some platforms.
CC := gcc
PKGCONF := pkg-config
CFLAGS := -std=c11 -Wall -Wextra -Wconversion -Winline -Werror=format -Werror=format-security -Werror=write-strings -Wno-sign-conversion
CFLAGS += -DNVDIALOG_MAXBUF=4096 -DNVD_EXPORT_SYMBOLS -D_NVD_SUPPORT_IMAGES
CFLAGS += $(shell $(PKGCONF) --cflags gtk+-3.0)
LDFLAGS := $(shell $(PKGCONF) --libs gtk+-3.0)
INCLUDES := -Iinclude -Isrc/impl -Ivendor
# Set this to 0 to build nvdialog as a dynamic library instead.
# (If it's 1, nvdialog will be built as a static library)
BUILD_STATIC ?= 1
OBJDIR := build
ifeq ($(BUILD_STATIC),1)
TARGET := $(OBJDIR)/libnvdialog.a
CFLAGS += -DNVD_STATIC_LINKAGE
else
TARGET := $(OBJDIR)/libnvdialog.so
CFLAGS += -fPIC
endif
# Installation directory. /usr/local works for most people but you can also use /usr
# if you want or install it under ~/.local.
INSTALLPREFIX ?= /usr/local
LIBDIR := $(INSTALLPREFIX)/lib
INCDIR := $(INSTALLPREFIX)/include/nvdialog
DIALOGDIR:= $(INCDIR)/dialogs
COMMON_SRC := $(wildcard src/*.c)
GTK_SRC := $(wildcard src/backend/gtk/*.c)
SRC := $(COMMON_SRC) $(GTK_SRC)
OBJ := $(patsubst %.c,$(OBJDIR)/%.o,$(SRC))
.PHONY: all clean install uninstall
all: $(TARGET)
$(TARGET): $(OBJ)
ifeq ($(BUILD_STATIC),1)
ar rcs $@ $(OBJ)
else
$(CC) -shared -o $@ $(OBJ) $(LDFLAGS)
endif
$(OBJDIR)/%.o: %.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
install:
mkdir -p $(LIBDIR)
mkdir -p $(INCDIR)
mkdir -p $(DIALOGDIR)
cp $(TARGET) $(LIBDIR)/
cp include/nvdialog*.h $(INCDIR)/
cp include/dialogs/nvdialog_*.h $(DIALOGDIR)/
uninstall:
rm -f $(LIBDIR)/$(TARGET)
rm -rf $(INCDIR)
clean:
rm -rfv $(OBJDIR) $(TARGET)