| 1 |
######################################################################## |
| 2 |
# Code listing from "Advanced Linux Programming," by CodeSourcery LLC # |
| 3 |
# Copyright (C) 2001 by New Riders Publishing # |
| 4 |
# See COPYRIGHT for license information. # |
| 5 |
######################################################################## |
| 6 |
|
| 7 |
### Configuration. #################################################### |
| 8 |
|
| 9 |
# C source files for the server. |
| 10 |
SOURCES = server.c module.c common.c main.c |
| 11 |
# Object files corresponding to source files. |
| 12 |
OBJECTS = $(SOURCES:.c=.o) |
| 13 |
# Server module shared library files. |
| 14 |
MODULES = diskfree.so issue.so processes.so time.so |
| 15 |
|
| 16 |
### Rules. ############################################################ |
| 17 |
|
| 18 |
.PHONY: all clean |
| 19 |
|
| 20 |
# Default target: build everything. |
| 21 |
all: server $(MODULES) |
| 22 |
|
| 23 |
# Clean up build products. |
| 24 |
clean: |
| 25 |
rm -f $(OBJECTS) $(MODULES) server |
| 26 |
|
| 27 |
# The main server program. Link with -Wl,-export-dyanamic so |
| 28 |
# dynamically loaded modules can bind symbols in the program. Link in |
| 29 |
# libdl, which contains calls for dynamic loading. |
| 30 |
server: $(OBJECTS) |
| 31 |
$(CC) $(CFLAGS) -Wl,-export-dynamic -o $@ $^ -ldl |
| 32 |
|
| 33 |
# All object files in the server depend on server.h. But use the |
| 34 |
# default rule for building object files from source files. |
| 35 |
$(OBJECTS): server.h |
| 36 |
|
| 37 |
# Rule for building module shared libraries from the corresponding |
| 38 |
# source files. Compile -fPIC and generate a shared object file. |
| 39 |
$(MODULES): \ |
| 40 |
%.so: %.c server.h |
| 41 |
$(CC) $(CFLAGS) -fPIC -shared -o $@ $< |