commit ca9010a6e792e6e6e532670e2c8af9c7cf0d23fe
parent 3a508b14aaadd0021511ede62abacc54b3ea66ee
Author: Michael Forney <mforney@mforney.org>
Date: Mon, 30 Dec 2013 19:28:04 -0800
Switch to using Makefiles directly
Diffstat:
9 files changed, 209 insertions(+), 247 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -1,29 +1,10 @@
*.o
*.lo
-.*.swp
+.*.sw*
-.deps/
-.libs/
-
-Makefile
-Makefile.in
-
-/aclocal.m4
-/ar-lib
-/autom4te.cache/
-/config.guess
-/config.log
-/config.status
-/config.sub
-/configure
-/depcomp
-/install-sh
-/libtool
-/ltmain.sh
-/m4/
-/missing
-
-/libwld.la
+/.deps/
+/libwld.a
+/libwld.so*
/wld.pc
/protocol/wayland-drm-client-protocol.h
/protocol/wayland-drm-protocol.c
diff --git a/Makefile b/Makefile
@@ -0,0 +1,148 @@
+# wld: Makefile
+
+include config.mk
+
+VERSION_MAJOR := 0
+VERSION_MINOR := 0
+VERSION := $(VERSION_MAJOR).$(VERSION_MINOR)
+
+WLD_LIB := libwld.so
+WLD_LIB_MAJOR := $(WLD_LIB).$(VERSION_MAJOR)
+WLD_LIB_MINOR := $(WLD_LIB_MAJOR).$(VERSION_MINOR)
+
+TARGETS := wld.pc libwld.a $(WLD_LIB) $(WLD_LIB_MAJOR) $(WLD_LIB_MINOR)
+CLEAN_FILES := $(TARGETS)
+
+WLD_REQUIRES = fontconfig pixman-1
+WLD_REQUIRES_PRIVATE = freetype2
+WLD_SOURCES = drawable.c color.c font.c
+WLD_HEADERS = wld.h
+
+ifeq ($(ENABLE_DEBUG),1)
+ WLD_CPPFLAGS += -DENABLE_DEBUG=1
+endif
+
+ifeq ($(ENABLE_DRM),1)
+ WLD_REQUIRES_PRIVATE += libdrm
+ WLD_SOURCES += drm.c dumb.c
+ WLD_HEADERS += drm.h
+endif
+
+ifeq ($(ENABLE_PIXMAN),1)
+ WLD_SOURCES += pixman.c
+ WLD_HEADERS += pixman.h
+endif
+
+ifeq ($(ENABLE_WAYLAND),1)
+ WLD_REQUIRES_PRIVATE += wayland-client
+ WLD_SOURCES += wayland.c
+ WLD_HEADERS += wayland.h
+
+ ifneq ($(findstring shm,$(WAYLAND_INTERFACES)),)
+ WLD_SOURCES += wayland-shm.c
+ WLD_HEADERS += wayland-shm.h
+ WLD_CPPFLAGS += -DWITH_WAYLAND_SHM=1
+ endif
+
+ ifneq ($(findstring drm,$(WAYLAND_INTERFACES)),)
+ WLD_SOURCES += wayland-drm.c protocol/wayland-drm-protocol.c
+ WLD_HEADERS += wayland-drm.h
+ WLD_CPPFLAGS += -DWITH_WAYLAND_DRM=1
+ endif
+endif
+
+ifneq ($(findstring intel,$(DRM_DRIVERS)),)
+ WLD_REQUIRES_PRIVATE += libdrm_intel intelbatch
+ WLD_SOURCES += intel.c
+ WLD_CPPFLAGS += -DWITH_DRM_INTEL=1
+endif
+
+ifeq ($(if $(V),$(V),0), 0)
+ define quiet
+ @echo " $1 $@"
+ @$(if $2,$2,$($1))
+ endef
+else
+ quiet = $(if $2,$2,$($1))
+endif
+
+WLD_STATIC_OBJECTS = $(WLD_SOURCES:%.c=%.o)
+WLD_SHARED_OBJECTS = $(WLD_SOURCES:%.c=%.lo)
+WLD_PACKAGES = $(WLD_REQUIRES) $(WLD_REQUIRES_PRIVATE)
+WLD_PACKAGE_CFLAGS ?= $(call pkgconfig,$(WLD_PACKAGES),cflags,CFLAGS)
+WLD_PACKAGE_LIBS ?= $(call pkgconfig,$(WLD_PACKAGES),libs,LIBS)
+
+CLEAN_FILES += $(WLD_STATIC_OBJECTS) $(WLD_SHARED_OBJECTS)
+
+FINAL_CFLAGS = $(CFLAGS) -std=c99
+FINAL_CPPFLAGS = $(CPPFLAGS) -D_XOPEN_SOURCE=700 -D_BSD_SOURCE
+
+# Warning/error flags
+FINAL_CFLAGS += -Werror=implicit-function-declaration -Werror=implicit-int \
+ -Werror=pointer-sign -Werror=pointer-arith \
+ -Wall -Wno-missing-braces
+
+ifeq ($(ENABLE_DEBUG),1)
+ FINAL_CPPFLAGS += -DENABLE_DEBUG=1
+ FINAL_CFLAGS += -g
+endif
+
+compile = $(call quiet,CC) $(FINAL_CPPFLAGS) $(FINAL_CFLAGS) -c -o $@ $< \
+ -MMD -MP -MF .deps/$(basename $<).d -MT $(basename $@).o -MT $(basename $@).lo
+link = $(call quiet,CCLD,$(CC)) $(FINAL_CFLAGS) -o $@ $^
+pkgconfig = $(sort $(foreach pkg,$(1),$(if $($(pkg)_$(3)),$($(pkg)_$(3)), \
+ $(shell $(PKG_CONFIG) --$(2) $(pkg)))))
+
+.PHONY: all
+all: $(TARGETS)
+
+include protocol/local.mk
+
+.deps:
+ @mkdir "$@"
+
+%.o: %.c | .deps
+ $(compile) $(WLD_CPPFLAGS) $(WLD_PACKAGE_CFLAGS)
+
+%.lo: %.c | .deps
+ $(compile) $(WLD_CPPFLAGS) $(WLD_PACKAGE_CFLAGS) -fPIC
+
+wayland-drm.o wayland-drm.lo: protocol/wayland-drm-client-protocol.h
+
+wld.pc: wld.pc.in
+ $(call quiet,GEN,sed) \
+ -e "s:@VERSION@:$(VERSION):" \
+ -e "s:@PREFIX@:$(PREFIX):" \
+ -e "s:@LIBDIR@:$(LIBDIR):" \
+ -e "s:@INCLUDEDIR@:$(INCLUDEDIR):" \
+ -e "s:@WLD_REQUIRES@:$(WLD_REQUIRES):" \
+ -e "s:@WLD_REQUIRES_PRIVATE@:$(WLD_REQUIRES_PRIVATE):" \
+ $< > $@
+
+libwld.a: $(WLD_STATIC_OBJECTS)
+ $(call quiet,AR) cr $@ $^
+
+$(WLD_LIB_MINOR): $(WLD_SHARED_OBJECTS)
+ $(link) $(WLD_PACKAGE_LIBS) -shared -Wl,-soname,$(WLD_LIB_MAJOR),-no-undefined
+
+$(WLD_LIB_MAJOR) $(WLD_LIB): $(WLD_LIB_MINOR)
+ $(call quiet,SYM,ln -sf) $< $@
+
+$(foreach dir,LIB PKGCONFIG,$(DESTDIR)$($(dir)DIR)) $(DESTDIR)$(INCLUDEDIR)/wld:
+ mkdir -p "$@"
+
+.PHONY: install
+install: $(TARGETS) | $(foreach dir,LIB PKGCONFIG,$(DESTDIR)$($(dir)DIR)) $(DESTDIR)$(INCLUDEDIR)/wld
+ install -m0644 wld.pc "$(DESTDIR)$(PKGCONFIGDIR)"
+ install -m0644 $(WLD_HEADERS) "$(DESTDIR)$(INCLUDEDIR)/wld"
+ install -m0644 libwld.a "$(DESTDIR)$(LIBDIR)"
+ install -m0755 $(WLD_LIB_MINOR) "$(DESTDIR)$(LIBDIR)"
+ ln -sf $(WLD_LIB_MINOR) "$(DESTDIR)$(LIBDIR)/$(WLD_LIB_MAJOR)"
+ ln -sf $(WLD_LIB_MINOR) "$(DESTDIR)$(LIBDIR)/$(WLD_LIB)"
+
+.PHONY: clean
+clean:
+ rm -rf $(CLEAN_FILES)
+
+-include .deps/*.d
+
diff --git a/Makefile.am b/Makefile.am
@@ -1,53 +0,0 @@
-# wld: Makefile.am
-
-ACLOCAL_AMFLAGS = -I m4
-AM_CFLAGS = $(fontconfig_CFLAGS) $(freetype_CFLAGS) $(pixman_CFLAGS)
-
-lib_LTLIBRARIES = libwld.la
-pkginclude_HEADERS = wld.h
-
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = wld.pc
-
-libwld_la_SOURCES = color.c drawable.c font.c
-libwld_la_LIBADD = $(fontconfig_LIBS) $(freetype_LIBS) $(pixman_LIBS)
-
-if ENABLE_DRM
- AM_CFLAGS += $(libdrm_CFLAGS)
- libwld_la_SOURCES += drm.c dumb.c
- pkginclude_HEADERS += drm.h
-endif
-
-if WITH_DRM_INTEL
- AM_CFLAGS += $(drm_intel_CFLAGS) $(intelbatch_CFLAGS)
- libwld_la_SOURCES += intel.c
- libwld_la_LIBADD += $(drm_intel_LIBS) $(intelbatch_LIBS)
-endif
-
-if ENABLE_PIXMAN
- libwld_la_SOURCES += pixman.c
- pkginclude_HEADERS += pixman.h
-endif
-
-if ENABLE_WAYLAND
- AM_CFLAGS += $(wayland_client_CFLAGS)
- libwld_la_SOURCES += wayland.c
- libwld_la_LIBADD += $(wayland_client_LIBS)
- pkginclude_HEADERS += wayland.h
-endif
-
-if WITH_WAYLAND_DRM
- AM_CPPFLAGS = -I$(top_builddir)/protocol
- AM_CFLAGS += $(drm_CFLAGS)
- libwld_la_SOURCES += wayland-drm.c protocol/wayland-drm-protocol.c
- libwld_la_LIBADD += $(drm_LIBS)
- pkginclude_HEADERS += wayland-drm.h
-endif
-
-if WITH_WAYLAND_SHM
- libwld_la_SOURCES += wayland-shm.c
- pkginclude_HEADERS += wayland-shm.h
-endif
-
-SUBDIRS = protocol
-
diff --git a/autogen.sh b/autogen.sh
@@ -1,13 +0,0 @@
-#!/bin/sh
-
-set -ex
-
-rm -rf autom4te.cache
-
-libtoolize
-aclocal -I m4 --force
-autoconf -f -W all
-automake -f -a -c -W all
-
-rm -rf autom4te.cache
-
diff --git a/config.mk b/config.mk
@@ -0,0 +1,25 @@
+# wld: config.mk
+
+PREFIX = /usr/local
+LIBDIR = $(PREFIX)/lib
+INCLUDEDIR = $(PREFIX)/include
+PKGCONFIGDIR = $(LIBDIR)/pkgconfig
+
+CC = gcc
+CFLAGS = -pipe
+PKG_CONFIG ?= pkg-config
+WAYLAND_SCANNER ?= wayland-scanner
+
+ENABLE_DEBUG = 1
+
+ENABLE_PIXMAN = 1
+ENABLE_DRM = 1
+ENABLE_WAYLAND = 0
+
+DRM_DRIVERS = intel
+WAYLAND_INTERFACES = shm
+
+ifeq ($(ENABLE_DRM),1)
+ WAYLAND_INTERFACES += drm
+endif
+
diff --git a/configure.ac b/configure.ac
@@ -1,150 +0,0 @@
-dnl wld: configure.ac
-
-AC_PREREQ([2.59])
-
-AC_INIT([wld], [0.0.1], [mforney@mforney.org])
-AM_INIT_AUTOMAKE([foreign nostdinc subdir-objects -Wall -Werror])
-AC_LANG([C])
-
-m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
-
-AC_PROG_CC_C99
-AC_USE_SYSTEM_EXTENSIONS
-
-AM_PROG_AR
-LT_INIT
-
-AC_CONFIG_SRCDIR([wld.h])
-
-PKG_PROG_PKG_CONFIG([0.9.0])
-
-dnl Options {{{
-# Debugging
-AC_ARG_ENABLE([debug],
- AS_HELP_STRING([--enable-debug],
- [enable debugging messages]),
- enable_debug=$enableval,
- enable_debug=no)
-if test "x$enable_debug" = "xyes" ; then
- AC_DEFINE([ENABLE_DEBUG], [1], [Enable debug messages])
-fi
-
-# DRM
-AC_ARG_ENABLE([drm],
- AS_HELP_STRING([--disable-drm],
- [disable DRM support]),
- enable_drm=$enableval,
- enable_drm=yes)
-AM_CONDITIONAL([ENABLE_DRM], [test "x$enable_drm" = "xyes"])
-
-# DRM drivers
-DEFAULT_DRM_DRIVERS=intel
-AC_ARG_WITH([drm-drivers],
- AS_HELP_STRING([--with-drm-drivers=DRIVERS],
- [specify DRM drivers (comma separated)]),
- with_drm_drivers=$withval,
- with_drm_drivers=$DEFAULT_DRM_DRIVERS)
-case "x$with_drm_drivers" in
- xyes) with_drm_drivers=$DEFAULT_DRM_DRIVERS ;;
- xno) with_drm_drivers= ;;
-esac
-if test "x$drm_drivers" != "x" -a "x$enable_drm" != "xyes"; then
- AC_MSG_ERROR([--with-drm-drivers requires --enable-drm])
-fi
-drm_drivers=`IFS=','; echo $with_drm_drivers`
-for driver in $drm_drivers ; do
- case "x$driver" in
- xintel)
- AC_DEFINE([WITH_DRM_INTEL], [1], [Build Intel DRM driver])
- PKG_CHECK_MODULES([drm_intel], [libdrm_intel],,
- AC_MSG_ERROR([Intel DRM driver requires libdrm_intel]))
- PKG_CHECK_MODULES([intelbatch], [intelbatch],,
- AC_MSG_ERROR([Intel DRM driver requires libintelbatch]))
- PKGCONFIG_REQUIRES_PRIVATE+=" libdrm_intel intelbatch"
- with_drm_intel=yes
- ;;
- *)
- AC_MSG_ERROR([Unknown DRM driver: '$driver'])
- ;;
- esac
-done
-AM_CONDITIONAL([WITH_DRM_INTEL], [test "x$with_drm_intel" = "xyes"])
-
-# Wayland
-AC_ARG_ENABLE([wayland],
- AS_HELP_STRING([--disable-wayland],
- [disable Wayland support]),
- enable_wayland=$enableval,
- enable_wayland=yes)
-if test "x$enable_wayland" = "xyes" ; then
- PKG_CHECK_MODULES([wayland_client], [wayland-client],,
- AC_MSG_ERROR([Wayland client libraries not found. Specify \
---disable-wayland to build without wayland support]))
- PKGCONFIG_REQUIRES_PRIVATE+=" wayland-client"
-fi
-AM_CONDITIONAL([ENABLE_WAYLAND], [test "x$enable_wayland" = "xyes"])
-
-DEFAULT_WAYLAND_INTERFACES=drm,shm
-AC_ARG_WITH([wayland-interfaces],
- AS_HELP_STRING([--with-wayland-interfaces=INTERFACES],
- [specify Wayland interfaces (comma separated)]),
- with_wayland_interfaces=$withval,
- with_wayland_interfaces=$DEFAULT_WAYLAND_INTERFACES)
-case "x$with_wayland_interfaces" in
- xyes) with_wayland_interfaces=$DEFAULT_WAYLAND_INTERFACES ;;
- xno) with_wayland_interfaces= ;;
-esac
-if test "x$wayland_interfaces" != "x" -a "x$enable_wayland" != "xyes"; then
- AC_MSG_ERROR([--with-wayland-interfaces requires --enable-wayland])
-fi
-wayland_interfaces=`IFS=','; echo $with_wayland_interfaces`
-for interface in $wayland_interfaces ; do
- case "x$interface" in
- xdrm)
- PKG_CHECK_MODULES([libdrm], [libdrm],,
- AC_MSG_ERROR([Wayland DRM support requires libdrm]))
- PKGCONFIG_REQUIRES_PRIVATE+=" libdrm"
- AC_DEFINE([WITH_WAYLAND_DRM], [1],
- [Build support for wl_drm global])
- with_wayland_drm=yes
- ;;
- xshm)
- AC_DEFINE([WITH_WAYLAND_SHM], [1],
- [Build support for wl_shm global])
- with_wayland_shm=yes
- ;;
- *)
- AC_MSG_ERROR([Unknown Wayland interface: '$interface'])
- ;;
- esac
-done
-AM_CONDITIONAL([WITH_WAYLAND_DRM], [test "x$with_wayland_drm" = "xyes"])
-AM_CONDITIONAL([WITH_WAYLAND_SHM], [test "x$with_wayland_shm" = "xyes"])
-
-# Pixman
-AC_ARG_ENABLE([pixman],
- AS_HELP_STRING([--disable-pixman],
- [disable pixman drawable support]),
- enable_pixman=$enableval,
- enable_pixman=yes)
-if test "x$enable_pixman" = "xyes" ; then
- AC_DEFINE([ENABLE_PIXMAN], [1], [Enable Pixman support])
-fi
-AM_CONDITIONAL([ENABLE_PIXMAN], test "x$enable_pixman" = "xyes")
-dnl }}}
-
-dnl Check for libraries {{{
-PKG_CHECK_MODULES([pixman], [pixman-1])
-PKG_CHECK_MODULES([fontconfig], [fontconfig])
-PKG_CHECK_MODULES([freetype], [freetype2])
-dnl }}}
-
-dnl Wayland protocol
-WAYLAND_SCANNER_RULES(['$(top_srcdir)/protocol'])
-
-dnl pkgconfig
-AC_SUBST([PKGCONFIG_REQUIRES_PRIVATE])
-
-AC_CONFIG_FILES([Makefile protocol/Makefile wld.pc])
-AC_OUTPUT
-
diff --git a/protocol/local.mk b/protocol/local.mk
@@ -0,0 +1,25 @@
+# wld: protocol/local.mk
+
+dir := protocol
+
+PROTOCOL_EXTENSIONS = $(dir)/wayland-drm.xml
+
+$(dir)/%-protocol.c: $(dir)/%.xml
+ $(call quiet,GEN,$(WAYLAND_SCANNER)) code < $< > $@
+
+$(dir)/%-client-protocol.h: $(dir)/%.xml
+ $(call quiet,GEN,$(WAYLAND_SCANNER)) client-header < $< > $@
+
+.deps/$(dir): | .deps
+ @mkdir "$@"
+
+$(dir)/%.o: $(dir)/%.c | .deps/$(dir)
+ $(compile)
+
+$(dir)/%.lo: $(dir)/%.c | .deps/$(dir)
+ $(compile) -fPIC
+
+CLEAN_FILES += \
+ $(PROTOCOL_EXTENSIONS:%.xml=%-protocol.c) \
+ $(PROTOCOL_EXTENSIONS:%.xml=%-client-protocol.h)
+
diff --git a/wayland-drm.c b/wayland-drm.c
@@ -22,7 +22,7 @@
*/
#include "wayland-drm.h"
-#include "wayland-drm-client-protocol.h"
+#include "protocol/wayland-drm-client-protocol.h"
#include "wayland.h"
#include "drm.h"
#include "wayland-private.h"
diff --git a/wld.pc.in b/wld.pc.in
@@ -1,14 +1,13 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
+prefix=@PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
Name: wld
Description: A primitive drawing library library targeted at Wayland
-Version: @PACKAGE_VERSION@
+Version: @VERSION@
Cflags: -I${includedir}
Libs: -L${libdir} -lwld
-Requires: fontconfig pixman-1
-Requires.private: freetype2 @PKGCONFIG_REQUIRES_PRIVATE@
+Requires: @WLD_REQUIRES@
+Requires.private: @WLD_REQUIRES_PRIVATE@