Now to proceed further I need to change the presentation of existing Makefile.
Presently I am using:
~/Linuz/src: 1.c, 2.c, 3.c ...
~/Linuz/inc: abc.h, xyz.h
and makefile is in: ~/Linuz/some_other_dir/
But need to change the structure.
- Want to create a library from (
~/Linuz/src/
and~/linuz/inc
) - Library will be used to get executable. Application source files(.c files) are in
~/Linuz/app/
~/Linuz/bin/
should be created during compilation to store all the object files and executable file.
Any suggestions ??
My makefile looks like this:
all: Library.a
%.o: ../src/%.c
$(CC) $(CFLAGS) -I../inc/ -c -o $@ $^
Library.a: $(SRC_DIR)/1.c $(SRC_DIR)/2.c $(SRC_DIR)/3.c $(SRC_DIR)/4.c $(SRC_DIR)/5.c
$(CC) $(LDFLAGS) -o $@ $^
all: prog
%.o: ./*.c
$(CC) $(CFLAGS) -ILibrary.a -c -o $@ $^
prog: $(APP_DIR)/app1.c $(APP_DIR)/app2.c $(APP_DIR)/app3.c
clean:
rm -f *.o my_program
Let assume that your code architecture looks like that:
So your Makefile could be:
For the explanation, refer to your previous question