Adding Object files to FreeBSD Kernel Crypto Module - encryption

I added a new cipher to FreeBSD kernel, but i want to link some object files to my cipher. I am having difficulty figuring out how to link those object files.
The .c files of my cipher are located in /usr/src/sys/crypto/mycipher
and the make file for the crypto module looks located in /usr/src/sys/modules/crypto looks like this:
$FreeBSD: release/9.2.0/sys/modules/crypto/Makefile 212496 2010-09-12 16:28:26Z ivoras $
.PATH: ${.CURDIR}/../../opencrypto
.PATH: ${.CURDIR}/../../crypto
.PATH: ${.CURDIR}/../../crypto/blowfish
.PATH: ${.CURDIR}/../../crypto/des
.PATH: ${.CURDIR}/../../crypto/rijndael
.PATH: ${.CURDIR}/../../crypto/sha2
.PATH: ${.CURDIR}/../../crypto/camellia
.PATH: ${.CURDIR}/../../crypto/mycipher
KMOD = crypto
SRCS = crypto.c cryptodev_if.c
SRCS += criov.c cryptosoft.c xform.c
SRCS += cast.c deflate.c rmd160.c rijndael-alg-fst.c rijndael-api.c
SRCS += skipjack.c bf_enc.c bf_ecb.c bf_skey.c
SRCS += des_ecb.c des_enc.c des_setkey.c
SRCS += sha1.c sha2.c
SRCS += opt_param.h cryptodev_if.h bus_if.h device_if.h
SRCS += opt_ddb.h opt_kdtrace.h
SRCS += camellia.c camellia-api.c
SRCS += mycipher.c
.include <bsd.kmod.mk>
I want to link mycipher.c with abc.o , how can i do that ?
Thanks

The obvious answer would be this:
SRCS += abc.c
But since it's a pretty obvious answer, I suspect I'm missing something in your question. Do I?

Related

QMake subdir Template outputs into the build directory instead of the main directory

