QT Plugins, target build order AND BUILT_SOURCES

View: New views
3 Messages — Rating Filter:   Alert me  

QT Plugins, target build order AND BUILT_SOURCES

by Andre Heine :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello all,

I've a litte problem to build subproject correctly...

In my Makefile.am are one "bin_programs" and one "lib_LTLIBRARIES".

The plugin is a shared linked library, so that it can loaded into QT's
designer. The program should test all plugin widgets, features etc...

"bin_programs" has some UI files more, that UI's needed the plugin (.so)

All other source and header files are shared, so all files are in one  
directory...

And that is the problem, the "uic" needs the plugin to load at runtime. The
"uic" will load the plugin via dlopen, so I must build the lib first.

In my Makefile.am I call the "uic" with an extra switch (-L) to add the
libpath to my shared object:

$(UIC) -L $(top_builddir)/dvplugins/.libs

The "uic" will load the lib and generate some include defines into the qt
class files. But when uic  can't load the plugin my header is broken;()

Our source are bad organized, because there some file with ".hpp" and some
with ".h". So I must add some extra suffix rules...

When I call "make libCustomPlugin.la && make qplugin" all things works
correctly.

"make all" can't build the project...

I had gamble a little with "BUILT_SOURCES", but I can't resolve
the "cycles"...


Any hints?


Best regards

Andre


System: SuSE 10.2
                autoconf-2.60-21
                automake-1.9.6-35

------------------------ Makefile.am -----------------
AUTOMAKE_OPTIONS = foreign 1.4 gnu

INCLUDES = -I$(top_srcdir)/. -I$(top_srcdir)/src -I$(QTDIR)/include \
        -I$(QTDIR)/mkspecs/linux-g++ -I$(top_srcdir)/../libdvutil/include \
        -I$(top_srcdir)/../libsettings/include/ -I.

MOC      = $(QTDIR)/bin/moc
UIC      = $(QTDIR)/bin/uic

# global DV
ISAMFLAGS = -DREALLY_DB_ONLY -DITOOLS -DDB_ONLY -DLATIN1KONV
                     -DDVPLUGINS -DDAVIDX

bin_PROGRAMS    = qplugin
lib_LTLIBRARIES = libCustomPlugin.la

DVHEADER  =
DVSOURCE  =
DVXSOURCE =
DVXHEADER =

# only qplugin, it got the dynamic widgets from the plugin
FORMS_TEST      = Test.ui dialogimplform.ui

# all
FORMS           = dialogbase.ui
FORMS_HPP   = consdatum_dlg.ui adt_wizard.ui


MOC_HEADERS     = DialogImpl.h \
                  messagebox.hpp \
                  lineedit.hpp \
                  consdatum_dlg_impl.hpp \
                  datum_le.hpp

SHARED_SRC      = messagebox.cpp DialogImpl.cpp \
                          lineedit.cpp \
                          isam2x_str.cpp \
                          x2isam_str.cpp \
                          setwindow.cpp \
                          custom_event.cpp \
                          consdatum_dlg_impl.cpp \
                          datum_le.cpp

SHARED_INC      = isam2x_str.hpp \
                          x2isam_str.hpp \
                          setwindow.hpp \
                          custom_event.hpp


qplugindir = $(prefix)/include
qplugin_SOURCES         = $(SHARED_SRC)\
                          qplugin.cpp

qplugin_HEADERS         = $(SHARED_INC) $(MOC_HEADERS)


MOCdir = $(prefix)/include
FORMHEADERS     = $(FORMS:.ui=.h) $(FORMS_HPP:.ui=.hpp)
MOC_CC                = $(FORMS:.ui=.moc.cpp) $(MOC_HEADERS:.h=.moc.cpp) \
                    $(MOC_HEADERS:.hpp=.moc.cpp) $(FORMS_HPP:.ui=.moc.cpp)

MOC_CC_QP = $(FORMS_TEST:.ui=.moc.cpp)
UIC_CC_QP   = $(FORMS_TEST:.ui=.uic.cpp)

