forked from dewoods/greenplum-json-formatter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
40 lines (30 loc) · 888 Bytes
/
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
UNAME := $(shell uname)
PROG=json_formatter.so
ifeq ($(UNAME), Darwin)
CC=cc
ARCHFLAGS=-m32
%.so : CFLAGS=-Wall -bundle -flat_namespace -undefined suppress
endif
ifeq ($(UNAME), Linux)
CC=cc
%.so : CFLAGS=-Wall -shared
endif
LD = -L$(shell pg_config --libdir) -L$(shell pg_config --pkglibdir) -ljansson #-Wl,-v
PGINC = $(shell pg_config --includedir)
INCLUDEDIRS = -I$(PGINC) -I$(PGINC)/postgresql/internal -I$(PGINC)/postgresql/server -I$(PGINC)/jansson
lib/%.o : CFLAGS=-fpic -Wall $(INCLUDEDIRS)
all: lib/$(PROG)
lib/$(PROG): lib/$(PROG:%.so=%.o)
$(CC) $(LD) $(CFLAGS) $(ARCHFLAGS) -o $@ $<
lib/$(PROG:%.so=%.o): src/$(PROG:%.so=%.c)
$(CC) $(CFLAGS) $(ARCHFLAGS) -c $< -o $@
clean:
rm -rf lib/*.so
rm -rf lib/*.o
install:
test -f lib/$(PROG)
cp lib/$(PROG) $(GPHOME)/lib/postgresql
psql -f sql/install.sql
.PHONY: test
test:
roundup test/test.sh