I am trying to use qmake's subdirs template. The problem is that the output directory specified in the sub projects is created in the build directory instead of the directory that is being referenced in the projects. other then that everything works normally. I was wondering if there is a way to fix this.
Dir Structure
build-project_dir/
-Apps/ --this gets created
-Other things
project_dir/
-main.pro
-Apps/ -- I want it to use this instead
-Server/
----Server.pro
----some logic files
-Parser/
----Parser.pro
----Parser files
-muparser/
-build/
----muparser.pro
----main.cpp
Main.pro
TEMPLATE = subdirs
# where to find the sub projects - give the folders
Server.subdir = Server
Parser.subdir = Parser
muparser.file = muparser-2.2.5\build\muparser.pro
# what subproject depends on others
Server.depends = Parser
Parser.depends = muparser
SUBDIRS = muparser Parser Server
Server.pro
TEMPLATE = app
QT += core sql websockets xml
QT -= gui
TARGET = Server
CONFIG += console
CONFIG -= app_bundle
CONFIG += thread
SOURCES += $$files(src/*.cpp, true) $$files(src/*.c, true)
HEADERS += $$files(src/*.h, true)
INCLUDEPATH += src src/things/include
LIBS += -L../lib -lParser
DESTDIR = ../Apps
Parser.pro
TEMPLATE = lib
QT -= gui
TARGET = Parser
DEFINES += PARSER_LIBRARY
SOURCES += parser.cpp
HEADERS += parser.h
INCLUDEPATH += ./include
DEPENDPATH += $$PWD/./
LIBS += -L../lib -lmuparser
DESTDIR += ../lib
DLLDESTDIR += ../Apps
The reason for this is because there are DLL that are needed there.
Thank to Bill I was able to find a solution to the problem
I simply had to change the DESTDIR location for my apps to DESTDIR = $$_PRO_FILE_PWD_/../Apps_Win

qmake and generated qm files

What is the best (proper) way to organize compiled translations (*.qm) into resources?
*.qm files referred in qrc file and generated by two (three) extra targets this way:
trans_update.commands = lupdate $$_PRO_FILE_
trans_update.depends = $$_PRO_FILE_
trans_release.commands = lrelease $$_PRO_FILE_
trans_release.depends = trans_update $$TRANSLATIONS
translate.depends = trans_release
QMAKE_EXTRA_TARGETS += trans_update trans_release translate deploy
CONFIG(release, debug|release) {
DESTDIR=release
PRE_TARGETDEPS += translate
}
but the problem is at the moment qmake runs first time, there're no qm files generated yet and make prints errors like:
RCC: Error in 'qml.qrc': Cannot find file ...
I don't like an idea of saving compiled qm files into VSC.
Is there a way to organize it nicely?
I like to point out a solution which I use in some projects. It might be far from perfect, but it works out nicely.
CONFIG(release, debug|release) {
TRANSLATION_TARGET_DIR = $${OUT_PWD}/release/translations
LANGUPD_OPTIONS = -locations relative -no-ui-lines
LANGREL_OPTIONS = -compress -nounfinished -removeidentical
} else {
TRANSLATION_TARGET_DIR = $${OUT_PWD}/debug/translations
LANGUPD_OPTIONS =
LANGREL_OPTIONS = -markuntranslated "MISS_TR "
}
isEmpty(QMAKE_LUPDATE) {
win32:LANGUPD = $$[QT_INSTALL_BINS]\lupdate.exe
else:LANGUPD = $$[QT_INSTALL_BINS]/lupdate
}
isEmpty(QMAKE_LRELEASE) {
win32:LANGREL = $$[QT_INSTALL_BINS]\lrelease.exe
else:LANGREL = $$[QT_INSTALL_BINS]/lrelease
}
langupd.command = \
$$LANGUPD $$LANGUPD_OPTIONS $$shell_path($$_PRO_FILE_) -ts $$_PRO_FILE_PWD_/$$TRANSLATIONS
langrel.depends = langupd
langrel.input = TRANSLATIONS
langrel.output = $$TRANSLATION_TARGET_DIR/${QMAKE_FILE_BASE}.qm
langrel.commands = \
$$LANGREL $$LANGREL_OPTIONS ${QMAKE_FILE_IN} -qm $$TRANSLATION_TARGET_DIR/${QMAKE_FILE_BASE}.qm
langrel.CONFIG += no_link
QMAKE_EXTRA_TARGETS += langupd
QMAKE_EXTRA_COMPILERS += langrel
PRE_TARGETDEPS += langupd compiler_langrel_make_all
There might be a sensful tweak to lupdate options because the various builds (release and debug) generate different *.ts files which then trigger a change in the used VCS.
I also like to guide the tended reader to an example where experts use it.
The recommended way -- which may not have been available at the time this question was originally asked would be to use
TRANSLATIONS += <your *.ts files>
CONFIG += lrelease embed_translations
If you really need/want to build the qm files separately, I'd point to what qmake does with the above config and adapt it according to your needs. See https://github.com/qt/qtbase/blob/5.15.2/mkspecs/features/lrelease.prf
(Basically, it creates and adds a list of resources to RESOURCES).

qmake copy files created while building

I've got a library qmake project:
QT += gui
TARGET = qturtle
TEMPLATE = lib
DEFINES += QTURTLE_LIBRARY
SOURCES += qturtle.cpp
HEADERS += qturtle.h\
qturtle_global.h
docMake.commands = doxygen;
QMAKE_EXTRA_TARGETS += docMake
PRE_TARGETDEPS += docMake
QMAKE_DISTCLEAN += $$PWD/html/ -r
QMAKE_DISTCLEAN += doxygen_sqlite3.db
unix {
docInstall.path = /usr/share/doc/qturtle
docInstall.files = $$PWD/html/
headerInstall.files = $$HEADERS
headerInstall.path = /usr/include/qturtle
target.path = /usr/lib
INSTALLS += docInstall
INSTALLS += target
INSTALLS += headerInstall
}
docMake runs doxygen in the project directory, and creates the 'html' directory and its contents ( during build!)
'html' and its contents now should be copied to /usr/share/doc/qturtle, using the INSTALL variable.
BUT: qmake doesn't generate any code for docInstall install, because $$PWD/html and its contents do not exist during makefile generation. Could anybody tell me how to avoid this problem, or do I have to use cp?
Thanks in advance,
Marius
There are two approaches to address this problem.
Not to check againt the initially empty directory
docInstall.CONFIG += no_check_exist directory
Since this directory will be created on the fly, I would personally opt for this.
Create the directory explicitly
createDirs.commands = $$QMAKE_MKDIR $$PWD/html
This could be done either in a target or even in a system("$$QMAKE_MKDIR $$PWD/html") call, depending on your needs.

Qt Multimedia - how to force read tags from media file

It seems to be QMediaPlayer doesn't read tags of playlist files without of executing method play() of current track. Is there a way to force read tags from QMediaPlayer playlist without of playing it?
Sorry if this if a noob question, but I spent a lot of time for searches.
Thanks
Don't waste your time to use QMediaPlayer to read tags (this solution works good, but difficult for many files in list), simply use TagLib or another open-source library.
For example, 3 simple steps to use TagLib in Qt:
1.Compile taglib from source:
$ pwd
/home/user/taglib-1.9.1
$ cmake .
$ make
It's enough to deploy working instance of tag library. Really :)
2.Include headers and library in your project, simply add this or your custom path to project file:
unix:!macx: LIBS += -L$$PWD/3rdparty/taglib-1.9.1/taglib/ -ltag
INCLUDEPATH += $$PWD/3rdparty/taglib-1.9.1/taglib/Headers
DEPENDPATH += $$PWD/3rdparty/taglib-1.9.1/taglib/Headers
3.Use it, very simple function to get media tags from files, in this example artist and title of track:
#include <fileref.h>
#include <tag.h>
QString gettags(QString mediafile){
QString string;
TagLib::FileRef file(mediafile.toUtf8());
TagLib::String artist_string = file.tag()->artist();
TagLib::String title_string = file.tag()->title();
QString artist = QString::fromStdWString(artist_string.toWString());
QString title = QString::fromStdWString(title_string.toWString());
string = artist + " - " + title;
return string;
}
For the current QT/OSX, use this project file snippet (change paths for your system)
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.11
LIBS += -L/Users/sir/prg.qt/TuneMerge/taglib-1.11.1/taglib/ -ltag -lz
INCLUDEPATH += /Users/sir/prg.qt/TuneMerge/taglib-1.11.1/
INCLUDEPATH += /Users/sir/prg.qt/TuneMerge/taglib-1.11.1/taglib/
INCLUDEPATH += /Users/sir/prg.qt/TuneMerge/taglib-1.11.1/taglib/toolkit/
DEPENDPATH += /Users/sir/prg.qt/TuneMerge/taglib-1.11.1/taglib

How it's better to add generatable sources files to qmake project?

There is somefile.h.in and script somefile.h.pl which generates number of files like "somefile.h.gen" or "somefile_other.cpp.gen2".
How to add source generation phase in qmake? In plain Makefile I'd just put things like
somefile.o: somefile.cpp somefile.h somefile.h.gen
...
soemfile.h.gen: somefile.h.in somefile.h.pl
./somefile.h.pl < somefile.h.in # writes somefile.h.gen and friends
I need to use QMAKE_EXTRA_COMPILERS feature:
PREPROCESS_FILES = somefile.h.in
preprocess.name = Generate various files based on somefile.h.in
preprocess.input = PREPROCESS_FILES
preprocess.output = ${QMAKE_FILE_BASE}.gen
preprocess.commands = perl $$PWD/somefile.h.pl $$PWD/somefile.h.in
preprocess.CONFIG += no_link
QMAKE_EXTRA_COMPILERS += preprocess
PRE_TARGETDEPS += somefile.h.gen

Resources