UIC_CC         = $(FORMS:.ui=.uic.cpp)
UIC_CXX        = $(FORMS_HPP:.ui=.uic.cxx)

nodist_qplugin_SOURCES = $(UIC_CC) $(MOC_CC) $(UIC_CXX) $(MOC_CC_QP)
$(UIC_CC_QP)


qplugin_LDFLAGS         = $(all_libraries)
$(SUBLIBS) -L$(QTDIR)/lib -L/usr/X11R6/lib -lqt-mt \
                         -lqui -lXext -lX11 -lm -lpthread \
                         -ldvutil $(top_builddir)/src/libISAMCore.la \
                         $(BOOST_ROOT)/lib/libboost_regex.a \
                         -export-dynamic
# $(DVSTATICS_ROOT)/lib/libsettings.a

qplugin_LDADD           =
qplugin_CPPFLAGS        = $(ISAMFLAGS)
qplugin_CFLAGS          
= -pipe -Wall  -Wno-write-strings -Wno-parentheses -Werror -O2 \
        -D_REENTRANT  -DQT_THREAD_SUPPORT -DQT_SHARED

qplugin_CXXFLAGS        
= -pipe -Wall  -Wno-write-strings -Wno-parentheses -Werror -O2 \
        -D_REENTRANT  -DQT_THREAD_SUPPORT -DQT_SHARED



# This line ensures that generated moc_*.cpp and resources.cpp files are
# deleted when we make clean.
# CLEANFILES = $(filter moc_%.cpp, $(qplugin_SOURCES))

# This is to ensure the myapp.h file is distributed in your myapp-0.1.tar.gz
# I also have a resources.qrc I need to include. The png is used in myapp.


libCustomPlugin_ladir   = $(exec_prefix)/include
#libCustomPlugin_la_MOCdir       = $(exec_prefix)/include
libCustomPlugin_la_SOURCES   = $(SHARED_SRC) CustomPlugin.cpp
#dialogbase.moc.cpp dialogbase.uic.cpp
#libCustomPlugin_la_MOC_HEADERS  = DialogImpl.h
libCustomPlugin_la_HEADERS   = $(SHARED_INC) $(MOC_HEADERS) CustomPlugin.h
# dialogbase.h

nodist_libCustomPlugin_la_SOURCES = $(UIC_CC) $(MOC_CC) $(UIC_CXX)

libCustomPlugin_la_CFLAGS  
= -pipe -Wall -Wno-pointer-sign -Wno-parentheses -Werror -O2 \
        -D_REENTRANT  -DQT_THREAD_SUPPORT -DQT_SHARED
libCustomPlugin_la_CXXFLAGS
= -pipe -Wall -Wno-write-strings -Wno-parentheses -Werror -O2 \
        -D_REENTRANT  -DQT_THREAD_SUPPORT -DQT_SHARED

#-Wl,-soname,libcustomplugin.so.0 -Wl,-rpath,/home/ahe/david/plugins/widgets

libCustomPlugin_la_CPPFLAGS = $(ISAMFLAGS)
libCustomPlugin_la_LDFLAGS = $(all_libraries)
$(SUBLIBS) -L$(QTDIR)/lib -L/usr/X11R6/lib -lqt-mt -lqui -lXext -lX11 -lm -lpthread
\
        -ldvutil $(top_builddir)/src/libISAMCore.la
$(BOOST_ROOT)/lib/libboost_regex.a \
        -lsettings \
        -module -release 1.0 -version-info 1:1:0 -shared
# -export-dynamic -rdynamic
# -Wl,-rpath,'$$ORIGIN'

libCustomPlugin_la_LIBADD   = -lfbn

# QT specialslibCustomPlugin_la_HEADERSlibCustomPlugin_la_HEADERS
noinst_HEADERS = $(MOC_HEADERS) $(qplugin_HEADERS)
$(libCustomPlugin_la_HEADERS)
BUILT_SOURCES = $(FORMHEADERS) $(UIC_CC) $(MOC_CC) $(UIC_CXX) \
                  $(FORMS_TEST:.ui=.h) $(MOC_CC_QP) $(UIC_CC_QP)
