forked from casper2020/pg-jsonapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
156 lines (133 loc) · 4.08 KB
/
makefile
File metadata and controls
156 lines (133 loc) · 4.08 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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#
# Copyright (c) 2011-2018 Cloudware S.A. All rights reserved.
#
# This file is part of pg-jsonapi.
#
# pg-jsonapi is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# pg-jsonapi is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with pg-jsonapi. If not, see <http://www.gnu.org/licenses/>.
#
.PHONY: debug
####################
# PLATFORM
####################
PLATFORM:=$(shell uname -s)
MACHINE_ARCH:=$(shell uname -m)
####################
# ARCH
####################
PRJ_ARCH?=$(MACHINE_ARCH)
MULTI_ARCH_BUILD_MACHINE?=false
####################
# Set target type
####################
ifeq (Darwin, $(PLATFORM))
ifndef TARGET
TARGET:=Debug
else
override TARGET:=$(shell echo $(TARGET) | tr A-Z a-z)
$(eval TARGET_E:=$$$(TARGET))
TARGET_E:=$(shell echo $(TARGET_E) | tr A-Z a-z )
TARGET_S:=$(subst $(TARGET_E),,$(TARGET))
TARGET_S:=$(shell echo $(TARGET_S) | tr a-z A-Z )
TMP_TARGET:=$(TARGET_S)$(TARGET_E)
override TARGET:=$(TMP_TARGET)
endif
else
ifndef TARGET
TARGET:=debug
else
override TARGET:=$(shell echo $(TARGET) | tr A-Z a-z)
endif
endif
TARGET_LC:=$(shell echo $(TARGET) | tr A-Z a-z)
# validate target
ifeq (release, $(TARGET_LC))
#
else
ifeq (debug, $(TARGET_LC))
#
else
$(error "Don't know how to build for target $(TARGET_LC) ")
endif
endif
### ... ###
LIB_NAME:= pg-jsonapi
ifndef LIB_VERSION
LIB_VERSION := 2.6.3
endif
include settings.mk
ifeq (Darwin,$(PLATFORM))
CFLAGS+= -DDEVELOPER_MODE=1
ARCH_CFLAGS=-arch $(PRJ_ARCH)
ARCH_CXXFLAGS=-arch $(PRJ_ARCH)
ARCH_LDFLAGS=-m64 -arch $(PRJ_ARCH)
ifeq (true, $(MULTI_ARCH_BUILD_MACHINE))
OPENSSL_VERSION:=$(shell cat ../casper-packager/openssl/version | tr -dc '0-9.' | cut -d'.' -f1-2)
OPENSSL_DIR:=/usr/local/casper/openssl/$(PRJ_ARCH)/$(TARGET)/$(OPENSSL_FULL_VERSION)
else
OPENSSL_DIR:=/Applications/casper.app/Contents/MacOS/openssl/lib
endif
OPENSSL_LDFLAGS:=-L$(OPENSSL_DIR)
else
SO_NAME = $(LIB_NAME).so.$(LIB_VERSION)
LINK_FLAGS += -Wl,-soname,$(SO_NAME) -Wl,-z,relro -Bsymbolic
endif
$(shell sed -e s#@VERSION@#${LIB_VERSION}#g pg-jsonapi.control.tpl > pg-jsonapi.control)
RAGEL:=$(shell which ragel)
RAGEL_FILES=src/query_builder.rl src/operation_request.rl
SRC_FILES=src/pg_jsonapi.cc json/jsoncpp.cc src/document_config.cc src/error_code.cc src/error_object.cc src/resource_config.cc src/resource_data.cc src/observed_stat.cc src/utils_adt_json.cc
OBJS=$(SRC_FILES:.cc=.o) $(RAGEL_FILES:.rl=.o)
#%.o:%.cc
# $(CC) -c $(CFLAGS) $(CXXFLAGS) $(OTHER_CFLAGS) $< -o $@
%.cc: %.rl
$(RAGEL) $< -G2 -o $@
%.bc : %.cc
$(COMPILE.cxx.bc) $(CCFLAGS) $(CPPFLAGS) -fPIC -c -o $@ $<
EXTENSION := $(LIB_NAME)
EXTVERSION := $(LIB_VERSION)
SHLIB_LINK := -lstdc++ $(LINK_FLAGS)
PG_CPPFLAGS := -fPIC $(CFLAGS) $(CXXFLAGS) $(OTHER_CFLAGS) $(ARCH_CFLAGS)
MODULE_big := $(LIB_NAME)
PG_CONFIG ?= pg_config
EXTRA_CLEAN := $(RAGEL_FILES:.rl=.cc) $(LIB_NAME).so*
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
## OVERRIDE sysroot ##
ifeq (Darwin,$(PLATFORM))
XCODE_APP_DIR:=$(shell echo "${XCODE_APP_DIR}")
# only if XCODE_APP_DIR is not set ( it should only be set on beta machines )
ifndef XCODE_APP_DIR
override CPPFLAGS := $(subst Xcode-beta,Xcode,$(CPPFLAGS))
endif
endif
SHLIB_LINK += $(OPENSSL_LDFLAGS)
# developer
dev: debug
sudo make install
# so
so:
@echo "* $(PLATFORM) $(TARGET) $(PRJ_ARCH) rebuild..."
@make -f makefile clean all
# debug
debug:
@make -f makefile TARGET=debug so
ifeq (Darwin, $(PLATFORM))
@lipo -info $(LIB_NAME).so
endif
# release
release:
@echo "* $(PLATFORM) $(TARGET) $(PRJ_ARCH) rebuild..."
@make -f makefile TARGET=release so
ifeq (Darwin, $(PLATFORM))
@lipo -info $(LIB_NAME).so
endif