Buildsystems and what the heck for we actually use the autotools
Tom´ aˇ s Chv´ atal
SUSE Packagers team
Buildsystems and what the heck for we actually use the autotools - - PowerPoint PPT Presentation
Buildsystems and what the heck for we actually use the autotools Tom a s Chv atal SUSE Packagers team 2013/07/19 Introduction Who the hell is Tom a s Chv atal SUSE Employee since 2011 - Team lead of packagers team
SUSE Packagers team
3 of 37
5 of 37
7 of 37
CC ?= @CC@ CFLAGS ?= @CFLAGS@ PROGRAM = examplebinary OBJ = main . o p a r s e r . o output . o $ (PROGRRAM) : $ (OBJ) $ (CC) $ (LDFLAGS) −o $@ $ˆ main . o : main . c common . h p a r s e r . o : p a r s e r . c common . h
i n s t a l l : $ (PROGRAM) # You have to use tabs here $ (INSTALL) $ (PROGRAM) $ (BINDIR) clean : $ (RM) $ (OBJ)
8 of 37
9 of 37
10 of 37
12 of 37
AC INIT ( example , 0.1 , bugs@example . com) AC CONFIG HEADER ( [ c o n f i g . h ] ) AC PROG C AC PROG CPP AC PROG INSTALL AC HEADER STDC AC CHECK HEADERS ( [ s t r i n g . h u n i s t d . h l i m i t s . h ] ) AC CONFIG FILES ( [ Makefile doc/ Makefile s r c / Makefile ] ) AC OUTPUT
13 of 37
14 of 37
bin PROGRAMS = examplebinary examplebinary SOURCES = \ s r c /main . c \ s r c / p a r s e r . c \ s r c / output . c \ s r c / setup . c noinst HEADERS = s r c /common . h s r c / setup . h
15 of 37
16 of 37
17 of 37
18 of 37
20 of 37
LT VERSION=m4 esyscmd ( [ . / v e r s i o n . sh −v ] ) LT INIT ( [ d i s a b l e −s t a t i c pic −only ] ) AC PROG LIBTOOL
21 of 37
lib LTLIBRARIES = libexample . l a libexample la SOURCES = \ s r c / something . c \ s r c / somethingelse . c \ s r c / whatever . c libexample la CFLAGS = \ $ (MYEXTERNALPACKAGE CFLAGS) libexample la LDFLAGS = \ $ (MYEXTERNALPACKAGE LIBS) \ −version −i n f o $ (LT VERSION) \ −export −symbols−regex ’ˆ foo ’
22 of 37
24 of 37
AC MSG CHECKING ( [ f o r n a t i v e Win32 ] ) AS CASE ( [ $host ] , [∗−∗−mingw ∗] , [ n a t i v e w i n 3 2=yes BINARY WIN32 RESOURCE=binary−win32res . l o AC CHECK TOOL(WINDRES, windres ) ] , [ n a t i v e w i n 3 2=no BINARY WIN32 RESOURCE= ] ) # Ensure compat with MSVC AS IF ( [ t e s t ” x $ n a t i v e w i n 3 2 ” = ” xyes ” ] , [ AC CHECK TOOL(WINDRES, windres ) AS IF ( [ t e s t x”$GCC” = xyes ] , [ AC MSG CHECKING ( [ how to get MSVC −compatible s t r u c t packing ] ) AS IF ( [ t e s t −z ” $ac cv prog CC ” ] , [
] , [
] ) AS IF ( [ $our gcc −v − −help 2>/dev / n u l l | grep ms −b i t f i e l d s >/dev / n u l l ] , [ m s n a t i v e s t r u c t=” −mms −b i t f i e l d s ” CFLAGS=”$CFLAGS $ m s n a t i v e s t r u c t ” CXXFLAGS=”$CXXFLAGS $ m s n a t i v e s t r u c t ” AC MSG RESULT ( [ ${ m s n a t i v e s t r u c t }]) ] , [ AC MSG RESULT ( [ no way ] ) AC MSG WARN( [ produced l i b r a r i e s might be i n c o m p a t i b l e with MSVC −co ] ) 25 of 37
bin PROGRAMS = examplebinary examplebinary SOURCES = \ s r c /main . c \ s r c / p a r s e r . c \ s r c / output . c \ s r c / setup . c examplebinary LDADD = \ $ (OTHER LIBS) \ @BINARY WIN32 RESOURCE@ noinst HEADERS = s r c /common . h s r c / setup . h i f OS WIN32 @BINARY WIN32 RESOURCE@ : examplebinary . rc $ ( examplebinary OBJECTS ) chmod +x $ ( t o p s r c d i r )/ b u i l d /∗ compile−r e s o u r c e && \ WINDRES=@WINDRES@ $ ( t o p s r c d i r )/ b u i l d / l t −compile−r e s o u r c e examplebinary . rc @BINARY e n d i f 26 of 37
27 of 37
28 of 37
30 of 37
31 of 37
cmake minimum required (VERSION 2.8) p r o j e c t ( example C) s e t (Example VERSION MAJOR 0) s e t (Example VERSION MINOR 1) s e t (src EXAMPLE s r c /main . c s r c / p a r s e r . c s r c / output . c s r c / setup . c s r c /common . h s r c / setup . h ) add executable ( examplebinary ${src EXAMPLE}) i n s t a l l (TARGETS examplebinary DESTINATION bin )
32 of 37
i n c l u d e ( I n s t a l l R e q u i r e d S y s t e m L i b r a r i e s ) s e t (CPACK RESOURCE FILE LICENSE ”${CMAKE CURRENT SOURCE DIR}/LICENSE”) s e t (CPACK PACKAGE VERSION MAJOR ”${Tutorial VERSION MAJOR s e t (CPACK PACKAGE VERSION MINOR ”${Tutorial VERSION MINOR i n c l u d e ( CPack )
33 of 37
35 of 37
37 of 37