[pacman-dev] Possible start to a new make system

Dan McGee dpmcgee at gmail.com
Thu Jan 18 00:05:38 EST 2007


My little project for the night, and I wanted to get better with
makefiles anyway. I basically copied the code directory, removed
anything that started with Make or ended in .am, and dumped all the
configure stuff. I used your suggestion yesterday of looking at the
wmii Makefile, Aaron, and it is pretty similar. The biggest issues
were the fact that we are building libraries, and we are working out
of multiple subdirectories.

Current status of this will hopefully build libalpm and pacman
successfully. I haven't done anything for the scripts, etc, yet, but
that shouldn't be hard to add. The biggest point of this was just to
see if it could be done.

There are currently three files involved in the build process now, all
in the root of the project: Makefile, config.mk, and config.h. I
didn't want to destroy the code by removing config.h, so I pretty much
just ran a configure, kept config.h, and put it in the directory.

Let me know what you guys think. 3 files inlined here. Obviously still
a lot of work to do, but this is my start.

-Dan

Makefile:

# Pacman 3 Package Manager
#   Makefile written by Dan McGee, (C) 2006
#   Ideas from wmii makefile, http://wmii.suckless.org/

PACVER = 3.0.0
ALPMVER = 0.1.0

# Install/System paths
DESTDIR =
prefix = /usr/local
exec_prefix = /usr/local

BINDIR = ${exec_prefix}/bin
MANDIR = ${prefix}/man

include config.mk

# Project directory paths
TOPDIR = .
PACSRCDIR = $(TOPDIR)/src/pacman/
LIBSRCDIR = $(TOPDIR)/lib/libalpm/
MANSRC = $(TOPDIR)/doc/
SCRDIR = $(TOPDIR)/scripts/

CFLAGS += -I. -Ilib/libalpm -D_GNU_SOURCE -DVERSION=\"${VERSION}\"
LDFLAGS += -L/usr/lib -ldownload -larchive -lm -lmcheck -lz -lbz2 -lattr -lacl

PACSRC = $(PACSRCDIR)add.c $(PACSRCDIR)conf.c $(PACSRCDIR)deptest.c \
         $(PACSRCDIR)downloadprog.c $(PACSRCDIR)list.c $(PACSRCDIR)log.c \
		 $(PACSRCDIR)package.c $(PACSRCDIR)pacman.c $(PACSRCDIR)query.c \
		 $(PACSRCDIR)remove.c $(PACSRCDIR)sync.c $(PACSRCDIR)trans.c \
		 $(PACSRCDIR)upgrade.c $(PACSRCDIR)util.c

PACOBJ = ${PACSRC:.c=.o}

LIBSRC = $(LIBSRCDIR)add.c $(LIBSRCDIR)alpm.c $(LIBSRCDIR)backup.c \
		 $(LIBSRCDIR)be_files.c $(LIBSRCDIR)cache.c $(LIBSRCDIR)conflict.c \
		 $(LIBSRCDIR)db.c $(LIBSRCDIR)deps.c $(LIBSRCDIR)error.c \
		 $(LIBSRCDIR)group.c $(LIBSRCDIR)handle.c $(LIBSRCDIR)list.c \
		 $(LIBSRCDIR)log.c $(LIBSRCDIR)md5.c $(LIBSRCDIR)md5driver.c \
		 $(LIBSRCDIR)package.c $(LIBSRCDIR)provide.c $(LIBSRCDIR)remove.c \
		 $(LIBSRCDIR)server.c $(LIBSRCDIR)sha1.c $(LIBSRCDIR)sync.c \
		 $(LIBSRCDIR)trans.c $(LIBSRCDIR)util.c $(LIBSRCDIR)versioncmp.c

LIBOBJ = ${LIBSRC:.c=.o}

all: options libalpm pacman vercmp alpmdoc pacmandoc

options:
	@echo "Pacman Build Options:"
	@echo "CC       = ${CC}"
	@echo "CFLAGS   = ${CFLAGS}"
	@echo "LD       = ${LD}"
	@echo "LDFLAGS  = ${LDFLAGS}"
	@echo "AR       = ${AR}"
	@echo

# put @ sign back in front of lines to be silent
${PACOBJ}: config.h config.mk
	@echo CC $*.c
	@${CC} -c ${CFLAGS} -o $*.o $*.c

${LIBOBJ}: config.h config.mk
	@echo CC $*.c
	@${CC} -fPIC -c ${CFLAGS} -o $*.o $*.c

libalpm: ${LIBOBJ}
	@echo AR $@
	@${AR} rcs $@.a ${LIBOBJ}
	@echo LD $@
	@${LD} -shared -Wl,-soname,libalpm.so.0 -o $@.so.${ALPMVER} ${LIBOBJ}
${LDFLAGS}

pacman: libalpm ${PACOBJ}
	@echo LD $@
	@${LD} -o $@ ${PACOBJ} -L. -lalpm ${LDFLAGS}
	@echo LD $@.static
	@${LD} -o $@.static ${PACOBJ} -static -L. -lalpm ${LDFLAGS}

clean:
	@echo "Cleaning..."
	@rm -f ${PACOBJ} ${LIBOBJ}
	@rm -f libalpm.a libalpm.so.${ALPMVER} pacman pacman.static

dist: clean
	@echo "Creating tarball for version ${VERSION}..."
	mkdir -p pacman-${VERSION}
#	cp -R AUTHORS COPYING NEWS README
	tar -cf pacman-${VERSION}.tar pacman-${VERSION}
	gzip pacman-${VERSION}.tar
	rm -rf pacman-${VERSION}

.PHONY: clean
# End of file


config.mk:

# Customize below to fit your system

# paths
PREFIX = /usr/local
CONFPREFIX = ${PREFIX}/etc
MANPREFIX = ${PREFIX}/share/man

# includes and libs
INCS = -I${PREFIX}/include
LIBS = -L${PREFIX}/lib

# flags
CFLAGS = -O2 -Wall -Werror -std=c99 -g ${INCS} -DPACMAN_DEBUG
-D'PACCONF="/etc/pacman.conf"'
LDFLAGS = ${LIBS}

# compiler and linker
CC = ccache cc
LD = ${CC}


config.h:

/* config.h. */
/* This file originally generated using configure, but that got confusing.
 * configure could be used for just this and not the build, and it would
 * not be a bad idea.
 */

/* Architecture */
#define CARCH "i686"

/* Architecture */
#define CARCHFLAGS "i686"

/* Define to 1 if translation of program messages to the user's native
   language is requested. */
#define ENABLE_NLS 1

#define HAS_DOXYGEN TRUE
#define HAS_JAVA TRUE
#define HAS_MAN2HTML FALSE
#define HAS_PERL TRUE
#define HAS_PO4A TRUE
#define HAS_PYTHON TRUE

/* Architecture */
#define MARCHFLAG "march"

/* Name of package */
#define PACKAGE "pacman"

/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "pacman-dev at archlinux.org"

/* Define to the full name of this package. */
#define PACKAGE_NAME "Pacman package manager"

/* Define to the full name and version of this package. */
#define PACKAGE_STRING "Pacman package manager 3.0.0"

/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "pacman"

/* Define to the version of this package. */
#define PACKAGE_VERSION "3.0.0"

/* libalpm version number */
#define PM_VERSION "0.1.0"

/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
#define HAVE_STRVERSCMP




More information about the pacman-dev mailing list