Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 246
  • Last Modified:

question about autoconf

I've written a package that uses autoconf, and automake.  I am having trouble figuring out how to set my log file for the program though.  I want the program to use the --localstatedir as the log directory.

How do I make the command
%make install
create the localstatedir, and how can I make my program use that for the log directory?  
0
lwinkenb
Asked:
lwinkenb
  • 2
  • 2
1 Solution
 
AxterCommented:
Modify your make file so that the link command includes the "--localstatedir" option.
0
 
greyfairerCommented:
in your automake.am you could use
CPPFLAGS = -DLOCAL_STATE_DIR=\"$(localstatedir)\"

in your program you should then be able to use
char filename[] = LOCAL_STATE_DIR "/log1.txt"

something like that,

Geert.
0
 
lwinkenbAuthor Commented:
Thanks, that works for accessing the localstatedir from my program.  Now do I make sure the directory is created when the user runs 'make install'?
0
 
greyfairerCommented:
not sure if it's the best solution, but a local install hook should do.

in your Makefile.am:

install-data-local:
     $(mkinstalldirs) $(localstatedir)
0
 
lwinkenbAuthor Commented:
Thanks for your help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now