GNU style configure batch file issues - batch-file

I'm trying to create a GNU like configure script for Windows in a batch file. It seems to work ok so far except depending on the order options get ignored and in particular with the '--with-smtube' option it sometimes gets the path but again depending on the order causes it to result in:
test.cmd --enable-portable --with-smtube=C:\svn\smtube
configure: error: unrecognized option: `C:\svn\smtube'
Try `--with-smtube --help' for more information
(supposed to also say Try `test.cmd --help)
I copied the structure from another script I found but not having success. The order of arguments shouldn't matter and arguments can be omitted (all or some). Can someone steer me in the right direction?
The script is for a Qt program, it uses command prompt as the shell and not msys or cygwin or anything like that.
This is what I have so far: http://redxii.users.sourceforge.net/test.cmd

Related

How to use yarpgen random C program generator?

I am new here.
Could anyone help me, on how to use yarpgen to generate a random c program.
I tried running the run_gen.py script that I saw in the yarpgen readme.
But, I got a warning and an error like this:
Warning: please set YARPGEN_HOME envirnoment variable to point to test generator path, using C:\Users\..\Python\Python36-32\yarpgen-master for now
and
File C:\Users\..\Python\Python36-32\yarpgen-master\yarpgen wasn't found
Any help would be much appreciated.
Thanks in advance !
The warning very likely points to the source of the problem, run_gen does not know where the other parts of yarpgen are installed.
First, note down the directory you installed/copied yarpgen to.
Then open a command shell. Type this:
cd <where run_gen.py is>
set YARPGEN_HOME=<the path you just noted down>
run_gen.py
If this works, you can write a batch script, that contains the set YARPGEN_HOME=... line and then calls run_gen.py. If the directory where run_gen.py is located is not on your PATH environment variable, call run_gen.py with the full absolute path in the batch script:
set YARPGEN_HOME=<the path to yarpgen>
python3 <absolute_path_to>\run_gen.py
Then you can call your batch script.
You may have to adjust the python3 command depending on the executable Python 3 installed on your machine (it may be just python on Windows).
When I tried this after building with cygwin, I noticed that I had to rename yarpgen.exe to yarpgen to make it work.

Executing windows commands in C

I have a batch file which changes the direction to a specific toolchain and executes one command like this:
cd C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin
avr-objcopy -O binary C:\Users\cinar\Desktop\hextobin\GccApplication.elf C:\Users\cinar\Desktop\hextobin\GccApplication.bin
I want to do this with my C application. I found this topic, tried the system(); command and it works partially. I can call this:
system("cd");
and get the direction back. But I can not change it with this command:
system("cd C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin");
This caused a compile warning about unknown escapes, so i added \ to escapes and tried this:
system("cd C:\\Program Files (x86)\\Atmel\\Studio\\7.0\\toolchain\\avr8\\avr8-gnu-toolchain\\bin");
I was able to compile and run this but that didn't change the direction.
Is there any possibility to execute my commands with system()? As I just want to change the direction and execute one command, I wanted to keep it simple.
Update: I found this topic afterwards:
system("cd <path>") in a C program
Then solved my query with this:
chdir("C:\\Program Files (x86)\\Atmel\\Studio\\7.0\\toolchain\\avr8\\avr8-gnu-toolchain\\bin");
system("avr-objcopy -O binary C:\\Users\\cinar\\Desktop\\ff.elf C:\\Users\\cinar\\Desktop\\ff.bin");
Your program has some incorrect assumptions. First of all, "cd" and "dir" are not programs, but commands built into the shell, cmd.exe. Second, I suspect you don't need to change the current directory at all.
Either way, since this is a Windows system, I would look at an example on how to start a program with CreateProcess().
For changing the current directory, check out the lpCurrentDirectory parameter of the CreateProcess() call.
Also
system("dir Users\\whatEverNextFolder > test.txt");

Cygwin bash.exe cannot run make, works in cmd.exe

I am having issues running any make command in a Cygwin bash terminal. The following is the error that is returned.
"'ygdrive' is not reconized as an internal or external command, operable program or batch file"
However I am able to properly run the make file using cmd.exe, any help would be appreciated.
Thanks Eric E
Looks like you are referencing a path in some recipe with \cygdrive\<letter>\.... bash interprets a single backslash as an escape character and therefore ignores the c directly following it.
Solutions:
If you want the Makefile to be portable to Unix systems, just write forward slashes in paths like this /cygdrive/<letter>/....
If you instead want the Makefile to be compatible with cmd, too, use double backslashes like \\cygdrive\\<letter\\... -- both bash and cmd will understand this.
In any case, such a path should be in a make variable because it is probably completely different on another machine.
The above solution by Felix might be the answer for others, however the solution for my problem was removing "SHELL=C:/Windows/System32/cmd.exe" from the top of my Makefile..

Shell Script to typeset Lilypond files with Textwrangler

I need a shell script which will allow me to typeset Lilypond files from TextWrangler (A Mac App).
So far I have come up with this:
#!/bin/sh
/Applications/LilyPond.app/Contents/Resources/bin/lilypond -o $1
which, of course, doesn't work. (That's why I'm at Stack Overflow.)
When I run that script from the shebang menu in TextWrangler, I get this output:
/Applications/LilyPond.app/Contents/Resources/bin/lilypond: option faultpaper,
--output'' requires an argument
What gives?
I'm running Snow Leopard, TextWrangler, and Lilypond.
Help appreciated.
EDIT: Found a way to get the document path in a Unix Script launched by TextWrangler, so I've rewritten this.
There are multiple ways to work with scripts in TextWrangler through the #! menu, and I'm not sure which one you're trying to use. It looks, though, like you're trying to create a Unix Script to convert your LilyPond document.
As your error hints, Unix Scripts unfortunately aren't given any arguments at all, so $1 will be empty. However, it turns out that recent versions of BBEdit/TextWrangler do set some environment variables before running your script (see BBEdit 9.3 Release Notes and scroll down to Changes). In particular, you can use the following environment variable:
BB_DOC_PATH path of the document (not set if doc is unsaved)
So, save this script to ~/Library/Application Support/TextWrangler/Unix Support/Unix Scripts and you should be good to go.
Other ways you might be trying to do this that don't work well:
Using a Unix Filter: to do this you would have to select all of your LilyPond code in the document, and it would be saved into a temporary file, which is passed as an argument to your script. OK, so that gets you an input filename, at the cost of some hassle. But then the output of that script (i.e. the LiiyPond compiler output) by default replaces whatever you just selected, which is probably not what you want. Wrong tool for the job.
Using #! → Run on a LilyPond file: This involves putting a #! line at the top of your file and having TextWrangler attempt to execute your file as a script, using the #! as a guide to selecting the script interpreter. Unfortunately, the #! line only works with certain scripting languages, and LilyPond (not quite a scripting language) isn't one of them. This is what Peter Hilton is trying to do, and as he notes, you will get LilyPond syntax errors if you try to add a #! line to the top of a LilyPond file. (If you're curious, there is technically a way to get #! → Run to work, which is to embed your LilyPond code inside an executable shell or perl script, using here-document syntax. But this is a gross hack that will quickly become unwieldly.)
There are a few limitations to the script linked above:
It doesn't check to see whether you saved your document before running LilyPond. It would be nice to have TextWrangler automatically save before running LilyPond.
It can't take snippets of text or unsaved documents as input, only saved documents.
You can make more sophisticated solutions that would address these by turning to AppleScript. Two ways of doing this:
Create a script that's specific to TextWrangler and drop it in ~/Library/Application Support/TextWrangler/Scripts. It then shows up in the AppleScript menu (the weird scrolly S), or you can get at it by bringing up Window → Palettes → Scripts. I believe two folks out there have gone down this path and shared their results:
Henk van Voorthuijsen (Lilypond.applescript extracted from MacOS 10.5 Applescript for TextWrangler thread on lilypond-devel, 21-Jul-2008)
Dr Nicola Vitacolonna (LilyPond in TextWrangler – uses TeXShop).
Create a Mac OS Service, which would potentially be a method that would be reusable across just about any text editor. This was how we used to compile Common Music files way back in the NeXT days, so I can testify to its elegance. I don't have a good up-to-date example of this, unfortunately.
Good question. It actually runs Lilypond on my system if you do this:
#!/Applications/LilyPond.app/Contents/Resources/bin/lilypond -o $1
… but fails because # is not a line-comment character so Lilypond tries to parse the line.
Surrounding it with a block comment fails because TextWrangler cannot find the ‘shebang’ line.
%{
#!/Applications/LilyPond.app/Contents/Resources/bin/lilypond -o $1
%}
An alternative is to use Smultron 3, which lets you define commands that you can run with a keyboard shortcut.

How do we write a program in Command line development environment?

I have been writing my code in IDE,I just read that there also existed a Command Line Development Environment in which the code is written in DOS.I googled but found no results on how to use the command line development environment.My OS is Windows XP.I would be very thankful for your help me write the hello world program in DOS and also explain how to run it.
You simply use whatever text editor you like to create the C sourse file(s) then invoke the compiler command line(s) to compile and link the program (typically, an IDE is doing exactly that, but in a behind-the-scene manner). How the command line is invoked depends on the exact toolchain you're using.
You might also need to set up an environment for you particular compiler toolchain (the right paths and various other env variables might need set up).
For Visual C++ the environment might be set up using a batch file installed by Visual Studio:
vcvarsall x86
Invoking the compiler could be as simple as:
cl helloworld.c
or for C++ (for some reason it issues a non-fatal warning if you don't give it an option configuring details about how it should implement exceptions):
cl /EHsc helloworld.cpp
The particulars are very dependent on the compiler you're using - you should read the docs for that compiler.
Also, the options you use depend on your particular situation and needs. Scripts/batch files and/or makefile can help you manage the complexity of the options you might need to use.
DOS is not dead.... yet!
fahad
There are a number of methods by which you can enter code in DOS (see EDIT further on down).
(1) You can send keystrokes directly to a file
You do this by redirecting output to CON (the console) to a file. The only oddity of this method is that you end the 'session' by entering a CTRL-Z when you are finished.
It's basic, but this is how it goes.
Firstly, suppose you want to display "Hello World" on the screen, a simple batch file containing the following two lines is all that is required:
#echo off
echo Hello World
The '#echo off' is commonly found at the start of all batch files. It simply instructs the command interpretter NOT to display each command as it is being executed (or parsed).
One more thing before we start. Throughout this answer, I will assume your program is named 'helloworld.bat'.
Enter the following lines one after the other pressing the ENTER key at the end of each line:
copy con helloworld.bat
#echo off
echo Hello World
^Z
The '^Z' is displayed when you press the CTRL-Z key combination (don't forget to press the ENTER key as well).
When you press the ENTER key after CTRL-Z, DOS displays the familiar '1 File(s) copied' messege.
You can now execute the batch file program by simply entering the program's name like this:
helloworld
And DOS will display the following:
Hello World
It can't get any more basic than that.
(2) You can use DOS' EDIT program
This is a DOS based IDE retained from around the mid-90's. Simply enter the following command:
edit
And EDIT will open in the same DOS window. When you close EDIT, you are returned back to DOS again.
EDIT also works with your mouse.
Once EDIT opens, enter the following two lines of code:
#echo off
echo Hello World
Then, click on [File], [Save], type: 'helloworld.bat' in the "File Name" input field, use your mouse to change directories in the "Directories:" pane if you want to, then click [OK]. To return to DOS, click [File], [Exit].
EDIT version 4.5 (I think) was context-sensitive and displayed code using different colours to seperate key word, different data type, symbols etc.
(3) Use Windows' built-in Notepad
This is simple. At the command prompt, enter the following command:
notepad
And Notepad will fire up. It's a simple text editor and does the job when entering small programs.
(4) Use Notepad++. It's FREE!!
Notepad++ is the programmer's choice. It's free, full of useful features and customisable. Find it on the net by searching for "notepad++".
From your comment, "Just some knowledge so I can say that I know one way to do programming without IDE" I would say learn to write simple batch files. They can be run from Explorer but they exist as a holdover from the DOS days.
Start a command prompt window (Start->Run->'cmd'), this will open a window and show a prompt, most likely "c:\" or some other path.
Type the following command (followed by )
echo "Hello World"
You should see:
"Hello World"
c:\
Now, using whatever editor you'd like, create a text file with that command as the only line. Name the file "hello.bat". When you are at the command prompt you can execute the batch file like so:
c:\hello.bat
"Hello World"
c:\
You have now programmed using the DOS command line. For more commands and such, start with the help system.
c:\help
Which will display all the available commands for your batch file.
Microsoft has an online reference here.
DOS is dead for all practical purposes. Under Windows your options boil down to the following:
Use an IDE. Visual Studio is one example, Qt another. You can write programs for the commandline with an IDE.
Use a proper text editor, build tool and other helper tools. You might use gvim for editing code, make for building your project and git for version control. You might as well use the GNU coreutils for other helpers, or maybe even the entire cygwin package.
Bro, use gcc compiler for which write ur code in any text editor then compile ur code in windows shell or u can say command line environment.
Look!
Prompt:/> gcc source_file_name.c
This command compiles ur code,
If there is any error, u will get dispalyed with line numbers,
now, every program creates its exe file by the name a.exe by default.
To, get the output of ur program,
Prompt:/> a.exe
O/P
Hello World!
To change the name of the exe file there is also a command..

Resources