topbuilddir=.
PROGRAM=ftsbench stopfilter
+PROGRAMOBJ_ftsbench = rand.o finnegan.o utils.o
WITH_PGSQL=yes
WITH_MYSQL=yes
-SUBDIRS=
-LIBRARY=ftsbench.a
-LIBOBJ=rand.o finnegan.o utils.o
-
ifeq ($(WITH_PGSQL), yes)
-LIBOBJ+=pgdriver.o
+PROGRAMOBJ_ftsbench+=pgdriver.o
PGSQLCFG=/usr/local/pgsql/bin/pg_config
EXTRALIB+=-L`$(PGSQLCFG) --libdir` -lpq -L/usr/lib -lcrypt
EXTRAINCLUDE+=-I`$(PGSQLCFG) --includedir`
endif
ifeq ($(WITH_MYSQL), yes)
-LIBOBJ+=mysqldriver.o
+PROGRAMOBJ_ftsbench+=mysqldriver.o
MYSQLCFG=/usr/local/mysql/bin/mysql_config
EXTRALIB+=`$(MYSQLCFG) --libs_r`
EXTRAINCLUDE+=`$(MYSQLCFG) --cflags`
SUBDIROBJS := $(SUBDIRS:%=%/SUBSYS.o)
endif
-ifdef PROGRAM
-PROGRAMOBJ := $(PROGRAM:%=%.o)
-endif
-
.SUFFIXES: .o.c
.c.o:
all: $(SUBSYS) $(LIBRARY) $(PROGRAM)
+define prog_dep
+ $(1): $$(PROGRAMOBJ_$(1))
+endef
+
+$(foreach prog,$(PROGRAM),$(eval $(call prog_dep,$(prog))))
+
ifdef PROGRAM
ifdef LIBRARY
$(PROGRAM): $(LIBRARY)
endif
$(PROGRAM): %: %.o
- $(CC) -o $@ $< $(LIBRARY) $(LIB)
+ $(CC) -o $@ $< $(PROGRAMOBJ_$(@)) $(LIBRARY) $(LIB)
endif
ifdef LIBRARY
$(SUBDIROBJS): $(SUBDIRS:%=%-recursive) ;
$(SUBDIRS:%=%-recursive):
- $(MAKE) -C $(subst -recursive,,$@) -f Makefile SUBSYS.o
+ $(MAKE) -C $(subst -recursive,,$@) -f Makefile OS=$(OS) SUBSYS.o
endif
clean:
-ifdef OBJ
- rm -rf $(OBJ)
-endif
ifdef LIBOBJ
rm -rf $(LIBOBJ)
endif
ifdef PROGRAM
- rm -rf $(PROGRAM) $(PROGRAMOBJ) *core core.*
+ rm -rf $(PROGRAM)
+ rm -rf $(foreach P, $(PROGRAM), $P.o $(PROGRAMOBJ_$(P)))
+ rm -rf *core core.*
endif
ifdef LIBRARY
rm -rf $(LIBRARY)
rm -rf $(SUBOBJ) $(SUBSYS)
endif
ifdef SUBDIRS
- for dir in $(SUBDIRS); do $(MAKE) -f Makefile -C $$dir clean || exit; done
+ for dir in $(SUBDIRS); do $(MAKE) -f Makefile -C $$dir OS=$(OS) clean || exit; done
endif