Question

I am writing a small tool in c++. It is actually more of a framework that is open to customization. It has the following directory structure (simplified example).

src/  
   main/myexec          # linked to libapple.so
   apple/  
        coder/libapple.so  
        john/libapple.so  
          .  
          .  
        james/libapple.so  

Here, the directory "coder" is a generic dummy, with some example code to generate libapple.so. Different users can checkout this tool, create directories of their own, copy the template code from "coder" and customize as they wish. Depending on the configure option (indicating the user), the respective libapple.so needs to be generated.

As I mentioned, this is a simplified example. It is not a matter of generic programming, inheritance etc. In fact, similar to the "apple" folder there are others like "scripts", "docs", "configs" etc each having similar user specific folders. Also, the tool will be maintained at a single repository location to allow me to support & maintain all the code that is not specific to user. As a policy, users are expected to modify and check-in only the contents of their folders.

The problem I am facing is with "configure.ac". I do not want to use "AC_ARG_WITH" option as it would require each new user to edit configure.ac. Also for each user the AC_CONFIG_FILE entries would be exactly the same except for his folder name. I tried using "--enable-user=User" and then AC_SUBST(USERDIR), which also helps in setting "SUBDIRS = @USERDIR@" in Makefile.am. Everything looks good except for the fact that "Makefile.in" is not getting created under the user folder when I specify "AC_CONFIG_FILE = ([apple/${USERDIR}/Makefile])".

Please advice how to overcome this issue. In the worst case I may end up in creating softlinks :(

Était-ce utile?

La solution

After one full day of scratching my head, following is the solution that I have come up with.

Create a file "project_makefiles.m4.in" like this

AC_CONFIG_FILES([ apple/USERDIR/Makefile ]

Add the below to configure.ac

m4_include([project_makefiles.m4])

Create a wrapper script like "build.sh" which will create "project_makefiles.m4" from "project_makefiles.m4.in" by replacing "USERDIR". This is done before the automake.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top