log in | register | forums


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

Advanced search
Recent discussions
- Rougol March 2023 Meeting - Nemo and IFR (News:)
- ROUGOL March 2023 meeting with Nemo (News:2)
- Source code for 6502Em and Z80Em (Gen:2)
- Free Tap Plane game released for RISC OS (News:)
- PiTools 1.20 released (News:3)
- South-West Show 2023 Report (News:1)
- RISC OS online Developer social meetup (News:)
- February 2023 News Summary (News:1)
- South-West Show 2023 talks (News:2)
- RISCOSbits new FAST systems reviewed (News:1)
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
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?