Postgresql extension Makefile returning error - postgresql

I wrote a SQL extension following the instructions on PGXN, but I always get a make install error as following:
/bin/mkdir -p '/usr/share/postgresql/9.5/extension'
/bin/mkdir -p '/usr/share/postgresql/9.5/extension'
/bin/mkdir -p '/usr/share/doc/postgresql-doc-9.5/extension'
/usr/bin/install -c -m 644 .//myextname.control '/usr/share/postgresql/9.5/extension/'
/usr/bin/install -c -m 644 .//sql/myextname--1.0.0.sql .//sql/myextname--1.0.0.sql '/usr/share/postgresql/9.5/extension/'
/usr/bin/install: will not overwrite just-created ‘/usr/share/postgresql/9.5/extension/myextname--1.0.0.sql’ with ‘.//sql/myextname--1.0.0.sql’
make: *** [install] Error 1
My Makefile is as following:
EXTENSION = myextname
EXTVERSION = $(shell grep default_version $(EXTENSION).control | \
sed -e "s/default_version[[:space:]]*=[[:space:]]*'\([^']*\)'/\1/")
DATA = $(filter-out $(wildcard sql/*--*.sql),$(wildcard sql/*.sql))
TESTS = $(wildcard test/sql/*.sql)
REGRESS = $(patsubst test/sql/%.sql,%,$(TESTS))
REGRESS_OPTS = --inputdir=test
DOCS = $(wildcard doc/*.md)
MODULES = $(patsubst %.c,%,$(wildcard src/*.c))
PG_CONFIG = pg_config
PG91 = $(shell $(PG_CONFIG) --version | grep -qE " 8\\.| 9\\.0" && echo no || echo yes)
ifeq ($(PG91),yes)
all: sql/$(EXTENSION)--$(EXTVERSION).sql
sql/$(EXTENSION)--$(EXTVERSION).sql: $(strip sql/tables.sql \
sql/types.sql \
sql/domains.sql \
)
cat $^ > $#
DATA = $(wildcard sql/*--*.sql) sql/$(EXTENSION)--$(EXTVERSION).sql
EXTRA_CLEAN = sql/$(EXTENSION)--$(EXTVERSION).sql
endif
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
This blog says this error is caused by this line:
DATA = $(wildcard sql/*--*.sql) sql/$(EXTENSION)--$(EXTVERSION).sql
which evaluates into the same filename twice (and /usr/bin/install refuses to overwrite the first instance of the file).
But how can I fix it?

You seem to have copied the Makefile from PGXN, and it is probably much more complicated than you need.
For example, do you target PostgreSQL versions below 9.1?
You'll be much better off with a small, simple custom tailored Makefile like this:
MODULES = src/myextname
EXTENSION = myextname
DATA = sql/myextname--1.0.sql
DOCS = doc/myextname.md
REGRESS = myextname
REGRESS_OPTS = --inputdir=test
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
This (untested) Makefile sticks with the file organization suggested by PGXN.

Related

Join two lists of strings in a makefile

In my makefile there is a variable that contains all source files:
SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))
I now want to create a DEPFILES that contains the same files as SOURCES with two main differences:
Each file ends with ".d" instead of ".c"
Each file contains a "." before its basename, such that the resulting file is hidden.
I came up with this expression, which works well:
DEPFILES := $(foreach s,$(SOURCES:.$(SRCEXT)=.$(DEPSEXT)),$(shell echo $(s) | sed -e 's/^\(.*\/\)/\1./')))
Initially, I split SOURCES into the following lists:
PRE := $(dir $(SOURCES))
SUF := $(addprefix ".", $(notdir $(SOURCES)))
Question: How do you join those two lists in a makefile, such that the results equals DEPFILES? In other words: How do you pairwisely concat the strings from both lists?
Here is a simpler approach using makefile only and no shell - if I understood your requirement ok:
SRCS += bob/src1.c fred/src2.c src3.c
DEPS=$(join $(addsuffix ., $(dir $(SRCS))), $(notdir $(SRCS:.c=.d)))
# Some debug:
$(info 1. $(SRCS))
$(info 2. $(SRCS:.c=.d))
$(info 3. $(notdir $(SRCS:.c=.d)))
$(info 4. $(dir $(SRCS)))
.PHONY: all
all:
#echo SRCS: $(SRCS)
#echo DEPS: $(DEPS)
I broke the output down into steps so you can see what each part does - saves me to explain it!
outputs:
1. bob/src1.c fred/src2.c src3.c
2. bob/src1.d fred/src2.d src3.d
3. src1.d src2.d src3.d
4. bob/ fred/ ./
SRCS: bob/src1.c fred/src2.c src3.c
DEPS: bob/.src1.d fred/.src2.d ./.src3.d

do_compile error while running bitbake on poky

iam using poky to build a BSP for my imxsabreauto board. i got the following error. please help me on this.
error log:
NOTE: Preparing runqueue
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
ERROR: Function failed: do_compile (log file is located at /home/viswanath/SabreAuto_error/build-wayland/tmp/work/cortexa9hf-vfp-neon-poky-linux-gnueabi/busybox/1.22.1-r32/temp/log.do_compile.15410)
ERROR: Logfile of failure stored in: /home/viswanath/SabreAuto_error/build-wayland/tmp/work/cortexa9hf-vfp-neon-poky-linux-gnueabi/busybox/1.22.1-r32/temp/log.do_compile.15410
| DEBUG: SITE files ['endian-little', 'bit-32', 'arm-common', 'common-linux', 'common-glibc', 'arm-linux', 'arm-linux-gnueabi', 'common']
| DEBUG: Executing shell function do_compile
| grep: .config: No such file or directory
| cp: cannot stat '.config': No such file or directory
| WARNING: exit code 1 from a shell command.
| ERROR: Function failed: do_compile (log file is located at /home/viswanath/SabreAuto_error/build-wayland/tmp/work/cortexa9hf-vfp-neon-poky-linux-gnueabi/busybox/1.22.1-r32/temp/log.do_compile.15410)
ERROR: Task 2086 (/home/viswanath/SabreAuto_error/sources/poky/meta/recipes-core/busybox/busybox_1.22.1.bb, do_compile) failed with exit code '1'
NOTE: Tasks Summary: Attempted 2014 tasks of which 16 didn't need to be rerun and 1 failed.
Waiting for 0 running tasks to finish:
Summary: 1 task failed:
/home/viswanath/SabreAuto_error/sources/poky/meta/recipes-core/busybox/busybox_1.22.1.bb, do_compile
Summary: There was 1 ERROR message shown, returning a non-zero exit code.
bitbake file:
require busybox.inc
PR = "r32"
SRC_URI =
"http://www.busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \
file://get_header_tar.patch \
file://busybox-appletlib-dependency.patch \
file://busybox-udhcpc-no_deconfig.patch \
file://find-touchscreen.sh \
file://busybox-cron \
file://busybox-httpd \
file://busybox-udhcpd \
file://default.script \
file://simple.script \
file://hwclock.sh \
file://mount.busybox \
file://syslog \
file://syslog-startup.conf \
file://syslog.conf \
file://busybox-syslog.default \
file://mdev \
file://mdev.conf \
file://umount.busybox \
file://defconfig \
file://busybox-syslog.service.in \
file://busybox-klogd.service.in \
file://fail_on_no_media.patch \
file://run-ptest \
file://inetd.conf \
file://inetd \
file://login-utilities.cfg \
file://0001-build-system-Specify-nostldlib-when-linking-to-.o-fi.patch \
file://recognize_connmand.patch \
file://busybox-cross-menuconfig.patch \
"
SRC_URI[tarball.md5sum] = "337d1a15ab1cb1d4ed423168b1eb7d7e"
SRC_URI[tarball.sha256sum] = "ae0b029d0a9e4dd71a077a790840e496dd838998e4571b87b60fed7462b6678b"
EXTRA_OEMAKE += "V=1 ARCH=${TARGET_ARCH} CROSS_COMPILE=${TARGET_PREFIX} SKIP_STRIP=y"
do_install_ptest () {
cp -r ${B}/testsuite ${D}${PTEST_PATH}/
cp ${B}/.config ${D}${PTEST_PATH}/
ln -s /bin/busybox ${D}${PTEST_PATH}/busybox
}
inherit autotools gettext
the error seems to there is no ".config file".
if you need p-test click the link p-test yocto
for busybox see the link busybox.bb

Compile a static version of pngquant

I'm trying to create a statically linked version of pngquant in Oracle Linux Server release 7.1. I've compiled the static version of zlib and the static version of libpng.
Then, when I configure pngquant, I always get the information that it will be linked with a shared version of zlib.
$ ./configure --with-libpng=../libpng-1.6.21 --extra-cflags="-I../zlib-1.2.8" --extra-ldflags="../zlib-1.2.8/libz.a"
Compiler: gcc
Debug: no
SSE: yes
OpenMP: no
libpng: static (1.6.21)
zlib: shared (1.2.7)
lcms2: no
If I execute make, in the output it seems that the options are correctly passed to the compiler. However, the resulting binary requires libz.so to be executed. It seems that my directives are ignored or that the installed version always takes precedence.
Is there any way of forcing pngquant to be compiled with the static version of zlib?
I'm not sure, if I got it right, but here's a patch to pngquant's configure that worked for me. configure now accepts --with-zlib=<dir> as parameter. Store it to pngquant.patch and apply it with patch -uN -p1 -i pngquant.patch.
diff -ur pngquant-2.9.0/configure pngquant-2.9.0.fixed/configure
--- pngquant-2.9.0/configure 2017-03-06 09:37:30.000000000 +0100
+++ pngquant-2.9.0.fixed/configure 2017-03-07 09:57:20.246012152 +0100
## -48,6 +48,7 ##
help "--with-cocoa/--without-cocoa use Cocoa framework to read images"
fi
help "--with-libpng=<dir> search for libpng in directory"
+ help "--with-zlib=<dir> search for zlib in directory"
echo
help "CC=<compiler> use given compiler command"
help "CFLAGS=<flags> pass options to the compiler"
## -97,6 +98,9 ##
--with-libpng=*)
LIBPNG_DIR=${i#*=}
;;
+ --with-zlib=*)
+ ZLIB_DIR=${i#*=}
+ ;;
--prefix=*)
PREFIX=${i#*=}
;;
## -238,6 +242,19 ##
echo "${MAJ}${MIN}"
}
+# returns full zlib.h version string
+zlibh_string() {
+ echo "$(grep -m1 "define ZLIB_VERSION" "$1" | \
+ grep -Eo '"[^"]+"' | grep -Eo '[^"]+')"
+}
+
+# returns major minor version numbers from png.h
+zlibh_majmin() {
+ local MAJ=$(grep -m1 "define ZLIB_VER_MAJOR" "$1" | grep -Eo "[0-9]+")
+ local MIN=$(grep -m1 "define ZLIB_VER_MINOR" "$1" | grep -Eo "[0-9]+")
+ echo "${MAJ}${MIN}"
+}
+
error() {
status "$1" "error ... $2"
echo
## -420,11 +437,42 ##
error "libpng" "not found (try: $LIBPNG_CMD)"
fi
-# zlib
-if ! find_library "zlib" "z" "zlib.h" "libz.a" "libz.$SOLIBSUFFIX*"; then
- error "zlib" "not found (please install zlib-devel package)"
+# try if given flags are enough for zlib
+HAS_ZLIB=0
+if echo "#include \"zlib.h\"
+ int main(){
+ uLong test = zlibCompileFlags();
+ return 0;
+}" | "$CC" -xc -std=c99 -o /dev/null $CFLAGS $LDFLAGS - &> /dev/null; then
+ status "zlib" "custom flags"
+ HAS_ZLIB=1
fi
+if [ "$HAS_ZLIB" -eq 0 ]; then
+ # try static in the given directory
+ ZLIBH=$(find_h "$ZLIB_DIR" "zlib.h")
+ if [ -n "$ZLIBH" ]; then
+ ZLIBH_STRING=$(zlibh_string "$ZLIBH")
+ ZLIBH_MAJMIN=$(zlibh_majmin "$ZLIBH")
+ if [[ -n "$ZLIBH_STRING" && -n "$ZLIBH_MAJMIN" ]]; then
+ ZLIBA=$(find_f "$ZLIB_DIR" "libz${ZLIBH_MAJMIN}.a")
+ if [ -z "$ZLIBA" ]; then
+ ZLIBA=$(find_f "$ZLIB_DIR" "libz.a")
+ fi
+ if [ -n "$ZLIBA" ]; then
+ cflags "-I${ZLIBH%/*}"
+ lflags "${ZLIBA}"
+ status "zlib" "static (${ZLIBH_STRING})"
+ HAS_ZLIB=1
+ fi
+ fi
+ fi
+fi
+# zlib
+if ! find_library "zlib" "z" "zlib.h" "libz.a" "zlib.$SOLIBSUFFIX*"; then
+ error "zlib" "not found (please install zlib-devel package)"
+fi
+
# lcms2
if [ "$LCMS2" != 0 ]; then
if find_library "lcms2" "lcms2" "lcms2.h" "liblcms2.a" "liblcms2.$SOLIBSUFFIX*"; then
Sorry, the configure script does not support it. It shouldn't be too hard to modify configure to pass appropriate flags to pkg-config or do the same workaround it does for libpng.

Perl installtion on ARMv7eb

I have cross compiled tool chain for armv7eb. Now I have copied the tools to my target machine and tried to build perl on target. In this process of building perl, there is a binary called 'miniperl' which crashes, outputting "ILLEGAL INSTRUCTION".
Can someone help me point out what I should be doing?
PERL VERSION: 5.8.8
GCC: 4.1.3
Please find the crash log below. Does anybody have any suggestions?
sh cflags "optimize='-O'" opmini.o` -DPIC -fPIC -DPERL_EXTERNAL_GLOB opmini.c
CCCMD = cc -DPERL_CORE -c -msoft-float -dynamic -fno-strict-aliasing -pipe -Wdeclaration-after-statement -O -Wall
LD_LIBRARY_PATH=/usr/pkg/src/perl-5.8.8:/lib:/usr/lib:/usr/pkg/lib:/usr/pkg/src/PTHREAD/lib cc -Wl,-rpath,/usr/pkg/lib -Wl,-rpath,/usr/local/lib -L/usr/pkg/lib -L/lib -L/usr/lib -o miniperl miniperlmain.o opmini.o -L. -lperl -lm -lcrypt -lutil -lc -lposix
LD_LIBRARY_PATH=/usr/pkg/src/perl-5.8.8:/lib:/usr/lib:/usr/pkg/lpid 25563 (miniperl), uid 0: exited on signal 4 (core not dumped, err = 2)
ib:/usr/pkg/src/PTHREAD/lib ./miniperl -w -Ilib -MExporter -e '<?>' || make minitest
[1] Illegal instruction LD_LIBRARY_PATH=...
cp ext/re/re.pm lib/re.pm
LD_LIBRARY_PATH=/usr/pkg/src/perpid 8052 (miniperl), uid 0: exited on signal 4 (core not dumped, err = 2)
l-5.8.8:/lib:/usr/lib:/usr/pkg/lib:/usr/pkg/src/PTHREAD/lib ./miniperl -Ilib configpm --heavy=lib/Config_heavy.pl lib/Config.pm
[1] Illegal instruction LD_LIBRARY_PATH=...
*** Error code 132
Stop.
make: stopped in /upid 25595 (miniperl), uid 0: exited on signal 4 (core not dumped, err = 2)
sr/pkg/src/perl-5.8.8
*** Error code 1 (ignored)
You may see some irrelevant test failures if you have been unable
to build lib/Config.pm, lib/lib.pm or the Unicode data files.
cd t && (rm -f perl; /bin/ln -s ../miniperl perl) && LD_LIBRARY_PATH=/usr/pkg/src/perl-5.8.8:/lib:/usr/lib:/usr/pkg/lib:/usr/pkg/src/PTHREAD/lib ./perl TEST -minitest base/*.t comp/*.t cmd/*.t run/*.t io/*.t op/*.t uni/*.t </dev/tty
[1] Illegal instruction LD_LIBRARY_PATH=...
*** Error code 132 (ignored)
*** Error code 1 (ignored)
LD_LIBRARY_PATH=/usr/pkg/src/perpid 703 (miniperl), uid 0: exited on signal 4 (core not dumped, err = 2)
l-5.8.8:/lib:/usr/lib:/usr/pkg/lib:/usr/pkg/src/PTHREAD/lib ./miniperl -Ilib configpm --heavy=lib/Config_heavy.pl lib/Config.pm

How to compile uefi application using gnu-efi?

I tried to compile uefi code using gnu-efi. But I don't understand how to compile my uefi application code.
I get gnu-efi 3.0.2, decompress and type make && make install. I write hello world code:
#include <efi.h>
#include <efilib.h>
EFI_STATUS efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) {
InitializeLib(ImageHandle, SystemTable);
Print(L"Hello, world!\n");
return EFI_SUCCESS;
}
My OS is Ubuntu 15.04.
Include the gnu-efi files
#include <efi.h>
#include <efilib.h>
it looks like your includes where removed by SO
create the make file;
If you were building a "Hello, World" program for Linux in a Linux
environment, you could compile it without a Makefile. Building the
program in Linux for EFI, though, is essentially a cross-compilation
operation. As such, it necessitates using unusual compilation and
linker options, as well as a post-linking operation to convert the
program into a form that the EFI will accept. Although you could type
all the relevant commands by hand, a Makefile helps a lot.
ARCH = $(shell uname -m | sed s,i[3456789]86,ia32,)
OBJS = main.o
TARGET = hello.efi
EFIINC = /usr/include/efi
EFIINCS = -I$(EFIINC) -I$(EFIINC)/$(ARCH) -I$(EFIINC)/protocol
LIB = /usr/lib64
EFILIB = /usr/lib64/gnuefi
EFI_CRT_OBJS = $(EFILIB)/crt0-efi-$(ARCH).o
EFI_LDS = $(EFILIB)/elf_$(ARCH)_efi.lds
CFLAGS = $(EFIINCS) -fno-stack-protector -fpic \
-fshort-wchar -mno-red-zone -Wall
ifeq ($(ARCH),x86_64)
CFLAGS += -DEFI_FUNCTION_WRAPPER
endif
LDFLAGS = -nostdlib -znocombreloc -T $(EFI_LDS) -shared \
-Bsymbolic -L $(EFILIB) -L $(LIB) $(EFI_CRT_OBJS)
all: $(TARGET)
hello.so: $(OBJS)
ld $(LDFLAGS) $(OBJS) -o $# -lefi -lgnuefi
%.efi: %.so
objcopy -j .text -j .sdata -j .data -j .dynamic \
-j .dynsym -j .rel -j .rela -j .reloc \
--target=efi-app-$(ARCH) $^ $#
reference:
http://www.rodsbooks.com/efi-programming/hello.html
In Ubuntu 18.04, these two lines:
LIB = /usr/lib64
EFILIB = /usr/lib64/gnuefi
need to be changed to:
LIB = /usr/lib
EFILIB = /usr/lib