Merging My Standard Makefile with a Qmake-generated Makefile?



  • Right now I have two makefiles, one that I have created myself, the other was generated using qmake. However, I need to leave just one (the one I created manually) and adjust it to use qmake for compiling my source code. Does anybody know how can I do this?

    Here's my Makefile:

    include $(TOPDIR)/rules.mk

    PKG_NAME:=cloud
    PKG_RELEASE:=1

    PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)

    include $(INCLUDE_DIR)/package.mk

    define Package/cloud
    SECTION:=Cloud
    CATEGORY:=cloud
    TITLE:=Cloud Package
    DEPENDS:=+qt4 +qt4-gui +qt4-network
    endef

    define Package/cloud/description
    Cloud Package
    endef

    define Build/Prepare
    mkdir -p $(PKG_BUILD_DIR)
    $(CP) ./src/* $(PKG_BUILD_DIR)/

    endef

    define Build/Configure
    endef

    define Build/Compile
    $(MAKE) -C $(PKG_BUILD_DIR)
    CC="$(TARGET_CC)"
    CFLAGS="$(TARGET_CFLAGS) -Wall"
    LDFLAGS="$(TARGET_LDFLAGS)"
    endef

    define Package/cloud/install
    $(INSTALL_DIR) $(1)/usr/sbin
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/exec$(1)/usr/sbin/

    endef
    $(eval $(call BuildPackage,cloud))


  • Moderators

    You can use MAKEFILE to force qmake to use another file name for the generated Makefile, like this (in your .pro file):

    MAKEFILE=Makefile_generated
    

    That can help you in working with your Makefile and the generated one without the danger of overwriting them. Alternatively, you can ditch qmake completely and put all UIC, MOC, RCC and C++ call there. This, however, is tedious and will make the maintenance harder.



  • What about within the Makefile? Is there a way that I could execute "qmake -makefile" from my Makefile? I think it's possible but I don't know how can I do it syntax-wise.


  • Moderators

    @Jesse-James said:

    What about within the Makefile? Is there a way that I could execute "qmake -makefile" from my Makefile? I think it's possible but I don't know how can I do it syntax-wise.

    Yes, that is also possible.

    I can't check myself right now, but something like that should work:

    # Call qmake from custom makefile
    qmake MAKEFILE=myTempMakeFile myProFile.pro
    # Build the project
    make -j 8
    # Remove the generated file (if you wish)
    rm myTempMakeFile
    

    You may need to enclose MAKEFILE=myTempMakeFile in quotes, please test. Also, with that kind of stuff you need to be careful and test separately for each platform (especially Windows) as the syntax might be different there.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.