log in | register | forums
Show:
Go:
Forums
Username:

Password:

User accounts
Register new account
Forgot password
Forum stats
List of members
Search the forums

Advanced search
Recent discussions
- FrogFind - seems to make the www a little more old school ! (Gen:1)
- RISC OS interview with Chris Johnson (News:)
- April update for Iris browser (News:4)
- March News Round-up (News:)
- RISC OS Developments updates Iris (News:4)
- Git comes to RISC OS (News:1)
- Daryl Dudey talks about Graphics Programming Using DARIC (News:)
- Daryl Dudey ROUGOL interview on monday (News:2)
- ROOL updates DDE (News:1)
- Acorn Preservation Team wa... data before it's too late (News:)
Latest postings RSS Feeds
RSS 2.0 | 1.0 | 0.9
Atom 0.3
Misc RDF | CDF
Site Search
 
Article archives
The Icon Bar: Programming: Can oneUse flex in a GNU makefile?
 
  Can oneUse flex in a GNU makefile?
  Cauchy (17:30 25/2/2021)
 
John O'Meara Message #125093, posted by Cauchy at 17:30, 25/2/2021
Member
Posts: 43
I have a file fbl-1.l, i.e., fbl-1 is in the l directory. At the CLI I type *flex fbl-1.l. This produces a file in the c directory called lex/yy. I remove the '/' character from the this file name to get lexyy. I then type at the CLI *gcc lexyy -lfl, to get the a/out file. Everything works fine. I put a work-around of those instructions into a makefile, but no joy with the flex command. The word-around instructions are as follows.
TestImage: lextest.o -lfl
gcc lextest.o -oTestImage

lextest.o: fbl-1.c
gcc -c fbl-1.c -o $@

fbl-1.c: fbl-1.l
flex -t fbl-1.l > fbl-1.c
When I run this makefile, the following is displayed:
flex -t fbl-1.l > fbl-1.c
/SCSI::SSD>$.Apps/DEvelopment/!Flex/flex: flex out: error closing output lex.yy.c
/SCSI::SSD.$.Apps/Development/!Flex/flex: error closing output file lex.yy.c
make: *** {test1make:16: fbl-1.c} Error 1
The thing is it produces the file c.fbl-1 but it is completely empty.
The file test1make is the name of the makefile and is run by typing at the * prompt: make --file=test1make
the file l.fbl-1 is a simple word count program. The reason I do not use the more simple commands flex fbl-1.l and gcc lex/yy -lfl, is that you cannot have '/' or '.' characters in a file name as to gcc lex/yy means the file yy in the directory lex, and gets translated as such into the RISC OS. The code in the file l.fbl-1 follows:
%{
int chars = 0;
int words = 0;
int lines = 0;
%}

%%

[a-zA-Z}+ {words++; chars++; strlen(yytext); }
\n {chars++; lines++; }
. {chars++; }

%%

main(int argc, char **argv)
{
yylex();
printf(%8d%8d%8d\n", lines, words, chars);
}
Any ideas and help is welcome. Thanks alot.
PS.
If I change the line gcc -c fbl-1.c -o $@ to
gcc -c fbl-1.c -o lextest.o The message I get is:
gcc -c fbl-1.c -o lextest.o
make: *** No reule to make target '-lfl', needed by 'TestImage'. Stop.

[Edited by Cauchy at 23:16, 25/2/2021]
  ^[ Log in to reply ]
 

The Icon Bar: Programming: Can oneUse flex in a GNU makefile?