-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
131 lines (110 loc) · 3.82 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
PKGNAME = postgres # Edit to adapt
LIBNAME = pqprims
KNOCONFIG = knoconfig
KNOBUILD = knobuild
prefix ::= $(shell ${KNOCONFIG} prefix)
libsuffix ::= $(shell ${KNOCONFIG} libsuffix)
CMODULES ::= $(DESTDIR)$(shell ${KNOCONFIG} cmodules)
SRCMODULES ::= $(DESTDIR)$(shell ${KNOCONFIG} installmods)
KNO_VERSION ::= $(shell ${KNOCONFIG} version)
KNO_MAJOR ::= $(shell ${KNOCONFIG} major)
KNO_MINOR ::= $(shell ${KNOCONFIG} minor)
PKG_VERSION ::= $(shell u8_gitversion etc/knomod_version)
PKG_MAJOR ::= $(shell echo ${PKG_VERSION} | cut -d. -f1)
PKG_MINOR ::= $(shell echo ${PKG_VERSION} | cut -d. -f2)
PKG_PATCHLEVEL ::= $(shell echo ${PKG_VERSION} | cut -d. -f3)
FULL_VERSION ::= ${KNO_MAJOR}.${PKG_VERSION}
INIT_CFLAGS ::= ${CFLAGS}
INIT_LDFLAGS ::= ${LDFLAGS}
KNO_CFLAGS ::= -I. -fPIC $(shell ${KNOCONFIG} cflags)
KNO_LDFLAGS ::= -fPIC $(shell ${KNOCONFIG} ldflags)
KNO_LIBS ::= $(shell ${KNOCONFIG} libs)
MODULE_CFLAGS ::= $(shell ./etc/getcflags libpq)
MODULE_LDFLAGS ::= $(shell ./etc/getlibflags libpq)
SUDO ::= $(shell which sudo)
CFLAGS = ${INIT_CFLAGS} ${MODULE_CFLAGS} ${KNO_CFLAGS} ${XCFLAGS}
LDFLAGS = ${INIT_LDFLAGS} ${MODULE_LDFLAGS} ${KNO_LDFLAGS} ${XLDFLAGS}
MKSO = $(CC) -shared $(CFLAGS) $(LDFLAGS) $(LIBS)
SYSINSTALL = /usr/bin/install -c
MSG = echo
MACLIBTOOL = $(CC) -dynamiclib -single_module -undefined dynamic_lookup \
$(LDFLAGS)
# Meta targets
# .buildmode contains the default build target (standard|debugging)
# debug/normal targets change the buildmode
# module build targets depend on .buildmode
default build: .buildmode
make $(shell cat .buildmode)
module: ${LIBNAME}.${libsuffix}
standard:
make module
debugging:
make XCFLAGS="-O0 -g3" module
.buildmode:
echo standard > .buildmode
debug:
echo debugging > .buildmode
make
normal:
echo standard > .buildmode
make
# Basic targets (Edit to adapt)
pqprims.o: pqprims.c makefile
@$(CC) $(CFLAGS) -D_FILEINFO="\"$(shell u8_fileinfo ./$< $(dirname $(pwd))/)\"" -o $@ -c $<
@$(MSG) CC "(PQPRIMS)" $@
pqprims.so: pqprims.o
@$(MKSO) $(LDFLAGS) -o $@ pqprims.o ${LDFLAGS}
@$(MSG) MKSO $@ $<
@ln -sf $(@F) $(@D)/$(@F).${KNO_MAJOR}
pqprims.dylib: pqprims.c makefile
@$(MACLIBTOOL) -install_name \
`basename $(@F) .dylib`.${KNO_MAJOR}.dylib \
${CFLAGS} ${LDFLAGS} -o $@ $(DYLIB_FLAGS) \
pqprims.c
@$(MSG) MACLIBTOOL $@ $<
TAGS: pqprims.c
etags -o TAGS pqprims.c
# Other targets
${CMODULES} ${SRCMODULES}:
install -d $@
install: build ${CMODULES} ${SRCMODULES}
${SUDO} u8_install_shared ${LIBNAME}.${libsuffix} ${CMODULES} ${FULL_VERSION} "${SYSINSTALL}"
${SUDO} $(SYSINSTALL) postgres.scm ${SRCMODULES}
clean:
rm -f *.o *.${libsuffix}
fresh:
make clean
make default
gitup gitup-trunk:
git checkout trunk && git pull
buildinfo:
@echo "PKGNAME=$(PKGNAME) LIBNAME=$(LIBNAME)";
@echo " PKG_VERSION=$(PKG_VERSION)";
@echo " FULL_VERSION=$(FULL_VERSION)";
@echo " CFLAGS=$(CFLAGS)";
@echo " LDFLAGS=$(LDFLAGS)";
@echo " libsuffix=$(libsuffix)";
@echo " prefix=$(prefix)";
@echo " MKSO=$(MKSO)";
@echo " MACLIBTOOL=$(MACLIBTOOL)";
@echo " SYSINSTALL=$(SYSINSTALL)";
all_buildinfo: buildinfo
@echo "FULL_VERSION=$(FULL_VERSION)";
@echo " PKG_VERSION=$(PKG_VERSION)";
@echo " KNO_VERSION=$(KNO_VERSION)";
@echo " PKG_MAJOR=$(PKG_MAJOR)";
@echo " PKG_MINOR=$(PKG_MINOR)";
@echo " PKG_PATCHLEVEL=$(PKG_PATCHLEVEL)";
@echo " KNO_MAJOR=$(KNO_MAJOR)";
@echo " KNO_MINOR=$(KNO_MINOR)";
@echo "KNOCONFIG=$(KNOCONFIG)";
@echo " KNOBUILD=$(KNOBUILD)";
@echo " CMODULES=$(CMODULES)";
@echo " INIT_CFLAGS=$(INIT_CFLAGS)";
@echo " INIT_LDFLAGS=$(INIT_LDFLAGS)";
@echo " KNO_CFLAGS=$(KNO_CFLAGS)";
@echo " KNO_LDFLAGS=$(KNO_LDFLAGS)";
@echo " KNO_LIBS=$(KNO_LIBS)";
@echo " MODULE_CFLAGS=$(MODULE_CFLAGS)";
@echo " MODULE_LDFLAGS=$(MODULE_LDFLAGS)";
@echo " SUDO=$(SUDO)";