u-isdn/Make.rules

256 lines
4.8 KiB
Plaintext
Raw Permalink Normal View History

# This Makefile is chaotic. Sorry.
# It gets (most of) the job done and that's what counts.
#
all:: first_rule
unexport KERNEL
unexport PROGRAM
unexport PROGRAMS
unexport CC
unexport CFLAGS
1995-11-13 22:20:37 +00:00
unexport LDFLAGS
unexport SOURCES
unexport HEADERS
unexport LIB
unexport LIBS
unexport OBJ
unexport OBJS
unexport DOCARDS
unexport WHAT
unexport REALSOURCE
unexport DOSRC
1995-10-25 12:36:04 +00:00
unexport SUBDIRS
1995-11-13 22:20:37 +00:00
unexport EXTRA_CFLAGS
unexport EXTRA_LDFLAGS
unexport EXTRA_LIBS
ifneq ($(strip $(DOCARDS)),)
KERNEL=1
endif
include $(TOPDIR)/Make.config
export KERNELSRC
export TOPDIR
VERSION := $(shell $(TOPDIR)/tools/getversion $(KERNELSRC))
.PHONY: dummy
ifeq ($(strip $(HEADERS)),)
HEADERS := $(wildcard *.h)
endif
DOSRC:=1
ifneq ($(strip $(REALSOURCE)),)
DOSRC:=0
endif
ifneq ($(strip $(DOCARDS)),)
DOSRC:=1
endif
ifeq ($(DOSRC),1)
ifneq ($(strip $(KERNEL)),)
ifeq ($(strip $(SOURCES)),)
SOURCES := $(wildcard *.c)
endif
else
ifeq ($(strip $(PSOURCES)),)
PSOURCES := $(wildcard *.c)
endif
endif
endif
ifneq ($(strip $(DOCARDS)),)
OLDSOURCES := $(SOURCES)
SOURCES := $(filter $(addsuffix .c,$(CARDS)),$(SOURCES))
endif
INCLUDES = -I$(TOPDIR)/include -I$(TOPDIR)/compat -I$(TOPDIR)/streams -I$(KERNELSRC)/include $(EXTRA_INCLUDES)
first_rule:: libs programs modules
all depend indent clean install::
ifneq ($(strip $(SUBDIRS)),)
$(MAKE) WHAT=$@ subdirs
subdirs::
1995-11-13 22:20:37 +00:00
set -e; for i in $(SUBDIRS); do $(MAKE) -r TOPDIR=../$(TOPDIR) -C $$i $(WHAT); done
endif
depend::
ifneq ($(strip $(SOURCES)),)
OBJS = $(addsuffix .o, $(basename $(SOURCES)))
endif
ifneq ($(strip $(PSOURCES)),)
POBJS = $(addsuffix .o, $(basename $(PSOURCES)))
ifeq ($(strip $(PROGRAM)),)
ifeq ($(strip $(PROGRAMS)),)
ifeq ($(strip $(LIB)),)
PROGRAMS = $(basename $(PSOURCES))
endif
endif
endif
endif
ifneq ($(strip $(REALSOURCE)),)
$(OBJS): $(REALSOURCE)
$(CC) $(CFLAGS) $(INCLUDES) $(EXTRA_CFLAGS) -DREALNAME=$(basename $@) -D_$(basename $@)_ -c -o $@ $<
else
ifeq ($(DOCARDS),1)
1995-11-13 22:20:37 +00:00
%.o: %.c
$(CC) $(CFLAGS) $(INCLUDES) $(EXTRA_CFLAGS) -DREALNAME=$(basename $@) -D_$(basename $@)_ -c -o $@ $<
else
1995-11-13 22:20:37 +00:00
%.o: %.c
$(CC) $(CFLAGS) $(INCLUDES) $(EXTRA_CFLAGS) -c -o $@ $<
endif
endif
clean::
rm -f .depend core
rm -f *.vi?
ifneq ($(strip $(TARGET)),)
rm -f $(TARGET)
endif
ifneq ($(strip $(POBJS)),)
rm -f $(POBJS)
endif
ifneq ($(strip $(OBJ)),)
rm -f $(OBJ)
endif
ifneq ($(strip $(OBJS)),)
rm -f $(OBJS)
endif
ifneq ($(strip $(PROGRAM)),)
rm -f $(PROGRAM)
endif
ifneq ($(strip $(filter-out $(NOCLEAN),$(PROGRAMS))),)
rm -f $(filter-out $(NOCLEAN),$(PROGRAMS))
endif
ifneq ($(strip $(LIB)),)
rm -f $(LIB)
endif
ifneq ($(strip $(PROGRAM)),)
programs:: $(PROGRAM)
$(PROGRAM): $(POBJS) $(filter %.a,$(LIBS) $(EXTRA_LIBS))
1995-11-13 22:20:37 +00:00
$(CC) $(EXTRA_LDFLAGS) $(LDFLAGS) -o $@ $(POBJS) $(EXTRA_LIBS) $(LIBS)
else
ifneq ($(strip $(PROGRAMS)),)
programs:: $(PROGRAMS)
%: %.o $(filter %.a,$(LIBS) $(EXTRA_LIBS))
1995-11-13 22:20:37 +00:00
$(CC) $(EXTRA_LDFLAGS) $(LDFLAGS) -o $@ $< $(EXTRA_LIBS) $(LIBS)
else
programs::
endif
endif
ifneq ($(strip $(PROGRAMS)),)
programs:: $(PROGRAMS)
else
programs::
endif
ifneq ($(strip $(LIB)),)
libs: $(LIB)
$(LIB): $(POBJS)
rm -f $@
$(AR) rcs $@ $^
else
libs:
endif
lib::
ifneq ($(strip $(P_LIB)),)
$(MAKE) $(P_OBJ)
endif
ifneq ($(strip $(OBJS)),)
ifeq ($(strip $(OBJ)),)
modules: $(OBJS)
else
modules: $(OBJ)
$(OBJ): $(OBJS)
$(LD) -r -o $@ $^
endif
else
modules:
endif
install::
ifeq ($(strip $(KERNEL)),1)
ifneq ($(strip $(OBJ)),)
$(TOPDIR)/tools/insmod $(OBJ)
else
ifeq ($(strip $(DOCARDS)),1)
$(foreach OBJ,$(OBJS),$(TOPDIR)/tools/d_insmod $(OBJ); )
else
$(foreach OBJ,$(OBJS),$(TOPDIR)/tools/insmod $(OBJ); )
endif
endif
else
ifneq ($(strip $(PROGRAM)),)
install $(PROGRAM) $(DESTDIR)/bin-$(VERSION)
endif
ifneq ($(strip $(PROGRAMS)),)
install $(PROGRAMS) $(DESTDIR)/bin-$(VERSION)
endif
endif
indent::
ifneq ($(strip $(PSOURCES)),)
$(TOPDIR)/tools/indent.sh $(PSOURCES)
endif
ifneq ($(strip $(SOURCES)),)
$(TOPDIR)/tools/indent.sh $(SOURCES)
endif
ifneq ($(strip $(HEADERS)),)
$(TOPDIR)/tools/indent.sh $(HEADERS)
endif
ifeq (.depend,$(wildcard .depend))
include .depend
endif
depend::
rm -f .depend
ifneq ($(strip $(SOURCES)),)
ifneq ($(strip $(REALSOURCE)),)
depend:: Makefile $(REALSOURCE) $(HEADERS)
$(foreach SOURCE,$(SOURCES), $(CC) -M $(CFLAGS) $(INCLUDES) $(EXTRA_CFLAGS) $(REALSOURCE) -D_$(SOURCE:.c=)_ | sed -e s/$(REALSOURCE:.c=.o)/$(SOURCE:.c=.o)/ >> .depend ; )
else
depend:: Makefile $(SOURCES) $(HEADERS)
1996-04-11 14:53:10 +00:00
ifneq ($(strip $(CONFIG_MODVERSIONS)),)
ifneq ($(strip $(SYMTAB)),)
$(CC) $(CFLAGS) $(INCLUDES) $(EXTRA_CFLAGS) -E -D__GENKSYMS__ $(SYMTAB) | /sbin/genksyms $(TOPDIR)/include
for i in $(SYMTAB:.c=.ver) ; do echo "#include \"$$i\"" ; done >> $(TOPDIR)/include/symtables
endif
endif
$(CC) -M $(CFLAGS) $(INCLUDES) $(EXTRA_CFLAGS) $(SOURCES) >> .depend
1996-04-11 14:53:10 +00:00
endif
endif
1996-12-11 13:18:33 +00:00
ifneq ($(strip $(PSOURCES)),)
depend:: Makefile $(PSOURCES) $(HEADERS)
$(CC) -M $(CFLAGS) $(INCLUDES) $(EXTRA_CFLAGS) $(PSOURCES) >> .depend
endif