We can even install it already:
---------------------------------
-$ make install prefix=/opt
- INSTALL hello /opt/bin
-$ ls /opt/bin
-hello prog
+$ make install prefix=/opt DESTDIR=./inst
+ INSTALL hello ./inst/opt/bin
+$ ls ./inst/opt/bin
+hello
---------------------------------
For creating source package, we need to provide additional info:
COPY myhello-1.0
PACK myhello-1.0.tar.gz
$ ls
-Makefile antimake.mk hello hello.c myhello-1.0.tar.gz
+Makefile antimake.mk hello hello.c inst myhello-1.0.tar.gz
$ tar tzf myhello-1.0.tar.gz | sort
myhello-1.0/
myhello-1.0/Makefile
$ make clean
CLEAN hello
$ ls
-Makefile antimake.mk hello.c myhello-1.0.tar.gz
+Makefile antimake.mk hello.c inst myhello-1.0.tar.gz
---------------------------------
Done!
Prepare sources
+.File: api.h
+[source,c]
+-----------------------------------
+void func1(void);
+void func2(void);
+void func3(void);
+-----------------------------------
.File: main.c
[source,c]
-----------------------------------
#include <stdio.h>
+#include "api.h"
int main(void)
{
[source,c]
-----------------------------------
#include <stdio.h>
+#include "api.h"
void func1(void)
{
[source,c]
-----------------------------------
#include <stdio.h>
+#include "api.h"
void func2(void)
{
[source,c]
-----------------------------------
#include <stdio.h>
+#include "api.h"
void func3(void)
{
noinst_LIBRARIES = func1.a
func1_a_SOURCES = func1.c
+func1_a_CPPFLAGS = -I..
EXTRA_DIST = Makefile
noinst_LIBRARIES = func2.a
func2_a_SOURCES = func2.c
+func2_a_CPPFLAGS = -I../..
EXTRA_DIST = Makefile
noinst_LIBRARIES = func3.a
func3_a_SOURCES = func3.c
+func3_a_CPPFLAGS = -I$(top_srcdir)
EXTRA_DIST = Makefile
CC main.c
CCLD prog
$ ls
-Makefile antimake.mk lib1 lib2 main.c prog
+Makefile antimake.mk api.h lib1 lib2 main.c prog
$ ./prog
func1
func2
main
---------------------------------
-We can even install it already:
+We can now install it:
---------------------------------
-$ make install prefix=/opt
+$ make install DESTDIR=./inst
--> lib1
--> lib1/sublib
make[2]: Nothing to be done for `install'.
--> lib2
make[1]: Nothing to be done for `install'.
<-- lib2
- INSTALL prog /opt/bin
-$ ls /opt/bin
-hello prog
+ INSTALL prog ./inst/usr/local/bin
+$ ls ./inst/usr/local/bin
+prog
---------------------------------
Now we can create package that can be given to others.
COPY test-subdirs-1.0
PACK test-subdirs-1.0.tar.gz
$ ls
-Makefile antimake.mk lib1 lib2 main.c prog test-subdirs-1.0.tar.gz
+Makefile api.h lib1 main.c test-subdirs-1.0.tar.gz
+antimake.mk inst lib2 prog
$ tar tzf test-subdirs-1.0.tar.gz | sort
test-subdirs-1.0/
test-subdirs-1.0/Makefile
<-- lib2
CLEAN prog
$ ls
-Makefile antimake.mk lib1 lib2 main.c test-subdirs-1.0.tar.gz
+Makefile antimake.mk api.h inst lib1 lib2 main.c test-subdirs-1.0.tar.gz
---------------------------------
Test O=
CC ../main.c
CCLD prog
$ ls
-Makefile antimake.mk build lib1 lib2 main.c test-subdirs-1.0.tar.gz
+Makefile api.h inst lib2 test-subdirs-1.0.tar.gz
+antimake.mk build lib1 main.c
$ ls build
Makefile antimake.mk lib1 lib2 prog
---------------------------------
-----------------------------------
#include <stdio.h>
+void func1(void);
+void func2(void);
+void func3(void);
+
int main(void)
{
func1();
main
---------------------------------
-We can even install it already:
+We can now install it:
---------------------------------
-$ make install prefix=/opt
- INSTALL prog /opt/bin
-$ ls /opt/bin
-hello prog
+$ make install prefix=/opt DESTDIR=./inst
+ INSTALL prog ./inst/opt/bin
+$ ls ./inst/opt/bin
+prog
---------------------------------
Now we can create package that can be given to others.
COPY test-subdirs-1.0
PACK test-subdirs-1.0.tar.gz
$ ls
-Makefile antimake.mk lib1 lib2 main.c prog src test-subdirs-1.0.tar.gz
+Makefile inst lib2 prog test-subdirs-1.0.tar.gz
+antimake.mk lib1 main.c src
$ tar tzf test-subdirs-1.0.tar.gz | sort
test-subdirs-1.0/
test-subdirs-1.0/Makefile
CLEAN lib2/func3.a
CLEAN clean
$ ls
-Makefile antimake.mk lib1 lib2 main.c src test-subdirs-1.0.tar.gz
+Makefile antimake.mk inst lib1 lib2 main.c src test-subdirs-1.0.tar.gz
---------------------------------
Done!
.File: autogen.sh
[source,shell]
-----------------------------------
-libtoolize -i -q
-aclocal -I../../../m4
-autoconf
-rm -rf autom4te.cache ltmain.sh aclocal.m4
+../../std-autogen.sh ../../..
# fetch Antimake template from libusual
cp ../../antimake.mk antimake.mk.in
.File: autogen.sh
[source,shell]
-----------------------------------
-libtoolize -i -q
-aclocal -I../../../m4
-autoconf
-rm -rf autom4te.cache aclocal.m4
+../../std-autogen.sh ../../..
# fetch Antimake template from libusual
cp ../../antimake.mk antimake.mk.in
-----------------------------------
#include <stdio.h>
+void func1(void);
void func1(void)
{
printf("hello from func1\n");
.File: autogen.sh
[source,shell]
-----------------------------------
-libtoolize -i -q
-aclocal -I../../../m4
-autoconf
-rm -rf autom4te.cache aclocal.m4
+../../std-autogen.sh ../../..
# fetch Antimake template from libusual
grep -Ei '@[a-z_]+@' ../../antimake.mk > build.mk.in
SUBDIRS = sub
EMBED_SUBDIRS = esub
+override WFLAGS = -Wall
+
EXTRA_DIST = Makefile antimake.mk $(MAINTAINERCLEANFILES)
# clean configured files
---------------------------------
$ make maintainer-clean
- CLEAN esub/libfunc4.a
- CLEAN esub/esub/libfunc6.a
- CLEAN cpptest
- CLEAN esub/prog
--> sub
- CLEAN libfunc1.a
- CLEAN esub/libfunc2.a
--> sub/sub
CLEAN libfunc3.a
<-- sub/sub
+ CLEAN libfunc1.a
+ CLEAN esub/libfunc2.a
CLEAN clean
<-- sub
--> esub/sub
CLEAN libfunc5.a
<-- esub/sub
+ CLEAN esub/libfunc4.a
+ CLEAN esub/esub/libfunc6.a
+ CLEAN cpptest
+ CLEAN esub/prog
CLEAN clean
--> sub
- CLEAN libfunc1.a
- CLEAN esub/libfunc2.a
--> sub/sub
CLEAN libfunc3.a
<-- sub/sub
+ CLEAN libfunc1.a
+ CLEAN esub/libfunc2.a
CLEAN clean
--> sub/sub
CLEAN libfunc3.a
$ cd lib
$ ./autogen.sh
[...]
-$ ./configure --disable-shared --prefix=/home/marko/src/libusual/mk/temos/tmp/lib/../inst
+$ ./configure --disable-shared --prefix=/opt
[...]
$ make
[...]
-$ make install
+$ make install DESTDIR=`pwd`/../inst
[...]
$ cd ..
---------------------------------
OBJS = $(SRCS:.c=.o)
# here we link to libusual
-CPPFLAGS = -I./inst/include
-LDFLAGS = -L./inst/lib
+CPPFLAGS = -I./inst/opt/include
+LDFLAGS = -L./inst/opt/lib
LIBS = -lusual
CC = gcc
---------------------------------
$ make
-gcc -O -g -Wall -I./inst/include -c -o prog.o prog.c
-gcc -O -g -Wall -L./inst/lib prog.o -lusual -o prog
+gcc -O -g -Wall -I./inst/opt/include -c -o prog.o prog.c
+gcc -O -g -Wall -L./inst/opt/lib prog.o -lusual -o prog
$ ls
Makefile inst lib prog prog.c prog.o
$ ./prog
run ./hello
msg We can even install it already:
-run make install prefix=/opt
-run ls /opt/bin
+run make install prefix=/opt DESTDIR=./inst
+run ls ./inst/opt/bin
msg For creating source package, we need to provide additional info:
msg Prepare sources
+cat_file api.h <<"EOF"
+ void func1(void);
+ void func2(void);
+ void func3(void);
+EOF
+
cat_file main.c <<"EOF"
#include <stdio.h>
+ #include "api.h"
int main(void)
{
cat_file lib1/func1.c <<"EOF"
#include <stdio.h>
+ #include "api.h"
void func1(void)
{
cat_file lib1/sublib/func2.c <<"EOF"
#include <stdio.h>
+ #include "api.h"
void func2(void)
{
cat_file lib2/func3.c <<"EOF"
#include <stdio.h>
+ #include "api.h"
void func3(void)
{
noinst_LIBRARIES = func1.a
func1_a_SOURCES = func1.c
+ func1_a_CPPFLAGS = -I..
EXTRA_DIST = Makefile
noinst_LIBRARIES = func2.a
func2_a_SOURCES = func2.c
+ func2_a_CPPFLAGS = -I../..
EXTRA_DIST = Makefile
noinst_LIBRARIES = func3.a
func3_a_SOURCES = func3.c
+ func3_a_CPPFLAGS = -I$(top_srcdir)
EXTRA_DIST = Makefile
run ls
run ./prog
-msg We can even install it already:
-run make install prefix=/opt
-run ls /opt/bin
+msg We can now install it:
+run make install DESTDIR=./inst
+run ls ./inst/usr/local/bin
msg Now we can create package that can be given to others.
run make dist
cat_file main.c <<"EOF"
#include <stdio.h>
+ void func1(void);
+ void func2(void);
+ void func3(void);
+
int main(void)
{
func1();
run ls
run ./prog
-msg We can even install it already:
-run make install prefix=/opt
-run ls /opt/bin
+msg We can now install it:
+run make install prefix=/opt DESTDIR=./inst
+run ls ./inst/opt/bin
msg Now we can create package that can be given to others.
run make dist
msg Autoconf setup
cat_file autogen.sh <<"EOF"
- libtoolize -i -q
- aclocal -I../../../m4
- autoconf
- rm -rf autom4te.cache ltmain.sh aclocal.m4
+ ../../std-autogen.sh ../../..
# fetch Antimake template from libusual
cp ../../antimake.mk antimake.mk.in
msg Autoconf setup
cat_file autogen.sh <<"EOF"
- libtoolize -i -q
- aclocal -I../../../m4
- autoconf
- rm -rf autom4te.cache aclocal.m4
+ ../../std-autogen.sh ../../..
# fetch Antimake template from libusual
cp ../../antimake.mk antimake.mk.in
cat_file func.c <<"EOF"
#include <stdio.h>
+ void func1(void);
void func1(void)
{
printf("hello from func1\n");
msg Autoconf setup
cat_file autogen.sh <<"EOF"
- libtoolize -i -q
- aclocal -I../../../m4
- autoconf
- rm -rf autom4te.cache aclocal.m4
+ ../../std-autogen.sh ../../..
# fetch Antimake template from libusual
grep -Ei '@[a-z_]+@' ../../antimake.mk > build.mk.in
SUBDIRS = sub
EMBED_SUBDIRS = esub
+ override WFLAGS = -Wall
+
EXTRA_DIST = Makefile antimake.mk $(MAINTAINERCLEANFILES)
# clean configured files
run cd lib
runq ./autogen.sh
-runq ./configure --disable-shared --prefix=`pwd`/../inst
+runq ./configure --disable-shared --prefix=/opt
runq make
-runq make install
+runq make install 'DESTDIR=`pwd`/../inst'
run cd ..
OBJS = $(SRCS:.c=.o)
# here we link to libusual
- CPPFLAGS = -I./inst/include
- LDFLAGS = -L./inst/lib
+ CPPFLAGS = -I./inst/opt/include
+ LDFLAGS = -L./inst/opt/lib
LIBS = -lusual
CC = gcc