Visit The New, Modern Unix Linux Community


Makefile autogenerated by shell script for a given .c code file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Makefile autogenerated by shell script for a given .c code file
# 1  
Makefile autogenerated by shell script for a given .c code file

Hi,

I have learned native compilation of basic c code example programs from the net.
The issue is, .c code file doesn't come with respective Makefile.
Visited some web sites with Makefile manuals but still can not master writing Makefile file to work.

The idea is to have intelligent shell script, generating working Makefile for a given .c code file, providing some interactive options (dialog menu or the like).

It's a part of my research work on human cognition process based software solutions (old AI school).

To say it just in few words:

- moving Makefile manual rules from text to shell script code.

Could you give me your helpful hand ?

Darius
# 2  
Have you looked at GNU autotools? GNU build system - Wikipedia, the free encyclopedia
# 3  
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
# 4  
Quote:
Originally Posted by fpmurphy
Have you looked at GNU autotools? GNU build system - Wikipedia, the free encyclopedia
Hi,
spent another day with Makefile and Gnuplot, shell scripting, larning gnuplot to read a script, to read output from shell script , to read data file and more.

One example I follow now
compiling basic .c code examples from the net is:

gcc helloworld.c -o helloworld

It doesn't work for another example .c code program from the net

[admin@oo helloworld]$ gcc squares.c -o squares
squares.c: In function 'main':
squares.c:8: error: expected expression before '=' token
[admin@oo helloworld]$

---------
squares.c code is
what is wrong ?
--------------
#include <stdio.h>
main() {
double x;
FILE *datafile;

datafile = fopen("squares.dat","w");

for(x = 0.0; x < = 4.0; x += 1.0)
fprintf(datafile, "%4.1f %4.1f\n", x, x * x);

fclose(datafile);
}


This program should create data file to be read by gnuplot.

source
Introductory Graphing
Here is a C program to create this file.

(see above)

Darius
# 5  
Thank you for your post, it is a bit hard for people to understand you. Could you be very specific about how we can help you, one question at a time? Thanks.
# 6  
Quote:
Originally Posted by Neo
Thank you for your post, it is a bit hard for people to understand you. Could you be very specific about how we can help you, one question at a time? Thanks.
Thanks my friend.
There is nothing complicated in asking basic questions.
I will try to describe you the issue.
I have been living on the Internet for the last 20 years
and expected to access some learning technologies to learn faster what I need for some research projects I am working on.

Example:1
about you:
----------------------
Join Date: Sep 2000
Location: Asia Pacific
Posts: 4,666

4,666 posts in only 8 years.
You must be both Sheel Programming and Scripting expert and guru.
You are smart and there is no more chance to read or view all of your posts.

Example: 2

My efforts to learn basic of Gnuplot.
I have visited via Google about 20 web sites devoted to Gnuplot.
Both manuals , FAQ, examples , papers ..
and spend more than 24 hours reading and testing gnuplot examples.

Could you tell me how to access 1-page abbriged gnuplot manual, just basics:
few examples for dumb terminal,
how to plot from data file input
how to plot from live data stream
how to plot from shell, perl, javascript, php script
how to write plot macro as a script

So what I am really interested in, is 1-page manual.
Otherwide I visit interesting web pages, each 20-50 pages long
and extract and extract what I really need for tests, to build
1-page manual of interest to me.

The same with c code examples.
Some come with Makefile, some don't, just zipped directory of files.

In the last few days tried to compile Linux dialog
and curses.h is missing
ncurses-devel
not compiled yet. for my Linux embedded device.

I can ask you, others to help me or look for 1-page HowTo manual to get help on myself.

That's the problem.
Visiting Google I get access to hundreds of web pages devoted to gnuplot, Linux dialog, Shell scripting.
But what I really need is 1-page HowTo manual
or good answer to my HowTo question.

As people are busy answering hundreds of questions, and to get the right answer promptly is not easy, my solution to this problem is to extract just what counts from 100-page manuals.

In the case of shell programming and scripting forum with thousands of questions asked over and over again, such an organization of archives with already answered questions, to keep text as short as possible
and questions aggregated by categories, tags.

Tag cloud is still not a solution to your 489 pages long archives.

I am sure, the same question, asked by me, have been already asked and got answered hundreds of times in the past at this or another place.
On Usenet, other web sites, mayby on Google Groups or the like.

And I work really hard to find answers to my questions on the net before asking them on your forum.
Mayby I am wrong, but referring me to a right place is as good as giving me a right answer.

So human-based Google-like search engine is exactly what I am looking for.

As you claim that it takes humans some time to understand a question asked in fully, so mayby there is a way to replace humans by
some algorithms, generating such abriged 1-page manuals
for a question asked ( knowledge extraction from Google scanned, indexed
and ranked virtual libraries).

If you are aware of any such solution, please let me know.

Darius

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #241
Difficulty: Easy
In 1973, a transatlantic submarine fiber optic link connected the Norwegian Seismic Array (NORSAR) to the ARPANET, making Norway the first country outside the US to be connected to the network.
True or False?

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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

Featured Tech Videos