Sponsored Content
Top Forums Shell Programming and Scripting Makefile autogenerated by shell script for a given .c code file Post 302275181 by darius2 on Friday 9th of January 2009 12:45:14 PM
Old 01-09-2009
Quote:
Originally Posted by fpmurphy
Have you looked at GNU autotools? GNU build system - Wikipedia, the free encyclopedia
Hi,
===================
automake approach
Automake - Wikipedia, the free encyclopedia
Approach

Automake aims to allow the programmer to write a makefile in a higher-level language, rather than having to write the whole makefile manually. In simple cases, it suffices to give:
  • a line that declares the name of the program to build;
  • a list of source files;
  • a list of command-line options to be passed to the compiler (for example, in which directories header files will be found);
  • a list of command-line options to be passed to the linker (which libraries the program needs and in what directories they are to be found).
...
###########
My input to Automake:

a line that declares the name of the program to build;
- replace by standard name + date
a list of source files;
- have a code to scan directory for source files

a list of command-line options to be passed to the compiler (for example, in which directories header files will be found);
- automate this procedure

a list of command-line options to be passed to the linker (which libraries the program needs and in what directories they are to be found).
- trace program for libraries required and search file system for directories, they are to be found.

########
So I assume, the above input can be autogenerated by intelligent Automake.


===================

thanks,
exactly what I was looking for.
In my case, Makefile for Helloworld, downloaded from the net
-----------------------------------------------------------

helloworld: helloworld.o
cc -o $@ $<

helloworld.o: helloworld.c
cc -c -o $@ $<

.PHONY: clean

clean:
rm -f helloworld helloworld.o
--------------------------------
replaced by command line

gcc helloworld.c -o helloworld
====================================
Makefile template for Linux dialog
# $Id:
makefile.in,v 1.62 2008/07/20 18:30:36 tom Exp $
# template makefile for DIALOG
#
SHELL = /bin/sh

srcdir = @srcdir@
VPATH = @srcdir@

prefix = @prefix@
exec_prefix = @exec_prefix@

top_builddir = .

x = @EXEEXT@
o = .@OBJEXT@
.....
5441 in size total.

Ok.
Makefile.in for dialog is lost, deleted.
Any way to have an intelligent Automake to autogenerate and recover
makefile.in and generate makefile automagically ?

====================
So, what is really needed is some kind of compiler, autoconf, that takes an Autoconf program, configure.ac, and transforms it into a portable shell script, configure.
GNU Autoconf, Automake and Libtool
Learning the GNU development tools: Preface
Automake - Wikipedia, the free encyclopedia





Learning the GNU development tools: Preface
5.3 Hello world example with Autoconf and Automake

To get started we will show you how to do the Hello world program using `autoconf' and `automake'. In the fine tradition of K&R, the C version of the hello world program is:
#include <stdio.h>
main()
{
printf("Howdy world!\n");
}
Call this `hello.c' and place it under an empty directory. Simple programs like this can be compiled and ran directly with the following commands:
% gcc hello.c -o hello
% hello
=========================

Just to follow steps done by a human and have them repeated by intelligent, interactive Automake.

Darius
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

embeding shell script in makefile

Hi I am new to shell scripting and makefile. I want a command's output in makefile to process further, can anyone plz suggest me a way ? I want ls -d *.dsm output in a variable and want to process it in makefile itself. It's urgent Thanks In advance (0 Replies)
Discussion started by: madhu12345
0 Replies

2. Shell Programming and Scripting

shell script in makefile

Hi, Can we execute a shell script by makefile. I mean we will write a shell script in a make file and it will be executed when we compile the C++ program using make file. (2 Replies)
Discussion started by: surjyap
2 Replies

3. Shell Programming and Scripting

Shell script makefile

Is there a way to write a makefile for all the source files in a directory with a shell script? (2 Replies)
Discussion started by: zzhan
2 Replies

4. Shell Programming and Scripting

turn on shell tracing of a makefile

hey, within a shell script file I know how to turn on tracing using "-x" #!/bin/bash -x now I have a complicated makefile which contains lots of `command`, and i would like to trace these `command`, where shall i put the option "-x"? thanks! (1 Reply)
Discussion started by: patiobarbecue
1 Replies

5. Shell Programming and Scripting

Capture makefile errors in shell script

Hi, I have a bash script which calls a few "make". I would like to know whether the makefile failed with any errors. How do I do that in the script? Thanks, S (2 Replies)
Discussion started by: suryaemlinux
2 Replies

6. Shell Programming and Scripting

Call makefile from shell script

I'm writing a VERY simple shell script. I need to call a makefile in a subdirectory. What's the command I need to use? ./dir/make and ./dir/makefile doesn't work. Thanks in advance (1 Reply)
Discussion started by: yamahabob
1 Replies

7. Shell Programming and Scripting

how to run a shell script through Makefile

I want to run a target defined in a shell script. The shell script name is 'ua.sc' and the target in it is 'N' i.e. (ua N) throught a makefile. How can i do it so that i can run it with a make target. (3 Replies)
Discussion started by: vineet.dhingra
3 Replies

8. Shell Programming and Scripting

using a Shell Script in a Makefile

Hello, I have a Makefile that converts wrl (vrml) files to html files... how can I use a shell script in that makefile which works on all html files after converting? The Shell Script have to find and replace a String in every createt html file. sorry I'm a Newbie, so I hope someone can... (0 Replies)
Discussion started by: Dan_78
0 Replies

9. Shell Programming and Scripting

HTML code upload text file grep through shell script

I am looking for HTML code that browse text file and grep with database file then retrieve result txtfileuploaded contain 112233 115599 113366 shell code grep -F -f txtfileuploaded /data/database.txt result 112233 Mar 41$ 115599 Nov 44$ 113366 Oct 33$ attached... (2 Replies)
Discussion started by: phpshell
2 Replies

10. Shell Programming and Scripting

Shell Script Comment code blocks in a bash source file

Just began to learn on Shell Script. I got an exercise from my friend. I know how to make this happen in C, but I'm not familiar with Shell Script. Hope I can get some help from all of you. I want to write a bash script to comment code blocks in a bash source file. What I mean comment is '#', I... (1 Reply)
Discussion started by: HiFuture0801
1 Replies
All times are GMT -4. The time now is 01:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy