Trying to create makefile for lex program

时间:2016-02-12 20:11:21

标签: c lex

Notice, I'm new to "makefile"

I have program called "ba.lex" I need to create make file for it.

without the makefile, I first call:

flex ba.lex

then, I create executable:

gcc -o ba lex.yy.c -lfl

I will also need to clean the intermediate file: lex.yy.c

How I could put these on a makefile.

Update: I tried this:

flex ba.lex
gcc -o ba lex.yy.c -lfl

but I'm getting: makefile:1: *** commands commence before first target. Stop.

1 个答案:

答案 0 :(得分:3)

In a var Codec: TCodec; CipherText: AnsiString; begin Codec := TCodec.Create(nil); try Codec.CryptoLibrary := TCryptographicLibrary.Create(Codec); // Codec.StreamCipherId = 'native.StreamToBlock'; Codec.BlockCipherId = 'native.AES-256'; Codec.ChainModeId = 'native.CTR'; // Codec.Password := 'my password'; Codec.DecryptAnsiString(CipherText, 'oyC1KRVx3JZBLlI='); // Result := string(CipherText); finally Codec.Free; end; end; you don't just write commands, that's what shell scripts are for. A Makefile has 3 main entities:

  • targets
  • dependencies
  • commands to run

A very simple Makefile example can be this one:

Makefile

Here, build: a.out a.out: a.c <TAB> gcc -Wall a.c is a target that depends on build (which is a file, but we've also created a target with that name). The target a.out depends on a.out file. What happens when you run a.c is:

make

In your case, a possible if (! file_exists(a.out) || last_change(a.out) < last_change(a.c)) then execute gcc command can be:

Makefile