LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Mandriva (http://www.linuxquestions.org/questions/mandriva-30/)
-   -   How to create a top level makefile (http://www.linuxquestions.org/questions/mandriva-30/how-to-create-a-top-level-makefile-604860/)

rushadrenaline 12-06-2007 03:04 AM

How to create a top level makefile
 
Hello everybody...
This is the directory structure of my Main folder, for which i need to write a top level makefile
$> ls /home/rah/MAIN
AF/
Middleware/
Platform/
Tools/-->toolchain_2.8.0/-->(bin/,include/,man/,lib/,usr/,share/,doc/,uclibc/)
Utils/

So the problem is that i need to write a top level makefile(which will reside in MAIN) and also i need to generate a ncurses based menu for compiling it.
All the Af,MW,platform,tools and utils directories have their makefiles ready.Now i need to write a top level makefile to link them all and also a ncurses based menu.
pls help me on this,its really urgent.
Thank you all

tronayne 12-07-2007 03:34 PM

For ncurses, you're on your own but here's what a top-level Makefile would look like:
Code:

MAKEFILE =      Makefile

#      Note: defined here, these will override local Makefile;
#      dont' define these unelss they're common to all subdirectories
CFLAGS  =      -O (or whatever you need)

#      Note: defined here, these will override local Makefile;
#      dont' define these unelss they're common to all subdirectories
LDFLAGS =      -lm (or whatever you need)

ALL:    build

build:
        @echo "Building system..."
        cd AF; make CFLAGS="$(CFLAGS)" LDFFLAGS="$(LDFFLAGS)"
        cd Middleware; make CFLAGS="$(CFLAGS)" LDFFLAGS="$(LDFFLAGS)"
        cd Platform; make CFLAGS="$(CFLAGS)" LDFFLAGS="$(LDFFLAGS)"
        cd Tools; make CFLAGS="$(CFLAGS)" LDFFLAGS="$(LDFFLAGS)"

install:
        @echo "Installing system..."
        cd AF; make CFLAGS="$(CFLAGS)" LDFFLAGS="$(LDFFLAGS)"
        cd Middleware; make CFLAGS="$(CFLAGS)" LDFFLAGS="$(LDFFLAGS)"
        cd Platform; make CFLAGS="$(CFLAGS)" LDFFLAGS="$(LDFFLAGS)"
        cd Tools; make CFLAGS="$(CFLAGS)" LDFFLAGS="$(LDFFLAGS)"

clean:
        @echo "Clean system..."
        cd AF; make clean
        cd Middleware; make clean
        cd Platform; make clean
        cd Tools; make clean

Now, if you do CFLAGS and LDFLAGS like this, they will override whatever is defined in a "local" Makefile; if you have different flags in you local Makefiles, don't define them in this Makefile and your "build" section would then look like
Code:

build:
        @echo "Building system..."
        cd AF; make
        cd Middleware; make
        cd Platform; make
        cd Tools; make

Hope this helps some, sorry that I can't write a ncurses for you but, you know, the command line works just fine, too.

rushadrenaline 12-08-2007 01:11 AM

Thank you very much tronayne.
Ill check if it works fine, but that was a very decent and clean reply from your side.
Thanx again

rushadrenaline 12-10-2007 10:16 PM

Hey guys this is what my dir structure looks like :

trav@localhost]$ ls ~/Main
AF/ Mware/ Platform/ Tools/ Utils/

The directory listing below, is an expansion of Mware.


[HTML]
MAIN/--
MWARE/--
Lib/
Miniapps/
Modules/--
dvdaudio/--
Makefile
dvdvideo/--
Makefile
gfxlibrary/--
Makefile
Keyboard/--
localkeyboard.c

remote/--
localremote.c
localremote.h

dvdaudioapi/--
include/
Makefile
dvdaudioapi.cpp
dvdaudioapi.d

dvdvideoapi/--
include/
Makefile
dvdvideoapi.cpp
dvdvideoapi.d

Obj/
Thirdparty/--
Applications/--

include/--
dvdlocal.h
dvdaudio.h
dvdtypes.h
vcdtypes.h
vcdaudio.h

Lib/--
librmdisc.so
librmdvdfs.so
librmdvdvideonav.so
librmvcdnav.so
Makefile
Modules/--
Module1/--
Application/--
include/--
src/--
Module2/--
Application/--
include/--
src/--
Module3/--
Application/--
include/--
src/--
Module4/--
Application/--
include/--
src/--
[/HTML]

dvdvideoapi.d file contains this code --(rmdvdvideoapi.o rmdvdvideoapi.d: Makefile rmdvdvideoapi.cpp rmdef.h rmdvdvideoapi.h\
rmdvdvideonav.h )

So the problem now is that i need to write a top level makefile that resides in Main/Mware/ and removes the .d (dependency) files and instead cretaes .so and .o files, while also taking care of the lower level makefiles.
Please ,help, im stuck again.
thanx


All times are GMT -5. The time now is 05:01 PM.