Permalink
Browse files

rewrite buildsys with autotools

  • Loading branch information...
1 parent c923719 commit 6a4053298b541c9d28da50241e985270dc844f17 @falconindy committed Jul 17, 2012
View
@@ -1,5 +1,20 @@
+*.gz
*.o
+*.xz
+*~
+.deps
+.dirstamp
+Makefile
+Makefile.in
+aclocal.m4
+autom4te.cache
+build-aux
+config.h
+config.h.in
+config.log
+config.status
+configure
+libtool
pkgfile
-tags
pkgfile.1
-*.gz
+stamp-h1
View
@@ -1,37 +0,0 @@
-OUT = pkgfile
-VERSION = 1
-CPPFLAGS := -DVERSION=\"v$(VERSION)\" -D_FILE_OFFSET_BITS=64 $(CPPFLAGS)
-CFLAGS := -std=c99 -g -pedantic -pthread -Wall -Wextra $(CFLAGS) $(CPPFLAGS)
-LDFLAGS := -pthread -larchive -lpcre -lcurl $(LDFLAGS)
-
-PREFIX ?= /usr
-
-SRC = $(wildcard *.c)
-OBJ = $(SRC:.c=.o)
-
-all: $(OUT) doc
-$(OUT): $(OBJ)
-
-doc: pkgfile.1
-pkgfile.1: README.pod
- pod2man --section=1 --center="pkgfile Manual" --name="pkgfile" --release="pkgfile $(VERSION)" $< > $@
-
-$(OUT): $(OBJ)
- $(CC) -o $@ $(OBJ) $(LDFLAGS)
-
-install: all
- install -Dm755 pkgfile $(DESTDIR)$(PREFIX)/bin/pkgfile
- install -Dm644 pkgfile.1 $(DESTDIR)$(PREFIX)/share/man/man1/pkgfile.1
- install -dm775 $(DESTDIR)/var/cache/pkgfile
- install -Dm644 extra/bash_completion $(DESTDIR)/usr/share/bash-completion/completions/pkgfile
- install -Dm644 extra/command-not-found.bash $(DESTDIR)/usr/share/doc/pkgfile/command-not-found.bash
- install -Dm644 extra/command-not-found.zsh $(DESTDIR)/usr/share/doc/pkgfile/command-not-found.zsh
-
-dist:
- git archive --format=tar --prefix=$(OUT)-$(VERSION)/ v$(VERSION) | gzip -9 > $(OUT)-$(VERSION).tar.gz
-
-strip: $(OUT)
- strip --strip-all $(OUT)
-
-clean:
- $(RM) $(OBJ) $(OUT) pkgfile.1
View
@@ -0,0 +1,83 @@
+ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
+AM_MAKEFLAGS = --no-print-directory
+
+CLEANFILES = \
+ $(dist_man_MANS)
+
+bashcompletiondir=$(datarootdir)/bash-completion/completions
+shelldatadir = $(datarootdir)/doc/pkgfile
+
+shelldata_DATA = \
+ extra/command-not-found.bash \
+ extra/command-not-found.zsh
+
+dist_bashcompletion_DATA = \
+ extra/bash-completion
+
+EXTRA_DIST = \
+ README.pod \
+ extra/bash-completion \
+ extra/command-not-found.bash \
+ extra/command-not-found.zsh
+
+dist_man_MANS = \
+ pkgfile.1
+
+bin_PROGRAMS = \
+ pkgfile
+
+if USE_GIT_VERSION
+GIT_VERSION := $(shell git describe --abbrev=4 --dirty | sed 's/^v//')
+REAL_PACKAGE_VERSION = $(GIT_VERSION)
+DEFS += -DGIT_VERSION=\"$(GIT_VERSION)\"
+else
+REAL_PACKAGE_VERSION = $(PACKAGE_VERSION)
+endif
+
+AM_CFLAGS = \
+ -pthread \
+ $(WARNINGFLAGS)
+
+AM_LDFLAGS = \
+ -pthread \
+ $(GCLDFLAGS)
+
+AM_CPPFLAGS = \
+ -imacros $(top_builddir)/config.h \
+ -I${top_srcdir}/src
+
+pkgfile_SOURCES = \
+ src/match.c src/match.h \
+ src/pkgfile.c src/pkgfile.h \
+ src/repo.c src/repo.h \
+ src/result.c src/result.h \
+ src/update.c src/update.h \
+ src/macro.h
+
+pkgfile_CFLAGS = \
+ $(AM_CFLAGS) \
+ $(ARCHIVE_CFLAGS) \
+ $(CURL_CFLAGS) \
+ $(PCRE_CFLAGS)
+
+pkgfile_LDFLAGS = \
+ $(AM_LDFLAGS)
+
+pkgfile_LDADD = \
+ $(ARCHIVE_LIBS) \
+ $(CURL_LIBS) \
+ $(PCRE_LIBS)
+
+pkgfile.1: README.pod
+ $(AM_V_GEN)$(POD2MAN) \
+ --section=1 \
+ --center="pkgfile Manual" \
+ --name="PKGFILE" \
+ --release="pkgfile $(REAL_PACKAGE_VERSION)" $< > $@
+
+install-data-local:
+ $(MKDIR_P) $(DESTDIR)$(prefix)/share/bash-completion/completions
+ $(INSTALL_DATA) $(top_srcdir)/extra/bash-completion $(DESTDIR)$(bashcompletiondir)/pkgfile
+
+uninstall-local:
+ $(RM) $(DESTDIR)$(bashcompletiondir)/pkgfile
View
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exec autoreconf --install --symlink
View
@@ -0,0 +1,114 @@
+AC_PREREQ(2.60)
+AC_INIT(pkgfile,
+ [1],
+ [dreisner@archlinux.org])
+
+AC_CONFIG_SRCDIR([src/pkgfile.c])
+AC_CONFIG_AUX_DIR([build-aux])
+AC_CONFIG_MACRO_DIR([m4])
+AC_PREFIX_DEFAULT([/usr])
+AC_USE_SYSTEM_EXTENSIONS
+AC_SYS_LARGEFILE
+AC_PROG_CC_C99
+AC_PROG_INSTALL
+AC_PROG_SED
+AC_PROG_MKDIR_P
+AC_CHECK_PROGS([POD2MAN], [pod2man])
+
+AM_INIT_AUTOMAKE([foreign 1.11 -Wall -Wno-portability silent-rules tar-pax no-dist-gzip dist-xz subdir-objects])
+AM_SILENT_RULES([yes])
+
+PKG_CHECK_MODULES(PCRE, [ libpcre ])
+PKG_CHECK_MODULES(ARCHIVE, [ libarchive >= 3.0.0 ])
+PKG_CHECK_MODULES(CURL, [ libcurl >= 7.19.4 ])
+
+# Help line for using git version in pacman version string
+AC_ARG_ENABLE(git-version,
+ AS_HELP_STRING([--disable-git-version],
+ [enable use of git version in version string if available]),
+ [wantgitver=$enableval], [wantgitver=check])
+
+# Enable or disable use of git version in pacman version string
+AC_MSG_CHECKING(whether to use git version if available)
+if test "x$wantgitver" != "xno" ; then
+ AC_CHECK_PROGS([GIT], [git])
+ AC_CHECK_FILE([.git/], hasgitdir=yes)
+ if test $GIT -a "x$hasgitdir" = "xyes"; then
+ AC_MSG_RESULT([yes])
+ usegitver=yes
+ AC_DEFINE([USE_GIT_VERSION], , [Use GIT version in version string])
+ else
+ AC_MSG_RESULT([no, git or .git dir missing])
+ usegitver=no
+ fi
+else
+ AC_MSG_RESULT([no, disabled by configure])
+ usegitver=no
+fi
+AM_CONDITIONAL(USE_GIT_VERSION, test "x$usegitver" = "xyes")
+
+CC_CHECK_FLAGS_APPEND(with_cflags, [CFLAGS], [\
+ -g \
+ -pipe \
+ -Wall \
+ -W \
+ -Wextra \
+ -Wno-inline \
+ -Wvla \
+ -Wundef \
+ -Wformat=2 \
+ -Wlogical-op \
+ -Wsign-compare \
+ -Wformat-security \
+ -Wmissing-include-dirs \
+ -Wformat-nonliteral \
+ -Wold-style-definition \
+ -Wpointer-arith \
+ -Winit-self \
+ -Wdeclaration-after-statement \
+ -Wfloat-equal \
+ -Wmissing-prototypes \
+ -Wstrict-prototypes \
+ -Wredundant-decls \
+ -Wmissing-declarations \
+ -Wmissing-noreturn \
+ -Wshadow \
+ -Wendif-labels \
+ -Wstrict-aliasing=2 \
+ -Wwrite-strings \
+ -Wno-long-long \
+ -Wno-overlength-strings \
+ -Wno-unused-parameter \
+ -Wno-missing-field-initializers \
+ -Wno-unused-result \
+ -Wnested-externs \
+ -Wchar-subscripts \
+ -Wtype-limits \
+ -Wuninitialized \
+ -fno-common \
+ -fdiagnostics-show-option \
+ -fvisibility=hidden \
+ -ffunction-sections \
+ -fdata-sections])
+AC_SUBST([WARNINGFLAGS], $with_cflags)
+
+CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [ \
+ -Wl,--as-needed])
+AC_SUBST([GCLDFLAGS], $with_ldflags)
+
+AC_CONFIG_HEADERS(config.h)
+AC_CONFIG_FILES([
+ Makefile
+])
+
+AC_OUTPUT
+AC_MSG_RESULT([
+ prefix: ${prefix}
+ datarootdir: ${datarootdir}
+
+ using git version: ${usegitver}
+
+ compiler: ${CC}
+ cflags: ${with_cflags} ${CFLAGS}
+ ldflags: ${with_ldflags} ${LDFLAGS}
+])
File renamed without changes.
Oops, something went wrong.

0 comments on commit 6a40532

Please sign in to comment.