I have a problem which probably trivial for some who knows 'make' well,
but it has me stumped. I have written a program which can act as either
a CGI bin for a httpd server or a traditional Unix command line program
depending on a compile time directive being defined. For CGI related
parsing, all of the function definitions and data structure declarations
are contained in files called cgi_util.c and cgi_util.h. These are not
needed in the Unix command line version of the program.
I would like to know how to write a Makefile such that if -DUNIX_CMD_LINE
is defined in CFLAGS then the definition of the source files (SRCS,
see below) will not include cgi_util.c
For reference I have appended my Makefile at the end of the post.
Thank-you for any help or advice.
Director, X-ray Structural Facility | phone: (919) 515-7362
Department of Chemistry - Box 8204 | FAX: (919) 515-5079
North Carolina State University |
Raleigh, NC, 27695-8204
Here is my Makefile:
# Makefile for sinfo. Default build is for CGI bin executable.
# If you would rather build a Unix command line version of the
# program define UNIX_CMD_LINE in the CFLAGS variable.
#Linux make variables:
# Development flags (for gcc only)
CFLAGS = -g -ansi -pedantic -Wall \
-Wshadow -Wbad-function-cast -Wconversion \
#Production flags for Linux
#CFLAGS = -O2
#CFLAGS = -ansi -mips2 -O3
#DEC OSF/1 FLAGS
#CFLAGS = std1 -O3
EXE = sinfo
LIB_DIR = -L/usr/local/pgsql/lib
LIBS = -lm -lpq
SRCS = OutputFiles.c ProcessTuples.c \
SearchDatabase.c WholeTableThread.c sinfo_util.c \
OBJS = $(SRCS:.c=.o)
$(CC) -c $(CFLAGS) $<
rm -f *.o $(EXE)