1

I'm building Syslinux and there is one specific directory that I would like a different CC for. Instead of patching the Makefile, I can't I just invoke make with special arguments for that file? I haven't figured out how to do this.

When I just run make normally, this last lines are:

make -r -C lzo SRC="/syslinux-6.03/lzo" OBJ="/syslinux-6.03/bios/lzo" \ -f /syslinux-6.03/lzo/Makefile all make[3]: Entering directory '/syslinux-6.03/bios/lzo' gcc -o prepcore prepcore.o lzo.a 

But if I cd into bios/lzo and run make prepcore, it doesn't work, probably because it needs some environment from the parent directory Makefiles. The error message is:

make: Entering directory '/syslinux-6.03/lzo' /syslinux-6.03/lzo/Makefile:14: /build.mk: No such file or directory make: *** No rule to make target '/build.mk'. Stop. make: Leaving directory '/syslinux-6.03/lzo' 

So my question is, what is the correct way of telling make "for the current directory tree, find a target for <file> and make it"?

4
  • The answer to your question is, you have to find the name of the target and pass it to make. Then make will build that target. But, you already know that since you describe running make prepcore; here prepcore is the name of a target you've asked make to build. So I don't understand your question. Commented Mar 14, 2015 at 13:55
  • @MadScientist like I said, it doesn't work. It tries to link without lzo.a, which results in unresolved symbols. Commented Mar 14, 2015 at 15:15
  • What you asked is how to build a specific target from the command line. I told you how you do that. What you appear to really want to know is, "which target in my makefile environment should I invoke to get the link to work right", which of course we cannot tell you because we don't have your makefiles so we don't know what targets exist or what they do. You'll have to look at your makefiles and find the right target, then run make giving that target name. Commented Mar 14, 2015 at 16:56
  • syslinux makefile needs the variables SRC, OBJ and MAKEDIR. try make -r -C lzo SRC="/path/to/syslinux-6.03/lzo" OBJ="/path/to/syslinux-6.03/bios/lzo" MAKEDIR="/path/to/syslinux-6.03/mk" -f /path/to/syslinux-6.03/lzo/Makefile prepcore (cwd should be /path/to/syslinux-6.03) Commented Jun 17, 2015 at 15:39

1 Answer 1

1

Here is how to do this with remake. You run "remake" and set a breakpoint on the target you want to change. Then use the remake's "write" command to write the commands it would run to a shell script. Then you can edit that shell script to adjust the commands it runs for changes you want. The shell script will have a change directory command in it that you probably want to comment out.

Here is an example:

$ rm job.o $ remake -X job.o GNU Make 4.1+dbg0.91 Built for x86_64-unknown-linux-gnu ... -> (/src/external-vcs/github/remake/Makefile:621) Makefile: Makefile.in config.status remake<0> s ... # Step until job.o remake<9> s Must remake target 'job.o'. Makefile:781: update target 'job.o' due to: job.c /usr/include/stdc-predef.h ... ##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> depbase=`echo job.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\ gcc -DLOCALEDIR=\"/usr/local/share/locale\" -DLIBDIR=\"/usr/local/lib\" -DINCLUDEDIR=\"/usr/local/include\" -DHAVE_CONFIG_H -I. -DMAKE_MAINTAINER_MODE -pthread -I/usr/include/guile/2.0 -Wall -Wextra -Wdeclaration-after-statement -Wshadow -Wpointer-arith -Wbad-function-cast -g -O2 -MT job.o -MD -MP -MF $depbase.Tpo -c -o job.o job.c &&\ mv -f $depbase.Tpo $depbase.Po ##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ++ (/src/external-vcs/github/remake/.deps/job.Po:1) job.o remake<10> w File "/tmp/job.o.sh" written. remake<11> 

Now look at the file it wrote:

#!/bin/bash #/tmp/github/remake/.deps/job.Po:1 #cd /tmp/remake depbase=`echo job.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\ gcc -DLOCALEDIR=\"/usr/local/share/locale\" -DLIBDIR=\"/usr/local/lib\" -DINCLUDEDIR=\"/usr/local/include\" -DHAVE_CONFIG_H -I. -DMAKE_MAINTAINER_MODE -pthread -I/usr/include/guile/2.0 -Wall -Wextra -Wdeclaration-after-statement -Wshadow -Wpointer-arith -Wbad-function-cast -g -O2 -MT job.o -MD -MP -MF $depbase.Tpo -c -o job.o job.c &&\ mv -f $depbase.Tpo $depbase.Po 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.