EXTRA_DIST = $(nodist_qplugin_SOURCES:moc_%.cpp=%.h) $(FORMS) $(FORMS_HPP) \
                  $(nodist_libCustomPlugin_la_SOURCES:moc_%.cpp=%.h)
CLEANFILES = $(BUILT_SOURCES)


#echo "@($@) *($*) <($<) %($%)"
# echo "cpp@($@) *($*) <($<) %($%) NO("$(nodist_qplugin_SOURCES)")"
.ui.h: $(FORMS)
        $(UIC) -L $(top_builddir)/dvplugins/.libs -o $@ $<

.ui.hpp: $(FORMS_HPP)
        $(UIC) -o $@ $<

.h.moc.cpp:
        $(MOC) -o $@ $<

.hpp.moc.cpp:
        $(MOC) -o $@ $<

# $(FORMS:.ui=.h) $(FORMS_HPP:.ui=.hpp)

.ui.uic.cpp: $(FORMS)
        $(UIC) -o $@ -impl $*.h $(<:.h=.ui)

.ui.uic.cxx: $(FORMS_HPP)
        $(UIC) -o $@ -impl $*.hpp $(<:.hpp=.ui)

SUFFIXES = .h .ui .moc.cpp .uic.cpp .hpp .uic.cxx





--
Barometer, n.:
        An ingenious instrument which indicates what kind of weather we
are having.
                -- Ambrose Bierce, "The Devil's Dictionary"



Re: QT Plugins, target build order AND BUILT_SOURCES

by Andre Heine :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello all,

the only idea at this time is to add another subproject and
put the special test forms in there...

I must copy some other source files or use in XXX_SOURCES = ../src/files.cpp
(ugly??)

The build order can modified via SUBDIRS in the toplevel Makefile.am...

Greetings

andre


Am Donnerstag, 29. Oktober 2009 15:02 schrieb Andre Heine:

