EXTENSION = osm_fdw EXTVERSION = $(shell grep default_version $(EXTENSION).control | sed -e "s/default_version[[:space:]]*=[[:space:]]*'\([^']*\)'/\1/") DATA = $(filter-out $(wildcard sql/*--*.sql),$(wildcard sql/*.sql)) DOCS = $(wildcard doc/*.md) TESTS = $(wildcard test/sql/*.sql) REGRESS = $(patsubst test/sql/%.sql,%,$(TESTS)) REGRESS_OPTS = --inputdir=test --load-language=plpgsql MODULE_big = $(EXTENSION) # # Uncoment the MODULES line if you are adding C files # to your extention. # #MODULES = $(patsubst %.c,%,$(wildcard src/*.c)) PG_CONFIG = pg_config PG93 = $(shell $(PG_CONFIG) --version | grep -qE " 8\.| 9\.0| 9\.1 | 9\.2| 9\.2| 9\.4" && echo no || echo yes) PG94 = $(shell $(PG_CONFIG) --version | grep -qE " 8\.| 9\.0| 9\.1 | 9\.2| 9\.2| 9\.3" && echo no || echo yes) #ifeq ($(PG94),yes) DATA = $(wildcard sql/*--*.sql) sql/$(EXTENSION)--$(EXTVERSION).sql EXTRA_CLEAN = sql/$(EXTENSION)--$(EXTVERSION).sql #endif CURRENT_FOLDER = $(shell pwd) READER_FOLDER = $(CURRENT_FOLDER)/src/osm_reader FDW_FOLDER = $(CURRENT_FOLDER)/src/osm_fdw CONVERTER_FOLDER = $(CURRENT_FOLDER)/src/osm_convert FC = -g -fpic F_PROTO = $(shell pkg-config --cflags libprotobuf-c) F_Z = $(shell pkg-config --cflags zlib) F_JSON = $(shell pkg-config --cflags json-c) F_PG = -I$(shell $(PG_CONFIG) --includedir-server) F_LD = $(shell pkg-config --libs json-c) F_LD += $(shell pkg-config --libs libprotobuf-c) F_LD += $(shell pkg-config --libs zlib) SHLIB_LINK = $(F_LD) OBJS = osm_reader.o OBJS += type_defs.o OBJS += zdecode.o OBJS += fileformat.pb-c.o OBJS += osmformat.pb-c.o ifeq ($(PG94), yes) ENV_VARS += -DUSE_JSONB OBJS += jsonb_encode.o else ENV_VARS += -DUSE_LIBJSONC OBJS += json_encode.o endif OBJS += osm_fdw.o EXTRA_CLEAN += json_encode.o jsonb_encode.o osm_to_json.o osm_to_json build_all: sql/$(EXTENSION)--$(EXTVERSION).sql all sql/$(EXTENSION)--$(EXTVERSION).sql: sql/$(EXTENSION).sql cp $< $@ $(READER_FOLDER)/fileformat.pb-c.c: make -C $(READER_FOLDER) fileformat.pb-c.c fileformat.pb-c.o: $(READER_FOLDER)/fileformat.pb-c.c gcc -c $(FC) $(F_PROTO) $(READER_FOLDER)/fileformat.pb-c.c $(READER_FOLDER)/osmformat.pb-c.c: make -C $(READER_FOLDER) osmformat.pb-c.c osmformat.pb-c.o: $(READER_FOLDER)/osmformat.pb-c.c gcc -c $(FC) $(F_PROTO) $(READER_FOLDER)/osmformat.pb-c.c zdecode.o: gcc -c $(FC) $(F_Z) $(READER_FOLDER)/zdecode.c type_defs.o: gcc -c $(FC) $(READER_FOLDER)/type_defs.c json_encode.o: gcc -c $(FC) $(F_JSON) $(READER_FOLDER)/json_encode.c jsonb_encode.o: gcc -c $(FC) $(F_PG) $(ENV_VARS) -I$(READER_FOLDER) $(FDW_FOLDER)/jsonb_encode.c osm_reader.o: gcc -c $(FC) $(READER_FOLDER)/osm_reader.c osm_fdw.o: gcc -c $(FC) $(F_PG) $(F_JSON) $(ENV_VARS) -I$(READER_FOLDER) $(FDW_FOLDER)/osm_fdw.c CONVERTER_OBJS = osm_reader.o CONVERTER_OBJS += type_defs.o CONVERTER_OBJS += zdecode.o CONVERTER_OBJS += fileformat.pb-c.o CONVERTER_OBJS += osmformat.pb-c.o CONVERTER_OBJS += json_encode.o osm_to_json.o: gcc -c $(FC) $(F_JSON) -I$(READER_FOLDER) $(CONVERTER_FOLDER)/osm_to_json.c osm_to_json: osm_to_json.o $(CONVERTER_OBJS) gcc $(FC) $(F_LD) -o osm_to_json -I$(READER_FOLDER) osm_to_json.o $(CONVERTER_OBJS) PGXS := $(shell $(PG_CONFIG) --pgxs) include $(PGXS)