Given an empty file a.c and the following Makefile -
CC=gcc
l.a : l.a(a.o)
ranlib l.a
echo done
l.a(a.o) : a.c
clean::
rm -f l.a a.o
Running the command "make clean ; make" gives the following output -
rm -f l.a a.o
gcc -c -o a.o a.c
ar rv l.a a.o
a - a.o
ranlib l.a
echo done
done
Running the command "make clean ; make -j2" gives the following output -
rm -f l.a a.o
gcc -c -o a.o a.c
ar rv l.a a.o
a - a.o
Why does "make -j2" skip the commands listed under the first rule?
This occurs consistently on a 32-bit single processor system with gnu make 3.79.1
Does not occur on a 64-bit multi-core system with gnu make 3.81.
This is a very shortened example of a larger Makefile where I ran into the problem.
So, I made the example Makefile a bit more "complex" as follows -
AR := flock make.lock ar
RANLIB := flock make.lock ranlib
CC=gcc
l.a : l.a(a.o) l.a(b.o)
echo doing ranlib
$(RANLIB) l.a
echo done
l.a(a.o) : a.c
l.a(b.o) : b.c
clean::
rm -f l.a a.o b.o
The flock() trick is my invention (perhaps a re-invention) to serialize "ar".
Output -
> make clean ; make -j1
rm -f l.a a.o b.o
gcc -c -o a.o a.c
flock make.lock ar rv l.a a.o
ar: creating l.a
a - a.o
gcc -c -o b.o b.c
flock make.lock ar rv l.a b.o
a - b.o
echo doing ranlib
doing ranlib
flock make.lock ranlib l.a
echo done
done
rm a.o b.o
> make clean ; make -j2
rm -f l.a a.o b.o
gcc -c -o a.o a.c
gcc -c -o b.o b.c
flock make.lock ar rv l.a a.o
flock make.lock ar rv l.a b.o
ar: creating l.a
a - a.o
a - b.o
rm a.o b.o
Related
I would like to print a A4 Booklet on A3 paper on my mac os.
For a strange reason only A5 booklet is produced.
Here the command I use:
lpr -o sides=two-sided-long-edge -o fit-to-page -o PageSize=A3 -o InputSlot=Tray3 -o Duplex=DuplexNoTumble -o XRFinishing=Booklet -o XRFoldOption=BookletFold -o XRBookletLayout=true -o XRBookletSize=A3 file.pdf
natural-scaling option seems to produce nothing.
I solved my problem with this . The PageSize wan't correct (and I added also folding paper)
lpr -o sides=two-sided-long-edge -o fit-to-page -o PageSize=A4 -o InputSlot=Tray3 -o Duplex=DuplexNoTumble -o XRFinishing=Booklet -o XRFoldOption=BookletFold -o XRBookletLayout=true -o XRBookletSize=A3 -o XRFoldOption=BookletFold
I wish to submit my R package to CRAN that uses Rcpp and RcppGSL.My problem is that I am unable to build a package that pass R CMD check in win-builder. My understanding is that because the i386 package is built,but not installed and checked during R CMD check. The x64 package builds and passes the checks (when I run check with --no--multiarch). My understanding is a bit flawed, since I had limited time to get this windows build working at all for 64-bit.
This is the Makevars.win.gen
PKG_CPPFLAGS = $(GSL_CFLAGS) -I"$(LIB_GSL)/include" -I"$(LIB_GSL)/include/gsl" -I../inst/include -I../inst -Wall -Wno-unused-but-set-variable -Wno-long-long -Wno-sign-compare -Wno-deprecated -pedantic -pthread -fPIC -O2 -g
ARCH=x64
ifeq "$(WIN)" "64"
ARCH= i386
else
ARCH= x64
endif
RCPPGSL_LDFLAGS = `$(R_HOME)/bin/$(R_ARCH_BIN)/Rscript -e "RcppGSL:::LdFlags()"`
GRAPHM_OBJ = ./algorithm_ca.o ./algorithm_ext.o ./algorithm_fsol.o ./algorithm_iden.o ./algorithm_lp.o ./algorithm.o ./algorithm_path.o ./algorithm_qcv.o ./algorithm_rand.o ./algorithm_rank.o ./algorithm_umeyama.o ./algorithm_unif.o ./experiment.o ./graph.o ./hungarian.o ./rpc.o
GRAPHM_OBJ_REL = $(addprefix ./graphm/,$(GRAPHM_OBJ) )
PKG_LIBS = $(LDFLAGS) -L"$(LIB_GSL)\lib"$(R_ARCH_BIN) $(RCPPGSL_LDFLAGS) $(GSL_LIBS) -lgsl -lgslcblas
CXX ?= g++
SHVER= 1
VPATH= ./graphm:./graphm-0.52
SOURCES= graphmatch_rcpp.cpp RcppExports.cpp
OBJECTS= $(SOURCES:.cpp=.o) $(GRAPHM_OBJ_REL)
#all: $(SHLIB) $(OBJECTS)
$(SHLIB): $(OBJECTS)
#all: $(ALLFILES) ../inst/libgraphm.a
# cd graphm && $(MAKE)
# $(CXX) $(CXXFLAGS) $(OBJECTS) ../inst/libgraphm.a $(PKG_LIBS)
./experiment.o: experiment.cpp experiment.h
cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c experiment.cpp -o ./experiment.o
./rpc.o: rpc.cpp rpc.h
cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c rpc.cpp -o ./rpc.o
./graph.o: graph.cpp graph.h
cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c graph.cpp -o ./graph.o
./hungarian.o: hungarian.cpp hungarian.h
cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c hungarian.cpp -o ./hungarian.o
./algorithm.o: algorithm.cpp algorithm.h
cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c algorithm.cpp -o ./algorithm.o
#graph matching algorithms
./algorithm_ca.o: algorithm_ca.cpp algorithm_ca.h
cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c algorithm_ca.cpp -o ./algorithm_ca.o
./algorithm_path.o: algorithm_path.cpp algorithm_path.h
cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c algorithm_path.cpp -o ./algorithm_path.o
./algorithm_ext.o: algorithm_ext.cpp algorithm_ext.h
cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c algorithm_ext.cpp -o ./algorithm_ext.o
./algorithm_fsol.o: algorithm_fsol.cpp algorithm_fsol.h
cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c algorithm_fsol.cpp -o ./algorithm_fsol.o
./algorithm_iden.o: algorithm_iden.cpp algorithm_iden.h
cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c algorithm_iden.cpp -o ./algorithm_iden.o
./algorithm_lp.o: algorithm_lp.cpp algorithm_lp.h
cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c algorithm_lp.cpp -o ./algorithm_lp.o
./algorithm_qcv.o: algorithm_qcv.cpp algorithm_qcv.h
cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c algorithm_qcv.cpp -o ./algorithm_qcv.o
./algorithm_rand.o: algorithm_rand.cpp algorithm_rand.h
cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c algorithm_rand.cpp -o ./algorithm_rand.o
./algorithm_rank.o: algorithm_rank.cpp algorithm_rank.h
cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c algorithm_rank.cpp -o ./algorithm_rank.o
./algorithm_umeyama.o: algorithm_umeyama.cpp algorithm_umeyama.h
cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c algorithm_umeyama.cpp -o ./algorithm_umeyama.o
./algorithm_unif.o: algorithm_unif.cpp algorithm_unif.h
cd graphm && $(CXX) $(PKG_CPPFLAGS) -I"$(LIB_GSL)\include" -c algorithm_unif.cpp -o ./algorithm_unif.o
ALLOBJ: $(OBJECTS) $(GRAPHM_OBJ)
ALLFILES: $(OBJECTS) $(GRAPHM_OBJ_REL) ../inst/libgraphm.a
../inst/libgraphm.a: RcppExports.o $(GRAPHM_OBJ)
ar -rvs ../inst/libgraphm.a $(GRAPHM_OBJ_REL)
clean: cleana cleanb
cleana:
rm $(OBJECTS)
cleanb:
rm $(GRAPHM_OBJ_REL)
#.PHONY: all test clean
Incidentally, I am using this configure.win to pass the right flags to Makevars.win. But this is really unnecessary ,since I removed #GSL_LIBS# from Makevars.win.gen. Is this the reason i386 build is not installed during R CMD check?
ifeq "$(WIN)" "64"
R_ARCH_BIN="/x64"
else
R_ARCH_BIN="/i386"
endif
GSL_CFLAGS=`"${R_HOME}/bin$(R_ARCH_BIN)/Rscript.exe" -e "require(RcppGSL);RcppGSL:::CFlags()"`
GSL_LIBS=`"${R_HOME}/bin$(R_ARCH_BIN)/Rscript.exe" -e "require(RcppGSL);RcppGSL:::LdFlags()"`
sed -e "s|#GSL_LIBS#|${GSL_LIBS}|" \
-e "s|#GSL_CFLAGS#|${GSL_CFLAGS}|" \
src/Makevars.win.gen > src/Makevars.win
Any auxiliary information that is relevant for building a multi-arch R package that is dependent on pre-built windows libraries would be appreciated.
Your starting assumptions are wrong, methinks, and you may be making this too hard. I think it is worth stepping back:
In order to locally build multi-arch, you actually need a proper multi-arch setup locally. That would imply 32 and 64 bit builds of the GSL.
But you don't have to build locally -- you can submit your sources to both
win-builder
R Hub
both of which can run one or several Windows builds for you! I use them before every upload.
Also note that you don't necessarily need a Makevars.win all that complicated. My RcppZiggurat package (on CRAN) just has these two instructions:
PKG_CPPFLAGS = -I. -I../inst/include
## Use the R_HOME indirection to support installations of multiple R version
PKG_LIBS = $(shell "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" \
-e "RcppGSL:::LdFlags()")
(and I added the linebreak by hand).
Lastly, RcppGSL has four reverse Depends so you have four working examples to study. Eg mvabund does
## This assumes that the LIB_GSL variable points to working GSL libraries
PKG_CPPFLAGS=-std=c++0x -Wall -pedantic -I$(LIB_GSL)/include -I. -I../inst/include
PKG_LIBS=-L$(LIB_GSL)/lib -lgsl -lgslcblas
The existence of configure.win in the package source tree forces only the main architecture to be built, R CMD check fails with a message like
<package> is not installed for architecture -- i386
unless --no-multi-arch is present. Since CRAN building process for windows checks both architectures (i386, and x64) , R CMD checks fail during CRAN submission process, even though local R CMD checks with -no-multi-arch may be successful.
For my assignment, we are supposed to compile cpp2html.c to produce cpp2html.o. We are to do the same thing with lex.yy.c. lex.yy.c is created by the command flex cppscanner.l. Lastly, we're supposed to link the .o files together to produce an executable program named cpp2html.
My makefile is supposed to use gcc instead of g++, which I believe I am doing correctly. I've tried to get this specific makefile to work for this program for a few hours now, as the one for the g++ portion worked fine. When I submit this makefile, I'm told that "Your makefile does too much work when only cpp2html.c has been changed." I tried looking up this error, and was only able to find someone who had the error on the g++ portion; I tried adapting it, but it didn't work. I've tried changing the format of the makefile, I've tried altering the codes, but I just don't know what I'm doing wrong.
How can I alter my makefile to do what it needs to, without making it do "too much work"?
My makefile is as follows.
cpp2html: cpp2html.o lex.yy.o
gcc -g -DDEBUG cpp2html.o lex.yy.o
mv a.out cpp2html
cpp2html.o: cpp2html.c
gcc -g -DDEBUG -c cpp2html.c
flex cppscanner.l
lex.yy.o: lex.yy.c
gcc -g -c lex.yy.c
EDIT:
cpp2html: cpp2html.o lex.yy.o
gcc -g cpp2html.o lex.yy.o
gcc -g -DDEBUG cpp2html.o lex.yy.o -o cpp2html
cpp2html.o: cpp2html.c
gcc -g -c cpp2html.c
lex.yy.c: cppscanner.l
flex cppscanner.l
lex.yy.o: lex.yy.c
gcc -g -c lex.yy.c
This makefile should resolve this,
cpp2html: cpp2html.o lex.yy.o
gcc -g -DDEBUG cpp2html.o lex.yy.o -o cpp2html
cpp2html.o: cpp2html.c
gcc -g -DDEBUG -c cpp2html.c
lex.yy.o: lex.yy.c
gcc -g -c lex.yy.c
lex.yy.c: cppscanner.l
flex cppscanner.l -o lex.yy.c
Looking for help compiling my program below. I'm getting a "***Stop. no Targets." error when typing in limit.makefile in the compiler buffer. Ideas?
int main(int argc, char *argv[]) {
struct rlimit limit;
limit.rlim_cur = 60000;
limit.rlim_max = 60000;
if (setrlimit(RLIMIT_FSIZE, &limit) == -1){
perror("Error preventing core dump, errno=%d\n", errno);
exit(1);
}
else {
printf("The current core limit is %ll.\n", limit.rlim_cur);
printf("The core max limit is %ll.\n", limit.rlim_max);
exit(0);
}
if (getrlimit(RLIMIT_FSIZE, &limit) == -1){
printf("getlimit() failed with errno=%d\n", errno);
exit(1);
}
}
Compile command: make -k -f limit.makefile
This is what I type for the compiler buffer....still get the error though.
Makefile:
CC = /usr/bin/gcc
CFLAGS = -g -Wall -std=c99 -O2 -arch x86_64
Just tried that make -k -f myfile on an empty file and got your error.
If you just want it to work
CC= /usr/bin/gcc
CFLAGS = -g -Wall -std=c99 -O2 -arch x86_64
all: test.c
$(CC) $(CFLAGS) test.c
Note that the tab under all has to be a "real" tab.
I recommend you check out a makefile tutorial or just compile it from the command line.
gcc -g -Wall -std=c99 -O2 -arch x86_64 limit.c
BTW, not sure about that -arch flag. Not valid on my Linux box.
Try
CC = /usr/bin/gcc
CFLAGS = -g -Wall -std=c99 -O2 -arch x86_64
OBJ = limit.o
%.o: %.c
$(CC) -c -o $# $< $(CFLAGS)
EboMike's is more sophisticated, but here's a simpler one that is guaranteed to work for your one-file project:
CC = /usr/bin/gcc
CFLAGS = -g -Wall -std=c99 -O2 -arch x86_64
limit: limit.c
$(CC) $(CFLAGS) -o limit limit.c
You can run this with just make by itself.
You've not defined what the target to build is anywhere. You can do that on the command line, using the command
make -k -f limit.makefile limit
and the implicit rules of make will compile limit.c into limit. Alternatively define a target in your makefile,
CC = /usr/bin/gcc
CFLAGS = -g -Wall -std=c99 -O2 -arch x86_64
limit: limit.o
The first target will be built by default, and make knows how to compile *.c to *.o and link object files so everything else is automatic.
If you're curious, the default rules are equivalent to (in GNU make)
%.o:%.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $# $<
%:%.o
$(CC) $(LDFLAGS) -o $# $^ $(LDLIBS)
where $#, $< and $^ expand to the target, first prereq and all prereqs respectively, the percent signs are wildcards for the target name.
I am stumped as to why when I do a gnumake from the parent directory it behaves incorrectly, whereas, if I cd to the subdirectory and do gnumake it works correctly.
In the parent makefile, I have a rule like this:
.PHONY: zlib-1.2.5
zlib-1.2.5:
# echo Issuing $(MAKE) in $# ...
pushd zlib-1.2.5; make; popd
I also tried it like this for last line above with the same failure:
make -C zlib-1.2.5
Which gives different result than doing the same from the toplevel
pushd zlib-1.2.5; make; popd
There is a something from the parent makefile that is making its way into the subdirectory makefile and causing it to behave incorrectly, but I don't know how to find it.
The symptom I see is that the subdirectory config generated makefile rule for zlib misses the dependencies and I get this result going straight to the ar without generating the .o(s) first:
cd ~/src; make zlib-1.2.5
CPPFLAGS_AUTO = < >
Issuing make in zlib-1.2.5 ...
pushd zlib-1.2.5; make; popd
~/src/zlib-1.2.5 ~/src
make[1]: Entering directory `/disk2/user/src/zlib-1.2.5'
ar rc libz.a adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o
ar: adler32.o: No such file or directory
make[1]: *** [libz.a] Error 1
gcc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -o libz.so.1.2.5 adler32.lo compress.lo crc32.lo deflate.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo uncompr.lo zutil.lo -lc -L. libz.a
gcc: adler32.lo: No such file or directory
gcc: compress.lo: No such file or directory
gcc: crc32.lo: No such file or directory
gcc: deflate.lo: No such file or directory
[...]
make[1]: *** [libz.so.1.2.5] Error 1
make[1]: Target `all' not remade because of errors.
make[1]: Leaving directory `/disk2/user/src/zlib-1.2.5'
~/src
Versus from the zlib directory where it works correctly:
cd ~/src/zlib-1.2.5; make
gcc -O3 -D_LARGEFILE64_SOURCE=1 -c -o example.o example.c
gcc -O3 -D_LARGEFILE64_SOURCE=1 -c -o adler32.o adler32.c
gcc -O3 -D_LARGEFILE64_SOURCE=1 -c -o compress.o compress.c
gcc -O3 -D_LARGEFILE64_SOURCE=1 -c -o crc32.o crc32.c
[...]
gcc -O3 -D_LARGEFILE64_SOURCE=1 -c -o zutil.o zutil.c
ar rc libz.a adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o
(ranlib libz.a || true) >/dev/null 2>&1
gcc -O3 -D_LARGEFILE64_SOURCE=1 -o example example.o -L. libz.a
gcc -O3 -D_LARGEFILE64_SOURCE=1 -c -o minigzip.o minigzip.c
gcc -O3 -D_LARGEFILE64_SOURCE=1 -o minigzip minigzip.o -L. libz.a
mkdir objs 2>/dev/null || test -d objs
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DPIC -c -o objs/adler32.o adler32.c
mv objs/adler32.o adler32.lo
mkdir objs 2>/dev/null || test -d objs
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DPIC -c -o objs/compress.o compress.c
mv objs/compress.o compress.lo
[...]
mkdir objs 2>/dev/null || test -d objs
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DPIC -c -o objs/zutil.o zutil.c
mv objs/zutil.o zutil.lo
gcc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -o libz.so.1.2.5 adler32.lo compress.lo crc32.lo deflate.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo uncompr.lo zutil.lo -lc -L. libz.a
rm -f libz.so libz.so.1
ln -s libz.so.1.2.5 libz.so
ln -s libz.so.1.2.5 libz.so.1
rmdir objs
gcc -O3 -D_LARGEFILE64_SOURCE=1 -o examplesh example.o -L. libz.so.1.2.5
gcc -O3 -D_LARGEFILE64_SOURCE=1 -o minigzipsh minigzip.o -L. libz.so.1.2.5
gcc -O3 -D_LARGEFILE64_SOURCE=1 -o example64 example64.o -L. libz.a
gcc -O3 -D_LARGEFILE64_SOURCE=1 -o minigzip64 minigzip64.o -L. libz.a
run make -D to turn on debug
pushd zlib-1.2.5; make; popd
should be
make -C zlib-1.2.5
The -C flag/switch changes the directory similar to what your code does with the pushd and popd commands. The difference is in the behaviour since this make process is recursive. And actually, you might use $(MAKE) instead of make in the event that a command such as gmake is used instead of what might be BSD make (since it is a GNU makefile).