[PyQt] How to insert literal $ in QMAKE_LINK_SHLIB_CMD sip spec files

Albert Chin pykde at mlists.thewrittenword.com
Wed Dec 23 16:15:56 GMT 2009


On Wed, Dec 23, 2009 at 10:03:32AM +0000, Phil Thompson wrote:
> On Tue, 22 Dec 2009 20:54:22 -0600, Albert Chin
> <pykde at mlists.thewrittenword.com> wrote:
> > How do I insert a literal $ in QMAKE_LINK_SHLIB_CMD for sip spec files?
> > What I really want is the following for specs/aix-g++:
> >   QMAKE_LINK_SHLIB_CMD    = rm -f objects.o; \
> >           ld -r -o objects.o -bnogc $(OFILES); \
> >           rm -f lib.exp; /usr/ccs/bin/nm -BCpg objects.o | \
> >           awk '{ if ((($$2 == "T") || ($$2 == "D") || ($$2 == "B")) && \
> >           (substr($$3,1,1) != ".")) { print $$3 } }' | sort -u >lib.exp;
> \
> >           g++ -shared -Wl,-bE:lib.exp -o $(TARGET) $(LFLAGS) \
> >           objects.o $(LIBS); rm objects.o
> 
> Try $$LITERAL_DOLLAR

Then how do I use get $$2 in the awk expression?
$$LITERAL_DOLLAR$$LITERAL_DOLLAR2? I don't think the second
$$LITERAL_DOLLAR2 will work.

Anyway, sip doesn't seem to support QMAKE_LINK_SHLIB_CMD. So, I created
the attached patch.

With this patch, and you suggestion of $$LITERAL_DOLLAR, and
QMAKE_LINK_SHLIB_CMD set to:
  QMAKE_LINK_SHLIB_CMD    = rm -f objects.o; \
ld -r -o objects.o -bnogc $$LITERAL_DOLLAR{OFILES}; \
rm -f lib.exp; /usr/ccs/bin/nm -BCpg objects.o | \
awk '{ if ((($$LITERAL_DOLLAR$$LITERAL_DOLLAR2 == "T") || ($$LITERAL_DOLLAR$$LITERAL_DOLLAR2 == "D") || ($$LITERAL_DOLLAR$$LITERAL_DOLLAR2 == "B")) && \
(substr($$LITERAL_DOLLAR$$LITERAL_DOLLAR3,1,1) != ".")) { print $$LITERAL_DOLLAR$$LITERAL_DOLLAR3 } }' | sort -u >lib.exp; \
g++ -shared -Wl,-bE:lib.exp -o $$LITERAL_DOLLAR{TARGET} \
$$LITERAL_DOLLAR{LFLAGS} objects.o $$LITERAL_DOLLAR{LIBS}; \
rm objects.o

I get the following in siplib/Makefile:
$(TARGET): $(OFILES)
        @echo '#!' >sip.exp; \
         echo 'initsip' >>sip.exp
        rm -f objects.o; ld -r -o objects.o -bnogc LITERAL_DOLLAR{OFILES}; rm -f lib.exp; /usr/ccs/bin/nm -BCpg objects.o | awk '{ if (((LITERAL_DOLLARLITERAL_DOLLAR2 == "T") || (LITERAL_DOLLARLITERAL_DOLLAR2 == "D") || (LITERAL_DOLLARLITERAL_DOLLAR2 == "B")) && (substr(LITERAL_DOLLARLITERAL_DOLLAR3,1,1) != ".")) { print LITERAL_DOLLARLITERAL_DOLLAR3 } }' | sort -u >lib.exp; g++ -shared -Wl,-bE:lib.exp -o LITERAL_DOLLAR{TARGET} LITERAL_DOLLAR{LFLAGS} objects.o LITERAL_DOLLAR{LIBS}; rm objects.o

If I use $${LITERAL_DOLLAR}, I get the following in siplib/Makefile:
$(TARGET): $(OFILES)
        @echo '#!' >sip.exp; \
         echo 'initsip' >>sip.exp
        rm -f objects.o; ld -r -o objects.o -bnogc ${OFILES}; rm -f lib.exp; /usr/ccs/bin/nm -BCpg objects.o | awk '{ if (((${LITERAL_DOLLAR}2 == "T") || (${LITERAL_DOLLAR}2 == "D") || (${LITERAL_DOLLAR}2 == "B")) && (substr(${LITERAL_DOLLAR}3,1,1) != ".")) { print ${LITERAL_DOLLAR}3 } }' | sort -u >lib.exp; g++ -shared -Wl,-bE:lib.exp -o ${TARGET} ${LFLAGS} objects.o ${LIBS}; rm objects.o

-- 
albert chin (china at thewrittenword.com)
-------------- next part --------------
Index: siputils.py
===================================================================
--- siputils.py.orig	2009-11-23 13:49:24.000000000 +0000
+++ siputils.py	2009-12-23 16:01:37.587779542 +0000
@@ -1586,7 +1600,12 @@
                         mfile.write("\t at echo '#!' >%s.exp" % self._target)
                         mfile.write("; \\\n\t echo '%s' >>%s.exp\n" % (self._entry_point, self._target))
 
-                mfile.write("\t$(LINK) $(LFLAGS) -o $(TARGET) $(OFILES) $(LIBS)\n")
+                link_shlib_cmd = self.optional_string("LINK_SHLIB_CMD")
+
+                if link_shlib_cmd:
+                        mfile.write("\t" + link_shlib_cmd + "\n")
+                else:
+                        mfile.write("\t$(LINK) $(LFLAGS) -o $(TARGET) $(OFILES) $(LIBS)\n")
 
     def generate_target_install(self, mfile):
         """Generate the install target.


More information about the PyQt mailing list