A library and an application
What if we want to distribute shared libraries (again for all the CPUs we can) and a development package as well?
Let's use the bzip2 distribution as our example. The bzip2 binary already comes with QNX OS, but the library doesn't. You can download the source code from http://www.bzip.org.
tar -zxvf bzip2-1.0.3.tar.gz
cd bzip2-1.0.3
make
gcc -Wall -Winline -O2 -fomit-frame-pointer -fno-strength-reduce
-D_FILE_OFFSET_BITS=64 -c decompress.c
Let's remember those options for later.
The problem with using the QNX OS makefile system in this case, is that we want to make two projects: the libbz2 library and the bzip2 application. With the QNX OS Makefile system, we usually have a single project.
mkdir app
cd app
addvariant -i OS
addvariant nto aarch64 o.le
addvariant nto x86_64 o
cd ..
mkdir lib
cd lib
addvariant -i OS
addvariant nto aarch64 so.le
addvariant nto aarch64 a.le
addvariant nto x86_64 so
addvariant nto x86_64 a
If we try to build either of these projects now, not much happens. This is because we haven't told the Makefile system where our source files are.
ifndef QCONFIG
QCONFIG=qconfig.mk
endif
include $(QCONFIG)
include $(MKFILES_ROOT)/qtargets.mk
CCFLAGS+=-Wall -Winline -O2 -fomit-frame-pointer -fno-strength-reduce
-D_FILE_OFFSET_BITS=64
In QNX Neutrino 7.0 or earlier, flags defined in CCFLAGS got passed to both the C compiler, qcc, and the C++ compiler, q++. In QNX Neutrino 7.1 or later, the CCFLAGS settings are passed to the C compiler only; to pass flags to the C++ compiler, you must set them in CXXFLAGS instead.
EXTRA_SRCVPATH=$(PRODUCT_ROOT)
EXCLUDE_OBJS=bzip2recover.o bzip2.o dlltest.o spewG.o unzcrash.o
define PINFO
PINFO DESCRIPTION=bzip2 data compressions library
endef
INSTALLDIR=usr/lib
lib
, let's change it:
NAME=bz2
If we now run make at the terminal, we can watch all of our libraries being built.
LIBS+=bz2
ifndef QCONFIG
QCONFIG=qconfig.mk
endif
include $(QCONFIG)
CCFLAGS+=-Wall -Winline -O2 -fomit-frame-pointer -fno-strength-reduce
-D_FILE_OFFSET_BITS=64
EXTRA_SRCVPATH=$(PRODUCT_ROOT)
EXCLUDE_OBJS= blocksort.o bzip2recover.o bzlib.o compress.o crctable.o
decompress.o dlltest.o huffman.o randtable.o spewG.o unzcrash.o
LIBS+=bz2
define PINFO
PINFO DESCRIPTION=bzip2 file compressor/decompressor
endef
INSTALLDIR=usr/bin
NAME=bzip2
include $(MKFILES_ROOT)/qtargets.mk
../bzip2 --help 2> bzip2.use
make
ls -l nto/*/*/bzip2