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.
Related
Error i get!-----------------/
This is what my makefile looks like/
i am trying to Compile cookie.cpp to produce cookie.o.
Compile mainProg.cpp to produce mainProg.o.
Link the the .o files to produce an executable program named playChomp
mainprog.cpp' file has the header of cookie.h
i am working in unix in an ssh terminal linux server
makefile..
**all: playChomp
playChomp: mainProg.o cookie.o cookie.h
g++ -g -DDEBUG mainProg.o cookie.o -o playChomp
cookie.o:cookie.cpp
g++ -g -DDEBUG -c cookie.cpp
mainProg.o: mainProg.cpp cookie.h
g++ -g -DDEBUG -c mainProg.cpp**
You need to post some basic information that helps the people to understand better your problem. A few suggestions:
Try making a more meaningful title, put the error message that you receive into the title.
Put the source code of your program into your post. If possible, try to reduce it to a minimum content that still generates the same error message.
Inform your Operational System, Language that you are working on, what version, etc.
Given the following directory listing:
$ ls
cookie.cpp cookie.h mainProg.cpp Makefile
Then the Makefile you have provided:
all: playChomp
playChomp: mainProg.o cookie.o cookie.h
g++ -g -DDEBUG mainProg.o cookie.o -o playChomp
cookie.o: cookie.cpp
g++ -g -DDEBUG -c cookie.cpp
mainProg.o: mainProg.cpp cookie.h
g++ -g -DDEBUG -c mainProg.cpp
Will produce the desired executable:
$ make all
g++ -g -DDEBUG -c mainProg.cpp
g++ -g -DDEBUG -c cookie.cpp
g++ -g -DDEBUG mainProg.o cookie.o -o playChomp
$ ./playChomp
Hello World!
The error you are getting suggests the file is not there (in the directory where you are executing make). Ensure that you are calling make from the directory where those files exist, and triple check the spelling (i.e. make sure you have cookie.h, not Cookie.h, etc.)
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
I would like to use RInside in a c++x11 code to call R routine. By default, R seems to install a c++98 version of the library and thus the linking does not success. I wonder what are the different steps I should proceed to install c++x11 version of RInside (but I guess that I need to recompile all R/R package, is it ?) and if some more simple solution exists. Thanks in advance (I work on MacOs)
Update:
I reinstalled Rcpp and RInside doing (my Makevars is empty so c++98 version)
sudo R CMD INSTALL ~/Downloads/Rcpp_0.10.4.tar.gz
sudo R CMD INSTALL ~/Downloads/RInside_0.2.10.tar.gz
Then I compile the hello world example using (no cx11) :
clang++ -I/Library/Frameworks/R.framework/Versions/2.15/Headers/ -I/Library/Frameworks/R.framework/Versions/2.15/Resources/library/RInside/include/ -I/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/ -c ../src/Gui/test.cc -o testOut.cc.o
clang++ testOut.cc.o -o testOut -L/Library/Frameworks/R.framework/Versions/2.15/Resources/library/RInside/lib/x86_64 -L/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/lib/x86_64 -framework R -lRInside -lRcpp
That produces me:
Hello, world!
However, by adding the x11 option:
clang++ -I/Library/Frameworks/R.framework/Versions/2.15/Headers/ -I/Library/Frameworks/R.framework/Versions/2.15/Resources/library/RInside/include/ -I/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/ -c ../src/Gui/test.cc -o testOut.cc.o -stdlib=libc++ -std=c++11
clang++ testOut.cc.o -o testOut -L/Library/Frameworks/R.framework/Versions/2.15/Resources/library/RInside/lib/x86_64 -L/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/lib/x86_64 -framework R -lRInside -lRcpp -stdlib=libc++ -std=c++11
I get (when linking):
Undefined symbols for architecture x86_64:
"RInside::parseEvalQ(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
_main in testOut.cc.o
"RInside::operator[](std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
_main in testOut.cc.o
"Rcpp::Environment::assign(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, SEXPREC*) const", referenced from:
bool Rcpp::Environment::assign<char [15]>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const (&) [15]) const in testOut.cc.o
When recompiling Rcpp and RInside using c++x11 options
clang++ -I/Library/Frameworks/R.framework/Versions/2.15/Headers/ -I/Library/Frameworks/R.framework/Versions/2.15/Resources/library/RInside/include/ -I/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/ -c ../src/Gui/test.cc -o testOut.cc.o -stdlib=libc++ -std=c++11
clang++ testOut.cc.o -o testOut -L/Library/Frameworks/R.framework/Versions/2.15/Resources/library/RInside/lib/x86_64 -L/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/lib/x86_64 -framework R -lRInside -lRcpp -stdlib=libc++ -std=c++11
liking is ok but ./test gives me a seg fault.
Add: my clang version is : Apple clang version 4.1 (tags/Apple/clang-421.11.66)
R is compiled with a c compiler. You don't necessarily need to use the same to build packages. So it is perfectly valid to use clang to compile add on packages. I have this in my ~/.R/Makevars file to use clang and C++11 for package:
CC=clang
CXX=clang++
CXXFLAGS= -stdlib=libc++ -std=c++11
Also, you might want to have a look at Rcpp11, a C++11 centric redesign of Rcpp. It probably would not be too hard to fork RInside to use Rcpp11 instead of Rcpp.
I am not aware of different linker requirements. What you have should just work. Otherwise please show your actual linking steps and errors, preferably in a reproducible way I could look at at my end too.
Witness the following. We first build with default flags:
edd#max:~/svn/rinside/pkg/inst/examples/standard$ grep ^CXXFLAGS ~/.R/Makevars
CXXFLAGS= -g -O3 -Wall -pipe -Wno-unused -pedantic # plain C++
edd#max:~/svn/rinside/pkg/inst/examples/standard$ make rinside_sample0
ccache g++-4.7 -I/usr/share/R/include \
-I/usr/local/lib/R/site-library/Rcpp/include \
-I/usr/local/lib/R/site-library/RInside/include -g -O3 -Wall \
-pipe -Wno-unused -pedantic -Wall \
rinside_sample0.cpp -L/usr/lib/R/lib -lR -lblas \
-llapack -L/usr/local/lib/R/site-library/Rcpp/lib -lRcpp \
-Wl,-rpath,/usr/local/lib/R/site-library/Rcpp/lib \
-L/usr/local/lib/R/site-library/RInside/lib \
-lRInside -Wl,-rpath,/usr/local/lib/R/site-library/RInside/lib \
-o rinside_sample0
edd#max:~/svn/rinside/pkg/inst/examples/standard$ ./rinside_sample0
Hello, world!
edd#max:~/svn/rinside/pkg/inst/examples/standard$
Now I am simply adding -std=c++11 to my CXXFLAGS:
edd#max:~/svn/rinside/pkg/inst/examples/standard$ grep ^CXXFLAGS ~/.R/Makevars
CXXFLAGS= -g -O3 -Wall -pipe -Wno-unused -pedantic -std=c++11
edd#max:~/svn/rinside/pkg/inst/examples/standard$
and remake the binary:
edd#max:~/svn/rinside/pkg/inst/examples/standard$ rm rinside_sample0
edd#max:~/svn/rinside/pkg/inst/examples/standard$ make rinside_sample0
ccache g++-4.7 -I/usr/share/R/include \
-I/usr/local/lib/R/site-library/Rcpp/include \
-I/usr/local/lib/R/site-library/RInside/include \
-g -O3 -Wall -pipe -Wno-unused \
-pedantic -std=c++11 -Wall \
rinside_sample0.cpp -L/usr/lib/R/lib -lR \
-lblas -llapack -L/usr/local/lib/R/site-library/Rcpp/lib -lRcpp \
-Wl,-rpath,/usr/local/lib/R/site-library/Rcpp/lib \
-L/usr/local/lib/R/site-library/RInside/lib \
-lRInside -Wl,-rpath,/usr/local/lib/R/site-library/RInside/lib \
-o rinside_sample0
edd#max:~/svn/rinside/pkg/inst/examples/standard$ ./rinside_sample0
Hello, world!
edd#max:~/svn/rinside/pkg/inst/examples/standard$
To deploy C++11, you do not need a new compiler or project.
Just add a single option to your compiler flags -- it is that easy.
And just to make it more plain, we can also add these three lines to rinside_sample0.cpp to make it a C++11 program:
auto magic = 42; // C++11
R["magic"] = magic;
R.parseEvalQ("print(magic)");
and (with the required -std=c++11 flag) it too builds and runs. Stricly no change required at the Rcpp or RInside end to deploy them with a C++11-capable compiler.
I’m compiling the Qt with phonon and phonon-backend for my embedded board.
I type:
./configure -embedded arm -xplatform qws/linux-arm-g++ -qt-mouse-tslib -L/home/user/ev-sdk/rootfs/arm-a8-fs/usr/lib -L/home/user/Desktop/qt-everywhere-opensource-src-4.8.1/lib -I/home/user/ev-sdk/rootfs/arm-a8-fs/usr/include -I/home/user/ev-sdk/rootfs/arm-a8-fs/usr/include/freetype2/freetype/config -prefix /opt/qt_eng -little-endian -no-gif -no-libtiff -no-libmng -no-openssl -no-opengl -no-mmx -no-3dnow -no-sse -no-sse2 -no-largefile -no-sm -svg -v -no-feature-cursor -fast -opensource -release -no-multimedia -no-cups -no-nis -no-exceptions -nomake examples -nomake demos -no-sql-sqlite -no-g++-exceptions -phonon -phonon-backend -DQT_NO_QWS_CURSOR -DQT_THREAD_SUPPORT
with qmake.conf in /home/user/Desktop/qt-everywhere-opensource-src-4.8.1/mkspecs/qws/linux-arm-g++:
#
# qmake configuration for building with arm-linux-g++ #
include(../../common/gcc-base.conf)
include(../../common/gcc-base-unix.conf)
include(../../common/g++.conf)
include(../../common/linux.conf)
include(../../common/qws.conf)
QMAKE_CFLAGS_RELEASE = -O3 -march=armv7-a -mtune=cortex-a8
-mfpu=neon -mfloat-abi=softfp
DEFINES +=
# modifications to g++.conf
QMAKE_CC = sb2 -t imx53 gcc
QMAKE_CXX = sb2 -t imx53 g++
QMAKE_LINK = sb2 -t imx53 g++
QMAKE_LINK_SHLIB = sb2 -t imx53 g++
# modifications to linux.conf
QMAKE_AR = sb2 -t imx53 ar cqs
QMAKE_OBJCOPY = sb2 -t imx53 objcopy
QMAKE_STRIP = sb2 -t imx53 strip
load(qt_config)
If I remove -phonon -phonon-backend from option the compilation is successful.
If I put -phonon -phonon-backend
I have this error:
.
.
.
D-Bus auto-detection... ()
Project WARNING: Your mkspec is including 'common/g++.conf', but the mkspecs have been refactored
To fix this include 'common/gcc-base-.conf and 'common/g++-.conf' instead
sb2 -t imx53 g++ -c -pipe -pipe -pipe -pipe -pipe -pipe -O2 -O2 -O2 -O2 -O2 -O2 -Wall -W -Wall -W -Wall -W -Wall -W -Wall -W -Wall -W -I../../../mkspecs/qws/linux-arm-g++ -I. -I/home/user/ev-sdk/rootfs/arm-a8-fs/usr/include -I/home/user/ev-sdk/rootfs/arm-a8-fs/usr/include/freetype2/freetype/config -I/usr/lib/glib-2.0/include -I/usr/include/glib-2.0 -o dbus.o dbus.cpp
dbus.cpp:43:23: error: dbus/dbus.h: No such file or directory
dbus.cpp:46:2: error: #error Needs at least dbus version 1
dbus.cpp: In function 'int main(int, char**)':
dbus.cpp:51: error: 'dbus_shutdown' was not declared in this scope
make: *** [dbus.o] Error 1
D-Bus disabled.
Glib auto-detection... ()
Project WARNING: Your mkspec is including 'common/g++.conf', but the mkspecs have been refactored
To fix this include 'common/gcc-base-.conf and 'common/g++-.conf' instead
sb2 -t imx53 g++ -c -pipe -pipe -pipe -pipe -pipe -pipe -O2 -O2 -O2 -O2 -O2 -O2 -Wall -W -Wall -W -Wall -W -Wall -W -Wall -W -Wall -W -I../../../mkspecs/qws/linux-arm-g++ -I. -I/home/user/ev-sdk/rootfs/arm-a8-fs/usr/include -I/home/user/ev-sdk/rootfs/arm-a8-fs/usr/include/freetype2/freetype/config -I/usr/lib/glib-2.0/include -I/usr/include/glib-2.0 -o glib.o glib.cpp
glib.cpp: In function 'int main(int, char**)':
glib.cpp:55: warning: 'pollfd' is used uninitialized in this function
sb2 -t imx53 g++ -Wl,-O1 -o glib glib.o -L/home/user/ev-sdk/rootfs/arm-a8-fs/usr/lib -L/home/user/Desktop/qt-everywhere-opensource-src-4.8.1/lib
*glib.o: In function `main':
glib.cpp:(.text+0x10): undefined reference to `g_thread_init'
glib.cpp:(.text+0x14): undefined reference to `g_main_context_default'
glib.cpp:(.text+0x20): undefined reference to `g_source_new'
glib.cpp:(.text+0x28): undefined reference to `g_source_add_poll'
glib.cpp:(.text+0x38): undefined reference to `g_threads_got_initialized'
collect2: ld returned 1 exit status
make: *** [glib] Error 1*
Glib disabled.
Phonon support cannot be enabled due to functionality tests!
Turn on verbose messaging (-v) to ./configure to see the final report.
If you believe this message is in error you may use the continue
switch (-continue) to ./configure to continue.
I lost the last two days to understand why giving error.
Could someone help me?
Debian/linux can use:
$ sudo apt-get install libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev
The command can be run before run ./configure
QMAKE_LIBDIR += -L$${ROOTFS_DIR}/usr/lib
QMAKE_CFLAGS += -I$${ROOTFS_DIR}/usr/include/glib-2.0
QMAKE_CFLAGS += -I$${ROOTFS_DIR}/usr/lib/glib-2.0/include
QMAKE_LIBS += -lgthread-2.0 -lglib-2.0 -v
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).