log in | register | forums


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

Advanced search
Recent discussions
- WROCC March 2024 meeting o... Hughes and Peter Richmond (News:)
- February 2024 News Summary (News:1)
- Next developer fireside chat (News:)
- DDE31d released (News:)
- South-West Show 2024 Report (News:)
- South-West Show 2024 talks (News:2)
- South-West Show 2024 in pictures (News:)
- Big NVMe news for the RISC OS at the South-West Show (News:)
- Rougol Talk February 2024 - Chris Hall (News:1)
- Saturday is South-West Show (News:3)
Latest postings RSS Feeds
RSS 2.0 | 1.0 | 0.9
Atom 0.3
Misc RDF | CDF
View on Mastodon
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
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)
printf(%8d%8d%8d\n", lines, words, chars);
Any ideas and help is welcome. Thanks alot.
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?