Hello,I've been reading the manuals for autoconf/automake and have been unable to get a setup working correctly with autoconf. I've written up a toy shared library and right now the Makefile has a rule to install the library directly to `/usr/local`. All I really want from autoconf is to be able to have `--prefix` user-configurable. I figured it was better to use autoconf/automake than reinvent the wheel, but I'm totally unable to get it working.
Does anyone here know a source for a very simple example of what is needed (configure.ac/Makefile.in) to get this type of setup working? I've been reading both manuals, but I can't figure it out. Maybe someone here can even immediately see how to do this.
I'm attaching an extremely simplified version of a shared library setup. I'm also pasting the text of the files in below in case you just want to read directly (instead of extracting something from a random person on the internet). Basically if you run `make` it compiles a shared library for you with publicly exports one function called `public_func`. If you run `make test` it will test it by setting the current directory to LD_LIBRARY_PATH. You can install it by running `make install` and then ldconfig (though I doubt you want to...). This is the repo structure:
. ├── include │ └── public.h ├── Makefile ├── src │ ├── private.c │ ├── private.h │ └── public.c └── test.c Here are the files: include/public.h ----------------------------------- int public_func(void); ----------------------------------- src/public.h ----------------------------------- #include <private.h> int public_func(void) { return private_func(); } ----------------------------------- src/private.h ----------------------------------- int private_func(void); ----------------------------------- src/private.c ----------------------------------- #include <private.h> int private_func(void) { return 1; } ----------------------------------- test.c ----------------------------------- #include <public.h> #include <stdio.h> int main(void) { printf("public value: %d\n", public_func()); return 0; } ----------------------------------- Makefile ----------------------------------- so = libpublic.so solinkname = -lpublic install_target = /usr/local srcs = $(wildcard src/*.c) objs = $(patsubst %.c,%.o,$(srcs)) includes = include/public.h installed_includes = $(addprefix $(install_target)/,$(includes)) cc = gcc cflags = -c -g -fPIC -Wall -Wextra -Wfatal-errors -pedantic-errors privateincludedirs = -Isrc publicincludedirs = -Iinclude ldflags = -shared -Wl,-soname,$(so) all: $(so) $(so): $(objs) $(cc) $(ldflags) $(objs) -o $(so) %.o:%.c $(cc) $(cflags) $(privateincludedirs) -c -o $@ $< clean: rm -f *.o src/*.o *.so test install: cp -v $(includes) $(install_target)/include cp -v $(so) $(install_target)/lib ----------------------------------- Thanks for any help! Cheers, Thomas
Attachment:
library.tar.bz2
Description: application/bzip
_______________________________________________ Autoconf mailing list Autoconf@xxxxxxx https://lists.gnu.org/mailman/listinfo/autoconf