LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Need Help Writing a Make Rule (https://www.linuxquestions.org/questions/programming-9/need-help-writing-a-make-rule-644737/)

binarybob0001 05-25-2008 10:13 PM

Need Help Writing a Make Rule
 
Even if you don't know how to use automake, you may still be able to answer this question. Here is a snippet from a Makefile generated from qmake.
Code:

.ui/qmake_image_collection.cpp: images/filenew \
                images/fileopen \
                images/filesave \
                images/print \
                images/undo \
                images/redo \
                images/editcut \
                images/editcopy \
                images/editpaste \
                images/searchfind \
                images/options.png \
                images/designer_widgetstack.png \
                images/designer_d_table.png \
                images/designer_d_iconview.png
        $(UIC)  -embed colortool images/filenew images/fileopen images/filesave
images/print images/undo images/redo images/editcut images/editcopy images/editp
aste images/searchfind images/options.png images/designer_widgetstack.png images
/designer_d_table.png images/designer_d_iconview.png -o .ui/qmake_image_collecti
on.cpp

I'm trying to get automake to do the same thing. Here's the complete Makefile.am which contains all the rules.
Code:

bin_PROGRAMS = colortool

%.h: %.ui
        uic -o $@ $<
%.cpp: %.ui
        uic -o $@ -impl $*.h $<
# This rule lets GNU make create any moc_*.cpp from the equivalent *.h
# You have one .h file, it's called myapp.h. Therefore, here I list
# its mocced name, moc_myapp.cpp.
moc_%.cpp: %.h
        moc $< -o $@
# Turn .png files into a single .cpp files, but
# This rule doesn't work. Why?
%.cpp: %.png
        uic -embed colortool $? -o $@

# Generate image_collection.cpp from these files
image_collection.cpp: images/designer_widgetstack.png \
        images/designer_d_table.png \
        images/designer_d_iconview.png

mainwinform_UI = \
        mainwinform.h \
        mainwinform.cpp

mainwinform.h: mainwinform.ui
mainwinform.cpp: mainwinform.ui mainwinform.h

colortool_SOURCES = main.cpp mainwinform.ui.h image_collection.cpp
noinst_HEADERS = mainwinform.h
nodist_colortool_SOURCES = moc_mainwinform.cpp $(mainwinform_UI)
BUILT_SOURCES=image_collection.cpp $(mainwinform_UI)

# set the include path found by configure
INCLUDES= $(all_includes) $(QTDIR)/include

# the library search path.
colortool_LDFLAGS = $(all_libraries) -L$(QTDIR)/lib

CLEANFILES = $(nodist_colortool_SOURCES)

Uic never runs to make the image_collection.cpp file. What is wrong with my rule?

theriddle 05-27-2008 09:15 PM

It looks like Make isn't matching the rule to the pattern-rule. Try setting the command directly to the target instead of using a generic rule.


All times are GMT -5. The time now is 02:35 PM.