Dynamic universal Make file [message #51091] |
Wed, 20 November 2002 08:51 |
Eclipse User |
|
|
|
I want to create an "universal" dynamic Make file that we can use for all
our c projects. The projects will consist out of multiple c modules which
all will "create" a corresponding .exe file.
I managed to create a Make where all c modules and their resultant .o &
exe files end up in the same directory.
= Start Make 1
============================================================ ===
# Dynamic Make file
# for each .c module in the project (= CurDIR)
# a corresponding .o & .exe wil be created
RootPath = c:\data\ExtFiles\
CC = GCC
SRC := $(wildcard *.c)
OBJ := $(SRC:.c=.o)
EXE := $(SRC:.c=.exe)
INC = $(RootPath)\inc
LIB = $(RootPath)\lib\xxxxxxxx.lib
Phony: all clean
all: $(EXE)
(EXE): %.exe : %.o
$(CC) -o $(@) $(<) -I$(INC) $(LIB)
$(OBJ): %.o : %.c
$(CC) -c $(<) -I$(INC)
= End Make 1
============================================================ =====
However for various reason's we would like to create the following
directory structure "under" our project.
Project
|
+- src <- C source modules
|
+- inc <- includes (.h) files
|
+- obj <- result of compiles
|
+- exe <- result of links
For each Project\src\*.c a corresponding .o file is created in
Project\obj\*.o
For each Project\obj\*.o a corresponding .exe file is created in
Project\exe\*.exe
Directory Project is a subdirectory under Eclipse\Workspace\
Here is my attemp. After struggeling for 2 days, yep I'm a Make beginner,
I even wonder if it can be done. I even started looking at Make
replacements !!!
I use GnuMake and run Eclipse on a Win machine by the way.
Thanks for the help.
= Start Make 2
============================================================ ===
RootPath = c:\data\ExtFiles\
CC = GCC
INC = $(RootPath)\inc
LIB = $(RootPath)\lib\xxxxxxxx.lib
SRCDIR = $(CURDIR)/src
OBJDIR = $(CURDIR)/obj
EXEDIR = $(CURDIR)/exe
SRC := $(wildcard $(SRCDIR)/*.c)
OBJ := $(SRC:.c=.o)
OBJ := $(subst src,obj,$(OBJ))
EXE := $(SRC:.c=.exe)
EXE := $(subst src,exe,$(EXE))
all: $(EXE)
$(EXE): $(OBJ) <--+ the problem is here.
Whatever
$(CC) -o $(@) $^ $(LIB) | I do I just can't get the
|
$(OBJ): $(SRC) <--+
$(CC) -c $? -I$(INC) -o $(@)
= End Make 2 ==================================
|
|
|
Powered by
FUDForum. Page generated in 0.03128 seconds