> Hello all,
>
> I've a litte problem to build subproject correctly...
>
> In my Makefile.am are one "bin_programs" and one "lib_LTLIBRARIES".
>
> The plugin is a shared linked library, so that it can loaded into QT's
> designer. The program should test all plugin widgets, features etc...
>
> "bin_programs" has some UI files more, that UI's needed the plugin (.so)
>
> All other source and header files are shared, so all files are in one
> directory...
>
> And that is the problem, the "uic" needs the plugin to load at runtime. The
> "uic" will load the plugin via dlopen, so I must build the lib first.
>
> In my Makefile.am I call the "uic" with an extra switch (-L) to add the
> libpath to my shared object:
>
> $(UIC) -L $(top_builddir)/dvplugins/.libs
>
> The "uic" will load the lib and generate some include defines into the qt
> class files. But when uic  can't load the plugin my header is broken;()
>
> Our source are bad organized, because there some file with ".hpp" and some
> with ".h". So I must add some extra suffix rules...
>
> When I call "make libCustomPlugin.la && make qplugin" all things works
> correctly.
>
> "make all" can't build the project...
>
> I had gamble a little with "BUILT_SOURCES", but I can't resolve
> the "cycles"...
>
>
> Any hints?
>
>
> Best regards
>
> Andre
>
>
> System: SuSE 10.2
> autoconf-2.60-21
> automake-1.9.6-35
>
> ------------------------ Makefile.am -----------------
> AUTOMAKE_OPTIONS = foreign 1.4 gnu
>
> INCLUDES = -I$(top_srcdir)/. -I$(top_srcdir)/src -I$(QTDIR)/include \
> -I$(QTDIR)/mkspecs/linux-g++ -I$(top_srcdir)/../libdvutil/include \
> -I$(top_srcdir)/../libsettings/include/ -I.
>
> MOC      = $(QTDIR)/bin/moc
> UIC      = $(QTDIR)/bin/uic
>
> # global DV
> ISAMFLAGS = -DREALLY_DB_ONLY -DITOOLS -DDB_ONLY -DLATIN1KONV
>                      -DDVPLUGINS -DDAVIDX
>
> bin_PROGRAMS    = qplugin
> lib_LTLIBRARIES = libCustomPlugin.la
>
> DVHEADER  =
> DVSOURCE  =
> DVXSOURCE =
> DVXHEADER =
>
> # only qplugin, it got the dynamic widgets from the plugin
> FORMS_TEST      = Test.ui dialogimplform.ui
>
> # all
> FORMS           = dialogbase.ui
> FORMS_HPP   = consdatum_dlg.ui adt_wizard.ui
>
>
> MOC_HEADERS     = DialogImpl.h \
>                   messagebox.hpp \
>                   lineedit.hpp \
>                   consdatum_dlg_impl.hpp \
>                   datum_le.hpp
>
> SHARED_SRC      = messagebox.cpp DialogImpl.cpp \
>                           lineedit.cpp \
>                           isam2x_str.cpp \
>                           x2isam_str.cpp \
>                           setwindow.cpp \
>                           custom_event.cpp \
>                           consdatum_dlg_impl.cpp \
>                           datum_le.cpp
>
> SHARED_INC      = isam2x_str.hpp \
>                           x2isam_str.hpp \
>                           setwindow.hpp \
>                           custom_event.hpp
>
>
> qplugindir = $(prefix)/include
> qplugin_SOURCES         = $(SHARED_SRC)\
>                           qplugin.cpp
>
> qplugin_HEADERS         = $(SHARED_INC) $(MOC_HEADERS)
>
>
> MOCdir = $(prefix)/include
> FORMHEADERS     = $(FORMS:.ui=.h) $(FORMS_HPP:.ui=.hpp)
> MOC_CC                = $(FORMS:.ui=.moc.cpp) $(MOC_HEADERS:.h=.moc.cpp) \
>                     $(MOC_HEADERS:.hpp=.moc.cpp) $(FORMS_HPP:.ui=.moc.cpp)
>
> MOC_CC_QP = $(FORMS_TEST:.ui=.moc.cpp)
> UIC_CC_QP   = $(FORMS_TEST:.ui=.uic.cpp)
>
> UIC_CC         = $(FORMS:.ui=.uic.cpp)
> UIC_CXX        = $(FORMS_HPP:.ui=.uic.cxx)
>
> nodist_qplugin_SOURCES = $(UIC_CC) $(MOC_CC) $(UIC_CXX) $(MOC_CC_QP)
> $(UIC_CC_QP)
>
>
> qplugin_LDFLAGS         = $(all_libraries)
> $(SUBLIBS) -L$(QTDIR)/lib -L/usr/X11R6/lib -lqt-mt \
>                          -lqui -lXext -lX11 -lm -lpthread \
>                          -ldvutil $(top_builddir)/src/libISAMCore.la \
>                          $(BOOST_ROOT)/lib/libboost_regex.a \
>                          -export-dynamic
> # $(DVSTATICS_ROOT)/lib/libsettings.a
>
> qplugin_LDADD           =
> qplugin_CPPFLAGS        = $(ISAMFLAGS)
> qplugin_CFLAGS
> = -pipe -Wall  -Wno-write-strings -Wno-parentheses -Werror -O2 \
>         -D_REENTRANT  -DQT_THREAD_SUPPORT -DQT_SHARED
>
> qplugin_CXXFLAGS
> = -pipe -Wall  -Wno-write-strings -Wno-parentheses -Werror -O2 \
>         -D_REENTRANT  -DQT_THREAD_SUPPORT -DQT_SHARED
>
>
>
> # This line ensures that generated moc_*.cpp and resources.cpp files are
> # deleted when we make clean.
> # CLEANFILES = $(filter moc_%.cpp, $(qplugin_SOURCES))
>
> # This is to ensure the myapp.h file is distributed in your
> myapp-0.1.tar.gz # I also have a resources.qrc I need to include. The png
> is used in myapp.
>
>
> libCustomPlugin_ladir   = $(exec_prefix)/include
> #libCustomPlugin_la_MOCdir       = $(exec_prefix)/include
> libCustomPlugin_la_SOURCES   = $(SHARED_SRC) CustomPlugin.cpp
> #dialogbase.moc.cpp dialogbase.uic.cpp
> #libCustomPlugin_la_MOC_HEADERS  = DialogImpl.h
> libCustomPlugin_la_HEADERS   = $(SHARED_INC) $(MOC_HEADERS) CustomPlugin.h
> # dialogbase.h
>
> nodist_libCustomPlugin_la_SOURCES = $(UIC_CC) $(MOC_CC) $(UIC_CXX)
>
> libCustomPlugin_la_CFLAGS
> = -pipe -Wall -Wno-pointer-sign -Wno-parentheses -Werror -O2 \
>         -D_REENTRANT  -DQT_THREAD_SUPPORT -DQT_SHARED
> libCustomPlugin_la_CXXFLAGS
> = -pipe -Wall -Wno-write-strings -Wno-parentheses -Werror -O2 \
>         -D_REENTRANT  -DQT_THREAD_SUPPORT -DQT_SHARED
>
> #-Wl,-soname,libcustomplugin.so.0
> -Wl,-rpath,/home/ahe/david/plugins/widgets
>
> libCustomPlugin_la_CPPFLAGS = $(ISAMFLAGS)
> libCustomPlugin_la_LDFLAGS = $(all_libraries)
> $(SUBLIBS) -L$(QTDIR)/lib -L/usr/X11R6/lib -lqt-mt -lqui -lXext -lX11 -lm
> -lpthread \
> -ldvutil $(top_builddir)/src/libISAMCore.la
> $(BOOST_ROOT)/lib/libboost_regex.a \
> -lsettings \
> -module -release 1.0 -version-info 1:1:0 -shared
> # -export-dynamic -rdynamic
> # -Wl,-rpath,'$$ORIGIN'
>
> libCustomPlugin_la_LIBADD   = -lfbn
>
> # QT specialslibCustomPlugin_la_HEADERSlibCustomPlugin_la_HEADERS
> noinst_HEADERS = $(MOC_HEADERS) $(qplugin_HEADERS)
> $(libCustomPlugin_la_HEADERS)
> BUILT_SOURCES = $(FORMHEADERS) $(UIC_CC) $(MOC_CC) $(UIC_CXX) \
>                   $(FORMS_TEST:.ui=.h) $(MOC_CC_QP) $(UIC_CC_QP)
> EXTRA_DIST = $(nodist_qplugin_SOURCES:moc_%.cpp=%.h) $(FORMS) $(FORMS_HPP)
> \ $(nodist_libCustomPlugin_la_SOURCES:moc_%.cpp=%.h) CLEANFILES =
> $(BUILT_SOURCES)
>
>
> #echo "@($@) *($*) <($<) %($%)"
> # echo "cpp@($@) *($*) <($<) %($%) NO("$(nodist_qplugin_SOURCES)")"
> .ui.h: $(FORMS)
> $(UIC) -L $(top_builddir)/dvplugins/.libs -o $@ $<
>
> .ui.hpp: $(FORMS_HPP)
> $(UIC) -o $@ $<
>
> .h.moc.cpp:
> $(MOC) -o $@ $<
>
> .hpp.moc.cpp:
> $(MOC) -o $@ $<
>
> # $(FORMS:.ui=.h) $(FORMS_HPP:.ui=.hpp)
>
> .ui.uic.cpp: $(FORMS)
> $(UIC) -o $@ -impl $*.h $(<:.h=.ui)
>
> .ui.uic.cxx: $(FORMS_HPP)
> $(UIC) -o $@ -impl $*.hpp $(<:.hpp=.ui)
>
> SUFFIXES = .h .ui .moc.cpp .uic.cpp .hpp .uic.cxx

--
Concept, n.:
        Any "idea" for which an outside consultant billed you more than
$25,000.



Re: QT Plugins, target build order AND BUILT_SOURCES

by Ralf Wildenhues :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Andre,

Your example is pretty complex, and doesn't make the problem obvious.
Merely adding libCustomPlugin.la to BUILT_SOURCES doesn't seem to
introduce a cycle in the build dependencies, at least from a 'make -n'
in an example package that has this Makefile.am but no other files.

It may help to see a reduced example package that still has the cycle.

Cheers,
Ralf