Hello list,
After getting my curiosity spiked by an earlier post about
makefiles, I determined that I would look into using makefiles
to organize the project directory tree.
I.E. having the makefile be nice and generic and find/build the
list of all .o files for you and then creating said ofiles in a
sub_dir of the src directory..
Unfortunately, my understanding of makefiles and my ability
to search the web for those who understand more about makefiles
was not up to the task. I was able to find/modify a makefile that
does the first part of what I was looking for, but not the second..
I am pretty sure after reading "man make" that it _can_ be done,
but I just don't know how.
Below is the makefile i am using as it stands now, if anyone on the
list can help me modify the makefile to put the .o files into a
subdir and then link the exe using said ofiles in said dir, i would
appreciate it very much.
Thanks for taking the time to read this, :) and i hope to hear from
someone who can help me.
Steve, at a loss with makefiles.
----- begin makefile-----
####
# HOW TO MAKE project
# Step 1) "make clean"
# Step 2) "make"
####
### Customising
# Adjust the following if necessary; TARGET is the target
# executable's filename, LIBS is a list of libraries to link in
# (e.g. crypt), CFLAGS are the flags to pass to the compiler,
# and CC is the compiler to use. You can override these on
# make's command line of course, if you prefer to do it that way.
TARGET := ../area/Rom24
CC := g++
CFLAGS := -Wall -g
LIBS := crypt
RM-F := rm -f
# You shouldn't need to change anything below this point.
SOURCE := $(wildcard *.c) $(wildcard *.cc)
OBJS := $(patsubst %.c,%.o,$(patsubst %.cc,%.o,$(SOURCE)))
.PHONY : objs clean
objs : $(OBJS)
clean :
@$(RM-F) *.o
@$(RM-F) *.d
@$(RM-F) ../area/core
@$(RM-F) $(TARGET)
$(TARGET) : $(OBJS)
$(CC) -o $(TARGET) $(OBJS) $(addprefix -l,$(LIBS))
----end makefile-------