[PHP] parse a Makefile

2006-04-03 Thread Benjamin D Adams
I'm trying to parse a Makefile, (FreeBSD Ports)
I plan on dumping the Makefile vars to a MySQL Database.

Would I parse the make file like a ini file?
Or would I have to use something different?

Maybe someone knows a tool that can do this for me?

Thanks
Ben

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] parse a Makefile

2006-04-03 Thread Peter Hoskin

Makefile's are not ini files.

ini files have the structure
[section]
variable=value
[section2]
variable2=value2

Makefiles have the structure
variable=value

Benjamin D Adams wrote:

I'm trying to parse a Makefile, (FreeBSD Ports)
I plan on dumping the Makefile vars to a MySQL Database.

Would I parse the make file like a ini file?
Or would I have to use something different?

Maybe someone knows a tool that can do this for me?

Thanks
Ben

  


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] parse a Makefile

2006-04-03 Thread Kevin Kinsey

Benjamin D Adams wrote:


I'm trying to parse a Makefile, (FreeBSD Ports)
I plan on dumping the Makefile vars to a MySQL Database.

Would I parse the make file like a ini file?
Or would I have to use something different?

Maybe someone knows a tool that can do this for me?

Thanks
Ben
 



Try file() and ereg() or preg_match.  If the Makefile
has standard format you're looking for

FOOBAR=some string here

so reading the file into an array (the file() call) and
using a regular expression conditional (to determine
if you're looking at a variable or something else)
might be quite enough to do the trick.

HTH,

Kevin Kinsey

--
A pedestal is as much a prison as any small, confined space.
-- Gloria Steinem

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php