make install error with Makefile I created
hi everybody,
I am new to Linux and I am trying to install a C program from source using Makefile. So I 've created a "hello world" program and then a Makefile to install it. Then I logged in as root and used make install The following error occurs: make: execvp: /usr/bin: Permission denied make: *** [install] Error 127 here is the Makefile: CC=gcc CFLAGS=-c -Wall PROGS = hello INSTDIR = $(prefix)/usr/bin/ INSTMODE = 0755 INSTOWNER = root INSTGROUP = root all: $(PROGS) $(PROGS): main.o $(CC) main.o main.o: main.c $(CC) $(CFLAGS) main.c install: $(PROGS) $(INSTALL) $(INSTDIR) $(INSTALL) $(INSTMODE) $(INSTOWNER) -o $(INSTGROUP) $(PROGS) $(INSTDIR) clean: rm -rf $(PROGS) *o $(PROGS) --So, where are the errors Thank you in advance, Spiros |
I suspect that
Code:
INSTDIR = $(prefix)/usr/bin/ Here's a Makefile that does it all that may help Code:
MAKEFILE = Makefile Note that this consturct Code:
$(CC) $(CFLAGS) -s -o By the way, it's helpful if you enclose code samples in code blocks (easier to read). Hope this helps some. |
Problem solved !
I modified the code given by tronayne and it works ! The user can now use make install from within the directory containing the source code and the Makefile and after installation, all the mess can be cleaned up using make remove and make clean or make clobber.
Many thanks to user tronayne !!! Here is my new Makefile: MAKEFILE = Makefile CC=gcc CFLAGS = -c -Wall LDFLAGS = -lm OWNER = root GROUP = root BMASK = 0755 MAINS = hello123 #binary name SOURCEDIR = ${PWD} TARGETDIR = /usr/bin OBJECTS = main.o SOURCES = main.c ALL: $(MAINS) hello123: main.o $(LIBRARY) $(CC) -o hello123 main.o $(LDFLAGS) main.o: install: $(MAINS) cd / cp $(SOURCEDIR)/$(MAINS) $(TARGETDIR) cd /usr/bin;\ chown $(OWNER) $(MAINS);\ chgrp $(GROUP) $(MAINS);\ chmod $(BMASK) $(MAINS) remove: cd $(SOURCEDIR);\ rm -f $(MAINS) clean: rm -f $(OBJECTS) clobber: rm -f $(OBJECTS) $(MAINS) |
Glad to know it helped.
One comment: in your Makefile you have Code:
remove: The clobber directive is meant to remove both the object and executable file(s) create by make -- idea being to keep your source code directory size to a minimum. Just a thought. |
All times are GMT -5. The time now is 11:39 PM. |