Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Dynamic universal Make file
Dynamic universal Make file [message #51091] Wed, 20 November 2002 13:51
Johannes de Jong is currently offline Johannes de JongFriend
Messages: 11
Registered: July 2009
Junior Member
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 ==================================
Previous Topic:What's the point of disabling "Load shared library symbols automatically"?
Next Topic:CDT on Mac
Goto Forum:
  


Current Time: Sat Aug 10 07:12:28 GMT 2024

Powered by FUDForum. Page generated in 0.03152 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top