LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-07-2010, 01:11 PM   #1
sidneyluo
LQ Newbie
 
Registered: May 2010
Posts: 5

Rep: Reputation: 0
can “source filename” be used in makefile?


in directory a_dir, have a file named a_file.
i can type "source a_file" under directory a_dir and execute successfully.
but if i write the command to a Makefile under directory b_dir, the "source" function can't be executed well. it will generate some error message like this:
./a_file: line 1: setenv: command not found
./a_file: line 2: setenv: command not found
./a_file: line 3: setenv: command not found
./a_file: line 5: setenv: command not found

what can i do it in a script file like Makefile?
 
Old 05-07-2010, 03:36 PM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,276

Rep: Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153Reputation: 3153
Quote:
What can I do in a script file like Makefile?
Lots of things. But if you use 'setenv' and don't have csh,
you will of course be stopped.

How to ask a question : Tell which Linux OS, you are using.
# yum install tcsh
sudo apt-get install tcsh
.. if you use csh commands.

Makefiles http://www.wlug.org.nz/MakefileHowto
http://www.eng.hawaii.edu/Tutor/Make/

Other links http://www.gnu.org/software/autoconf/
http://www.gnu.org/software/automake/
http://sourceware.org/autobook/

http://www.freesoftwaremagazine.com/..._gnu_autotools
http://www.freesoftwaremagazine.com/...with_autotools
http://www.freesoftwaremagazine.com/..._with_autoconf

Last edited by knudfl; 05-07-2010 at 03:37 PM.
 
Old 05-08-2010, 09:51 AM   #3
sidneyluo
LQ Newbie
 
Registered: May 2010
Posts: 5

Original Poster
Rep: Reputation: 0
thanks for so many web site links. they should be good place
 
Old 05-09-2010, 09:25 PM   #4
ArthurSittler
Member
 
Registered: Jul 2008
Distribution: Slackware
Posts: 124

Rep: Reputation: 30
Makefile or makefile is default name for make specification

I recommend that you look at the documentation for make and gmake. Make by default looks for a file named Makefile or makefile for a specification about how to build a program from possibly several pieces using possibly several tools.

One advantage of using make for building your program is that you can put the commands and all needed parameters for the commands in the makefile so you don't need to type in the possibly fussy command line with parameters each time you want to build your project. Instead of typing in all the commands to compile and link your program myprog.c to create the executable file myprog, or even more involved projects that use higher level tools to generate some source files (for example, flex and bison), you simply type

make myprog

and make or gmake sends the commands to build myprog.

Another advantage to using make is that you don't needlessly compile parts of your project where the source files for those parts have not changed since the last time you built the project. That is not such a big deal nowadays, but not compiling some unchanged source files needlessly saved a lot of time when computers were much slower. It also can save a lot of time for large projects, such as ones which involve several tens of thousands of lines or more of source code.

Large programming efforts, for example, compiling a Linux kernel customized for your particular platform, make extensive use of makefiles. Make and gmake can include multiple "targets", or goals in a single makefile. Building a new Linux kernel (after you have installed the source code in the appropriate places on your machine is automated by the makefile or Makefile.

Configure your new kernel using

make menuconfig

and setting up the parts and pieces to match your platform.

Then type

make install

and gmake will create the thousands of command lines needed to produce a new kernel in the appropriate place for you.

Please refer to the instructions for building a custom kernel, however. There may be additional intermediate steps like

make modules

involved.

Depending on the speed of your computer and the options selected, building the kernel may take overnight or longer. But you don't have to be there typing commands to compile every little piece because gmake is doing that for you. Then, the next time you build a kernel but only change a few options, the build process can complete much faster.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Modify and Rebuild RedHat Source RPM - Wrong Filename malar Linux - Software 10 10-28-2009 05:49 PM
How to install from source when there is no Configure/Makefile? linus72 Slackware 25 03-16-2009 01:14 PM
source an environment file in Makefile sharathkv Programming 3 04-05-2007 11:15 PM
Installing MySQL source and cannot find 'makefile' melliott9 Linux - Software 1 05-23-2006 05:00 PM
modifying makefile after modified C source zerointeger Programming 6 10-06-2005 02:15 PM


All times are GMT -5. The time now is 06:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration