From owner-freebsd-questions@FreeBSD.ORG Mon May 22 22:07:46 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 534E316A561 for ; Mon, 22 May 2006 22:07:46 +0000 (UTC) (envelope-from andrew.chace@gmail.com) Received: from nz-out-0102.google.com (nz-out-0102.google.com [64.233.162.207]) by mx1.FreeBSD.org (Postfix) with ESMTP id DB99343D4C for ; Mon, 22 May 2006 22:07:45 +0000 (GMT) (envelope-from andrew.chace@gmail.com) Received: by nz-out-0102.google.com with SMTP id l8so1077654nzf for ; Mon, 22 May 2006 15:07:45 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:subject:from:to:content-type:date:message-id:mime-version:x-mailer:content-transfer-encoding; b=W/L5WYZp7Kt4VBjg9fIgPd7wRC4P6+j4mIYERdZqA0d1jd2gEFq/0EaQiPIesN6HnDlZt+DGdKld+tO5fJpTv3P/xRrzqLLPP9DLzIUmjSaL6+XQYS2doSUwlWS0NWMJramMM4obM53/Hxm8XP15ZLcvYPr3LY7UJ3CV5Xh9BXM= Received: by 10.37.2.11 with SMTP id e11mr6794795nzi; Mon, 22 May 2006 15:07:45 -0700 (PDT) Received: from ?192.168.0.6? ( [70.56.10.145]) by mx.gmail.com with ESMTP id 12sm7554214nzn.2006.05.22.15.07.44; Mon, 22 May 2006 15:07:44 -0700 (PDT) From: Andrew To: freebsd-questions@freebsd.org Content-Type: text/plain Date: Mon, 22 May 2006 17:07:51 -0500 Message-Id: <1148335671.2572.10.camel@LatitudeFC5.network> Mime-Version: 1.0 X-Mailer: Evolution 2.6.1 (2.6.1-1.fc5.2) Content-Transfer-Encoding: 7bit Subject: Makefile and '$(addprefix)' X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 May 2006 22:07:46 -0000 Hello all, I'm trying to clean up the source tree for some software I'm writing. The program itself is relatively simple, but is very fragmented; i.e. it has a lot of source files. I'd like to write one top-level Makefile that is able to find all of my source files, build the object files, and put them into a separate directory. I'm thinking this can't be that difficult, but I haven't figured it out yet. I'm trying to use $(addprefix) build lists of source files and object files containing the relative paths for each. The problem is that $(addprefix) never seems to be evaluated. When I run 'make -p', $OBJECT_LIST looks exactly like in does in my Makefile, which is listed below. Fixes or pointers to a somewhat simple example greatly appreciated... Thanks, -Andrew #### Begin Makefile #### ## compiler settings CC = gcc OPTIONS = -Wall -g ## directory layout BASEDIR = ../alice SOURCEDIR = $(BASEDIR)/sources OBJECTDIR = $(BASEDIR)/objects DOCSDIR = $(BASEDIR)/documentation ## sources SOURCES = main.c help.c status.c buffer.c device.c error.c insane.c ## objects OBJECTS = main.o help.o status.o buffer.o device.o error.o insane.o ## lists containing paths SOURCES_LIST = $(addprefix, $(SOURCEDIR), $(SOURCE)) OBJECTS_LIST = $(addprefix, $(OBJECTDIR), $(OBJECTS)) ## targets alice: $(OBJECT_LIST) $(CC) $(OPTIONS) -o $@ $(OBJECT_LIST) $(OBJECTS_LIST): alice.h $(CC) $(OPTIONS) -c $(SOURCES_LIST) clean: rm -f $(OBJECTS_LIST) *.core alice; #### End Makefile ####