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 #51060] Wed, 20 November 2002 13:51 Go to next message
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 ==================================
Re: Dynamic universal Make file [message #51147 is a reply to message #51060] Wed, 20 November 2002 14:02 Go to previous messageGo to next message
Johannes de Jong is currently offline Johannes de JongFriend
Messages: 11
Registered: July 2009
Junior Member
what I was trying to say here :

> $(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 $(@)

Is that whatever I do I cant seem to get the target to point to the
corresponding changed .o and/or .c. It keeps on seeing the while string of
all .o or .c files as dependeances. How do I point get make so far to
point only to the ONE corresponding .o or .c files.
Re: Dynamic universal Make file [message #51579 is a reply to message #51060] Fri, 22 November 2002 18:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Stephen.Kennedy.havok.com


Try:
obj/%.o : src/%.c
$(CC) -o $(@) $(<) -I$(INC) $(LIB)

And similarly exe/% : obj/%.o

Stephen.
Re: Dynamic universal Make file [message #51800 is a reply to message #51579] Mon, 25 November 2002 08:05 Go to previous messageGo to next message
Johannes de Jong is currently offline Johannes de JongFriend
Messages: 11
Registered: July 2009
Junior Member
Stephen Kennedy wrote:

> DQpUcnk6DQpvYmovJS5vIDogc3JjLyUuYw0KICAgICQoQ0MpIC1vICQoQCkg JCg8KSAtSSQoSU5D
> KSAkKExJQikgDQoNCkFuZCBzaW1pbGFybHkgZXhlLyUgOiBvYmovJS5vDQoN ClN0ZXBoZW4uDQo=


?????
Re: Dynamic universal Make file [message #51881 is a reply to message #51579] Mon, 25 November 2002 14:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Stephen.Kennedy.havok.com

(outlook munged that, lets try again)

Try:
obj/%.o : src/%.c
$(CC) -o $(@) $(<) -I$(INC) $(LIB)

And similarly exe/% : obj/%.o

Stephen.
Re: Dynamic universal Make file [message #52165 is a reply to message #51881] Tue, 26 November 2002 10:56 Go to previous messageGo to next message
Johannes de Jong is currently offline Johannes de JongFriend
Messages: 11
Registered: July 2009
Junior Member
Thanks Stephen :)

You suggested change did not work but you have pointed me in another
direction with the \"appending\" of the directory. I did not one could to
that. I have somthing else to \"work\" with now :)

Regards Johannes.

ps. the error I get is \"No rule to make target \'exe/%, need by \'all\'.
Stop\"

I can\'t seem to get all to \"point\" to exe/% : obj/*.o
Re: Dynamic universal Make file [message #52930 is a reply to message #51060] Mon, 02 December 2002 03:53 Go to previous messageGo to next message
Andrew Murray is currently offline Andrew MurrayFriend
Messages: 1
Registered: July 2009
Junior Member
Have you though about just using autoconf, automake and libtool? You might
save yourself quite a headache...

Just a thought.

Andrew

Johannes de Jong wrote:

> 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 ==================================
Adding and Removing Widgets [message #62178 is a reply to message #52930] Fri, 14 February 2003 14:38 Go to previous message
Eclipse UserFriend
Originally posted by: bijukp2000.rediffmail.com

Hi All.

Did SWT api support adding and removing widgets dynamically to
org.eclipse.swt.widgets.Composite
on user interactions ?.

I didn't find any api methods to add and remove widgets.

Please advise me how to proceed.

Regards
Biju
Previous Topic:Outline problem with anonymous structs
Next Topic:JNI Problems
Goto Forum:
  


Current Time: Thu Dec 26 11:03:07 GMT 2024

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

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

Back to the top