From 954c5504a03a061ff43ec6c5334f342bd919badd Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Tue, 17 Jul 2012 00:22:29 +0200 Subject: changed build system to autofoo. previous Makefile is now Makefile.shared --- Makefile | 84 ------------------------------------- Makefile.am | 12 ++++++ Makefile.shared | 84 +++++++++++++++++++++++++++++++++++++ autogen.sh | 15 +++++++ configure.ac | 110 +++++++++++++++++++++++++++++++++++++++++++++++++ include/Makefile.am | 1 + libirecovery.pc.in | 11 +++++ m4/as-compiler-flag.m4 | 62 ++++++++++++++++++++++++++++ src/Makefile.am | 17 ++++++++ 9 files changed, 312 insertions(+), 84 deletions(-) delete mode 100644 Makefile create mode 100644 Makefile.am create mode 100644 Makefile.shared create mode 100755 autogen.sh create mode 100644 configure.ac create mode 100644 include/Makefile.am create mode 100644 libirecovery.pc.in create mode 100644 m4/as-compiler-flag.m4 create mode 100644 src/Makefile.am diff --git a/Makefile b/Makefile deleted file mode 100644 index 05fd4ef..0000000 --- a/Makefile +++ /dev/null @@ -1,84 +0,0 @@ -MACHINE := $(shell $(CC) -dumpmachine) - -ifeq ($(findstring darwin,$(MACHINE)), darwin) - CFLAGS = -I./include -I/usr/local/include -I/opt/local/include - LDFLAGS = -L/usr/lib -L/opt/local/lib - LIBS = -lusb-1.0 -framework CoreFoundation -framework IOKit - - IRECOVERY_TARGET = irecovery - IRECOVERY_LDFLAGS = $(LDFLAGS) - IRECOVERY_LIBS = $(LIBS) -lreadline - - LIBIRECOVERY_STATIC_TARGET = libirecovery.a - - LIBIRECOVERY_SHARED_TARGET = libirecovery.dylib - LIBIRECOVERY_SHARED_LDFLAGS = $(LDFLAGS) -dynamiclib - LIBIRECOVERY_SHARED_LIBS = $(LIBS) -endif - -ifeq ($(findstring linux,$(MACHINE)), linux) - CFLAGS = -fPIC -O3 -I./include -I/usr/include -I/usr/local/include - LDFLAGS = -L/usr/lib -L/usr/local/lib - LIBS = -lusb-1.0 - - IRECOVERY_TARGET = irecovery - IRECOVERY_LDFLAGS = $(LDFLAGS) - IRECOVERY_LIBS = $(LIBS) -lreadline - - LIBIRECOVERY_STATIC_TARGET = libirecovery.a - - LIBIRECOVERY_SHARED_TARGET = libirecovery.so - LIBIRECOVERY_SHARED_LDFLAGS = $(LDFLAGS) -shared -W1,-soname,$(LIBIRECOVERY_SHARED_TARGET) - LIBIRECOVERY_SHARED_LIBS = $(LIBS) -endif - -WIN32= -ifeq ($(findstring cygwin,$(MACHINE)), cygwin) - WIN32=1 - CC=gcc-3 -endif -ifeq ($(findstring mingw32,$(MACHINE)), mingw32) - WIN32=1 -endif -ifdef WIN32 - CFLAGS = -O3 -DWIN32 -I include -I c:\mingw\include - LDFLAGS = -static-libgcc -L c:\mingw\lib -L c:\mingw\bin - LIBS = -lkernel32 -lmsvcrt -lsetupapi - - IRECOVERY_TARGET = irecovery.exe - IRECOVERY_LDFLAGS = $(LDFLAGS) - IRECOVERY_LIBS = $(LIBS) -lreadline - - LIBIRECOVERY_STATIC_TARGET = libirecovery.a - - LIBIRECOVERY_SHARED_TARGET = libirecovery.dll - LIBIRECOVERY_SHARED_LDFLAGS = $(LDFLAGS) -shared - LIBIRECOVERY_SHARED_LIBS = $(LIBS) -endif - -LIBIRECOVERY_OBJECTS = src/libirecovery.o -IRECOVERY_OBJECTS = src/irecovery.o libirecovery.a - -TARGETS = $(LIBIRECOVERY_SHARED_TARGET) $(LIBIRECOVERY_STATIC_TARGET) $(IRECOVERY_TARGET) -OBJECTS = src/libirecovery.o src/irecovery.o - -all: $(TARGETS) - -%.o: %.S - $(CC) -c $(<) -o $(@) $(CFLAGS) - -%.o: %.c - $(CC) -c $(<) -o $(@) $(CFLAGS) - -$(LIBIRECOVERY_STATIC_TARGET): $(LIBIRECOVERY_OBJECTS) - $(AR) rs $@ $^ - -$(LIBIRECOVERY_SHARED_TARGET): $(LIBIRECOVERY_OBJECTS) - $(CC) -o $@ $^ $(LIBIRECOVERY_SHARED_LDFLAGS) $(LIBIRECOVERY_SHARED_LIBS) - -$(IRECOVERY_TARGET): $(IRECOVERY_OBJECTS) - $(CC) -o $@ $^ $(IRECOVERY_LDFLAGS) $(IRECOVERY_LIBS) - -clean: - $(RM) $(LIBIRECOVERY_STATIC_TARGET) $(LIBIRECOVERY_SHARED_TARGET) $(IRECOVERY_TARGET) src/*.o - diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..3c8e304 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,12 @@ +AUTOMAKE_OPTIONS = foreign +ACLOCAL_AMFLAGS = -I m4 +SUBDIRS = src include + +DISTCHECK_CONFIGURE_FLAGS = + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = libirecovery.pc + +indent: + indent -kr -ut -ts4 -l120 src/*.c src/*.h + diff --git a/Makefile.shared b/Makefile.shared new file mode 100644 index 0000000..05fd4ef --- /dev/null +++ b/Makefile.shared @@ -0,0 +1,84 @@ +MACHINE := $(shell $(CC) -dumpmachine) + +ifeq ($(findstring darwin,$(MACHINE)), darwin) + CFLAGS = -I./include -I/usr/local/include -I/opt/local/include + LDFLAGS = -L/usr/lib -L/opt/local/lib + LIBS = -lusb-1.0 -framework CoreFoundation -framework IOKit + + IRECOVERY_TARGET = irecovery + IRECOVERY_LDFLAGS = $(LDFLAGS) + IRECOVERY_LIBS = $(LIBS) -lreadline + + LIBIRECOVERY_STATIC_TARGET = libirecovery.a + + LIBIRECOVERY_SHARED_TARGET = libirecovery.dylib + LIBIRECOVERY_SHARED_LDFLAGS = $(LDFLAGS) -dynamiclib + LIBIRECOVERY_SHARED_LIBS = $(LIBS) +endif + +ifeq ($(findstring linux,$(MACHINE)), linux) + CFLAGS = -fPIC -O3 -I./include -I/usr/include -I/usr/local/include + LDFLAGS = -L/usr/lib -L/usr/local/lib + LIBS = -lusb-1.0 + + IRECOVERY_TARGET = irecovery + IRECOVERY_LDFLAGS = $(LDFLAGS) + IRECOVERY_LIBS = $(LIBS) -lreadline + + LIBIRECOVERY_STATIC_TARGET = libirecovery.a + + LIBIRECOVERY_SHARED_TARGET = libirecovery.so + LIBIRECOVERY_SHARED_LDFLAGS = $(LDFLAGS) -shared -W1,-soname,$(LIBIRECOVERY_SHARED_TARGET) + LIBIRECOVERY_SHARED_LIBS = $(LIBS) +endif + +WIN32= +ifeq ($(findstring cygwin,$(MACHINE)), cygwin) + WIN32=1 + CC=gcc-3 +endif +ifeq ($(findstring mingw32,$(MACHINE)), mingw32) + WIN32=1 +endif +ifdef WIN32 + CFLAGS = -O3 -DWIN32 -I include -I c:\mingw\include + LDFLAGS = -static-libgcc -L c:\mingw\lib -L c:\mingw\bin + LIBS = -lkernel32 -lmsvcrt -lsetupapi + + IRECOVERY_TARGET = irecovery.exe + IRECOVERY_LDFLAGS = $(LDFLAGS) + IRECOVERY_LIBS = $(LIBS) -lreadline + + LIBIRECOVERY_STATIC_TARGET = libirecovery.a + + LIBIRECOVERY_SHARED_TARGET = libirecovery.dll + LIBIRECOVERY_SHARED_LDFLAGS = $(LDFLAGS) -shared + LIBIRECOVERY_SHARED_LIBS = $(LIBS) +endif + +LIBIRECOVERY_OBJECTS = src/libirecovery.o +IRECOVERY_OBJECTS = src/irecovery.o libirecovery.a + +TARGETS = $(LIBIRECOVERY_SHARED_TARGET) $(LIBIRECOVERY_STATIC_TARGET) $(IRECOVERY_TARGET) +OBJECTS = src/libirecovery.o src/irecovery.o + +all: $(TARGETS) + +%.o: %.S + $(CC) -c $(<) -o $(@) $(CFLAGS) + +%.o: %.c + $(CC) -c $(<) -o $(@) $(CFLAGS) + +$(LIBIRECOVERY_STATIC_TARGET): $(LIBIRECOVERY_OBJECTS) + $(AR) rs $@ $^ + +$(LIBIRECOVERY_SHARED_TARGET): $(LIBIRECOVERY_OBJECTS) + $(CC) -o $@ $^ $(LIBIRECOVERY_SHARED_LDFLAGS) $(LIBIRECOVERY_SHARED_LIBS) + +$(IRECOVERY_TARGET): $(IRECOVERY_OBJECTS) + $(CC) -o $@ $^ $(IRECOVERY_LDFLAGS) $(IRECOVERY_LIBS) + +clean: + $(RM) $(LIBIRECOVERY_STATIC_TARGET) $(LIBIRECOVERY_SHARED_TARGET) $(IRECOVERY_TARGET) src/*.o + diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..3292973 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,15 @@ +#!/bin/sh +gprefix=`which glibtoolize 2>&1 >/dev/null` +if [ $? -eq 0 ]; then + glibtoolize --force +else + libtoolize --force +fi +aclocal -I m4 +autoheader +automake --add-missing +autoconf + +if [ -z "$NOCONFIGURE" ]; then + ./configure "$@" +fi diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..a5afb57 --- /dev/null +++ b/configure.ac @@ -0,0 +1,110 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.61) +AC_INIT(libirecovery, 0.1.0, nospam@nowhere.com) +AM_INIT_AUTOMAKE([dist-bzip2 no-dist-gzip]) +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES]) +AC_CONFIG_SRCDIR([src/]) +AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_MACRO_DIR([m4]) + +dnl libtool versioning +# +1 : 0 : +1 == adds new functions to the interface +# +1 : 0 : 0 == changes or removes functions (changes include both +# changes to the signature and the semantic) +# ? :+1 : ? == just internal changes +# CURRENT : REVISION : AGE +LIBIRECOVERY_SO_VERSION=0:0:0 + +AC_SUBST(LIBIRECOVERY_SO_VERSION) + +# Checks for programs. +AC_PROG_CC +AC_PROG_CXX +AM_PROG_CC_C_O +AC_PROG_LIBTOOL + +# Checks for libraries. +ACCFLAGS= +ACLDFLAGS= +ACLIBS= + +#echo $host_os +case "$host_os" in + darwin*) + ACCFLAGS+="-I\$(top_srcdir)/include -I/usr/local/include -I/opt/local/include" + ACLDFLAGS+="-L/usr/lib -L/usr/local/lib -L/opt/local/lib" + ACLIBS+="-lusb-1.0 -framework CoreFoundation -framework IOKit" + ;; + linux*) + ACCFLAGS+="-fPIC -O3 -I\$(top_srcdir)/include -I/usr/include -I/usr/local/include" + ACLDFLAGS+="-L/usr/lib -L/usr/local/lib" + ACLIBS+="-lusb-1.0" + ;; + mingw32*) + ACCFLAGS+="-O3 -DWIN32 -I$(top_srcdir)/include -Ic:/mingw/include" + ACLDFLAGS+="-static-libgcc -Lc:/mingw/lib -Lc:/mingw/bin" + ACLIBS+="-lkernel32 -lmsvcrt -lsetupapi" + ;; + cygwin*) + CC=gcc-3 + ACCFLAGS+="-O3 -DWIN32 -mno-cygwin -I$(top_srcdir)/include -I/usr/include" + ACLDFLAGS+="-static-libgcc -L/lib -L/usr/lib -L/bin" + ACLIBS+="-lkernel32 -lmsvcrt -lsetupapi" + ;; + *) + + ;; +esac + +IRECOVERY_LIBS=-lreadline +AC_SUBST(IRECOVERY_LIBS) + +# Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS([stdint.h stdlib.h string.h]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_TYPE_SIZE_T +AC_TYPE_SSIZE_T +AC_TYPE_UINT16_T +AC_TYPE_UINT32_T +AC_TYPE_UINT8_T + +# Checks for library functions. +AC_FUNC_MALLOC +AC_FUNC_REALLOC +AC_CHECK_FUNCS([strcasecmp strdup strerror strndup]) + +AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith -Wwrite-strings -Wswitch-default -Wno-unused-parameter") +AC_SUBST(GLOBAL_CFLAGS) + +LIBIRECOVERY_CFLAGS=$ACCFLAGS +LIBIRECOVERY_CFLAGS+=$GLOBAL_CFLAGS +LIBIRECOVERY_LDFLAGS=$ACLDFLAGS +LIBIRECOVERY_LIBS=$ACLIBS + +AC_SUBST(LIBIRECOVERY_CFLAGS) +AC_SUBST(LIBIRECOVERY_LDFLAGS) +AC_SUBST(LIBIRECOVERY_LIBS) + +m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) + +AC_OUTPUT([ +Makefile +src/Makefile +include/Makefile +libirecovery.pc +]) + +echo " +Configuration for $PACKAGE $VERSION: +------------------------------------------- + + Install prefix: .........: $prefix + + Now type 'make' to build $PACKAGE $VERSION, + and then 'make install' for installation. +" diff --git a/include/Makefile.am b/include/Makefile.am new file mode 100644 index 0000000..d0e4bd4 --- /dev/null +++ b/include/Makefile.am @@ -0,0 +1 @@ +nobase_include_HEADERS = libirecovery.h diff --git a/libirecovery.pc.in b/libirecovery.pc.in new file mode 100644 index 0000000..71f8e93 --- /dev/null +++ b/libirecovery.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libirecovery +Description: A library to talk to iBoot/iBSS in iDevices via USB +Version: @VERSION@ +Libs: -L${libdir} -lirecovery +Cflags: -I${includedir} + diff --git a/m4/as-compiler-flag.m4 b/m4/as-compiler-flag.m4 new file mode 100644 index 0000000..0f660cf --- /dev/null +++ b/m4/as-compiler-flag.m4 @@ -0,0 +1,62 @@ +dnl as-compiler-flag.m4 0.1.0 + +dnl autostars m4 macro for detection of compiler flags + +dnl David Schleef + +dnl $Id: as-compiler-flag.m4,v 1.1 2005/12/15 23:35:19 ds Exp $ + +dnl AS_COMPILER_FLAG(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED]) +dnl Tries to compile with the given CFLAGS. +dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags, +dnl and ACTION-IF-NOT-ACCEPTED otherwise. + +AC_DEFUN([AS_COMPILER_FLAG], +[ + AC_MSG_CHECKING([to see if compiler understands $1]) + + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $1" + + AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no]) + CFLAGS="$save_CFLAGS" + + if test "X$flag_ok" = Xyes ; then + m4_ifvaln([$2],[$2]) + true + else + m4_ifvaln([$3],[$3]) + true + fi + AC_MSG_RESULT([$flag_ok]) +]) + +dnl AS_COMPILER_FLAGS(VAR, FLAGS) +dnl Tries to compile with the given CFLAGS. + +AC_DEFUN([AS_COMPILER_FLAGS], +[ + list=$2 + flags_supported="" + flags_unsupported="" + AC_MSG_CHECKING([for supported compiler flags]) + for each in $list + do + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $each" + AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no]) + CFLAGS="$save_CFLAGS" + + if test "X$flag_ok" = Xyes ; then + flags_supported="$flags_supported $each" + else + flags_unsupported="$flags_unsupported $each" + fi + done + AC_MSG_RESULT([$flags_supported]) + if test "X$flags_unsupported" != X ; then + AC_MSG_WARN([unsupported compiler flags: $flags_unsupported]) + fi + $1="$$1 $flags_supported" +]) + diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..a7027ee --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,17 @@ +AM_CPPFLAGS = -I$(top_srcdir)/include + +AM_CFLAGS = $(LIBIRECOVERY_CFLAGS) +AM_LDFLAGS = $(LIBIRECOVERY_LDFLAGS) +AM_LIBS = $(LIBIRECOVERY_LIBS) + +lib_LTLIBRARIES = libirecovery.la +libirecovery_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBIRECOVERY_SO_VERSION) -no-undefined $(AM_LIBS) +libirecovery_la_SOURCES = \ + libirecovery.c + +bin_PROGRAMS = irecovery + +irecovery_SOURCES = irecovery.c +irecovery_CFLAGS = $(AM_CFLAGS) +irecovery_LDFLAGS = $(AM_LDFLAGS) $(IRECOVERY_LIBS) +irecovery_LDADD = ./libirecovery.la -- cgit v1.1-32-gdbae