-
Notifications
You must be signed in to change notification settings - Fork 27
/
Makefile
133 lines (113 loc) · 3.78 KB
/
Makefile
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
_VERSION=?
-include config.mk
PWD:=$(shell pwd)
#GIT_TIP=$(shell [ -d .git ] && git log HEAD^..HEAD 2>/dev/null |head -n1|cut -d ' ' -f2)
GIT_TIP=$(shell git describe --tags)
DESTDIR?=
PREFIX?=/usr
MANDIR?=$(PREFIX)/share/man
CC?=gcc
VALAFLAGS:=$(foreach w,$(CPPFLAGS) $(CFLAGS) $(LDFLAGS),-X $(w))
VALAC?=valac -g --cc="$(CC)" $(VALAFLAGS)
RTLIBS=gobject-2.0 glib-2.0
VALAPKG:=lib$(shell ./getvv)
BUILD?=build
BIN=valabind
SRC=config.vala main.vala valabindwriter.vala nodeffiwriter.vala utils.vala
SRC+=girwriter.vala swigwriter.vala cxxwriter.vala ctypeswriter.vala dlangwriter.vala gowriter.vala
SRC+=vlangwriter.vala
VAPIS:=$(SRC:%.vala=$(BUILD)/%.vapi)
CSRC:=$(SRC:%.vala=$(BUILD)/%.c)
VALA_FILTER=$(filter %.vala,$?)
TEMPS=$(addprefix --use-fast-vapi=,$(filter-out $(VALA_FILTER:%.vala=$(BUILD)/%.vapi),$(VAPIS)))
TEMPS+=$(VALA_FILTER) $(patsubst %.vala,$(BUILD)/%.c,$(filter-out $?,$^))
ifneq ($(GIT_TIP),)
SGIT_TIP=$(shell echo ${GIT_TIP} | sed -e s,${_VERSION},,)
else
SGIT_TIP=$(GIT_TIP)
endif
ifneq ($(SGIT_TIP),)
VERSION=$(_VERSION)-$(SGIT_TIP)
else
VERSION=$(_VERSION)
endif
INSTALL_MAN?=install -m0644
INSTALL_PROGRAM?=install -m0755
ifneq ($(W32),)
VALAFLAGS+=-D W32=1
PREFIX=/opt/gtk3w32/
PKG_CONFIG_PATH=$(W32_PREFIX)/lib/pkgconfig
CFLAGS=-I$(PREFIX)/include/glib
CFLAGS+=-I$(PREFIX)/include/glib
LDFLAGS=-L$(PREFIX)/lib
CC=i686-pc-mingw32-gcc
all: $(BIN).exe
else
all: $(BIN)
endif
VALA_VERSION=$(shell ./getvv)
VALA_PKGLIBDIR=$(shell pkg-config --variable=pkglibdir lib${VALA_VERSION})
ifeq ($(VALA_PKGLIBDIR),)
VALA_LIBDIR=$(shell pkg-config --variable=libdir lib${VALA_VERSION})
VALA_PKGLIBDIR=$(VALA_LIBDIR)/$(shell ./getvv)
endif
VALA_PRIVATE_CODEGEN=--pkg $(VALAPKG)
VALA_PRIVATE_CODEGEN+=--vapidir=$(PWD)/private --pkg codegen -X -I$(PWD)/private
VALA_PRIVATE_CODEGEN+=--vapidir=${R2PM_PREFIX}/share/vala/vapi/
VALA_PRIVATE_CODEGEN+=-X -L$(VALA_PKGLIBDIR) -X -lvalaccodegen
ifneq ($(shell uname),Darwin)
VALA_PRIVATE_CODEGEN+=-X -Wl,-rpath=$(VALA_PKGLIBDIR)
endif
w32:
$(MAKE) W32=1
.PRECIOUS: $(BUILD)/%.c $(BUILD)/%.vapi
$(BIN).exe: $(SRC) | $(VAPIS)
@echo 'Compiling $(VALA_FILTER) -> $@'
$(VALAC) --vapidir=. -D W32 -X "${CFLAGS}" -X "${LDFLAGS}" -o $@ --pkg $(VALAPKG) --save-temps ${TEMPS} windows.c --pkg windows
@mv $(VALA_FILTER:%.vala=%.c) $(BUILD)
$(BIN): $(SRC) | $(VAPIS)
@echo 'Compiling $(VALA_FILTER) -> $@'
$(VALAC) -o $@ --pkg posix $(VALA_PRIVATE_CODEGEN) --save-temps ${TEMPS}
@mv $(VALA_FILTER:%.vala=%.c) $(BUILD)
$(BUILD)/%.vapi: %.vala | $(BUILD)
@echo 'Generating $< -> $@'
@$(VALAC) $(VALAFLAGS) --fast-vapi=$@ $<
@${MAKE} config.vala
config.vala: Makefile
@echo 'Generating $@'
@echo 'const string version_string = "$(VERSION)";' > $@
$(BUILD):
mkdir -p $@
install_dirs:
mkdir -p $(DESTDIR)$(PREFIX)/bin
mkdir -p $(DESTDIR)$(MANDIR)/man1
install: install_dirs
$(INSTALL_MAN) $(BIN).1 $(DESTDIR)$(MANDIR)/man1
$(INSTALL_MAN) $(BIN)-cc.1 $(DESTDIR)$(MANDIR)/man1
$(INSTALL_PROGRAM) $(BIN) $(DESTDIR)$(PREFIX)/bin
$(INSTALL_PROGRAM) $(BIN)-cc $(DESTDIR)$(PREFIX)/bin
symstall: install_dirs
chmod +x $(PWD)/$(BIN)-cc
ln -fs $(PWD)/$(BIN).1 $(DESTDIR)$(MANDIR)/man1
ln -fs $(PWD)/$(BIN)-cc.1 $(DESTDIR)$(MANDIR)/man1
ln -fs $(PWD)/$(BIN) $(DESTDIR)$(PREFIX)/bin
ln -fs $(PWD)/$(BIN)-cc $(DESTDIR)$(PREFIX)/bin
dist:
$(MAKE) shot GIT_TIP=
shot:
rm -rf valabind-$(VERSION)
git clone . valabind-$(VERSION)
cd valabind-$(VERSION) && $(MAKE) config.vala
rm -rf valabind-$(VERSION)/.git
tar czvf valabind-$(VERSION).tar.gz valabind-$(VERSION)
mrproper clean:
rm -f config.vala
rm -rf $(BUILD) $(BIN)
rm -rf $(CSRC)
deinstall: uninstall
uninstall:
-rm $(DESTDIR)$(MANDIR)/man1/$(BIN).1
-rm $(DESTDIR)$(MANDIR)/man1/$(BIN)-cc.1
-rm $(DESTDIR)$(PREFIX)/bin/$(BIN)
-rm $(DESTDIR)$(PREFIX)/bin/$(BIN)-cc
.PHONY: all clean dist install symstall uninstall deinstall mrproper