进入该目录,修改Make.defines.linux,将其中的WKDIR赋为上面解压的目录
进入std子目录,修改linux.mk,把命令nawk改为awk
make
例子中包含的apue.h位于解压目录的include子文件夹,那么相应的原文件要做一些修改.比如fig1.3的程序my_ls.c,我放在~/new/apue/src中:[code]#include "../include/apue.h"
#include
int main(int argc, char *argv[])
{
DIR *dp;
struct dirent *dirp;
if (argc != 2)
err_quit("usage: %s directory_name", argv[0]);
if ((dp = opendir(argv[1])) == NULL)
err_sys("can't open %s", argv[1]);
while ((dirp = readdir(dp)) != NULL)
printf("%s\n", dirp->d_name);
closedir(dp);
exit(0);
}[/code]src/中放个Makefile:[code]obj = $(patsubst %.c,%,$(wildcard *.c))
CC = gcc
CFLAGS = -g -Wall
LIBS = ../lib/libapue.a
all: $(obj)
$(obj): %: %.c
$(CC) $(CFLAGS) $< $(LIBS) -o $@
clean:
-rm *~ *.out
depclean:
-rm *~ *.out $(obj)[/code]至此,ok.