[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

makefile mysteries



hi guys,

even though today was declared to be a 'non syscalltrack day', a
Makefile bug bit apparitio and seemed "simple enough to fix".
these words are, in case you dont know, high on the list of famous last
words.

we want to check if an environemnt variable is set, and if not, die.
simple, eh? not. if i do the obvious

ifeq ($(string $(KERNEL_DIR)),)
	@echo bla bla
	@exit 1
endif

at the top of the Makefile, make complains loudly about "*** commands
commence before first target.  Stop.". there must be some simple
solution to this (adding a phony target?), but i couldnt find it. for
now, i implemented an extra level of indirection, but it's pretty ugly.
help?

my solution (snipped off irrelevant stuff)

# Makefile for syscalltrack_modules.
# (loosely based on the examples in rubini's device drivers book)

ifeq  ($(strip $(KERNEL_DIR)), )
	NO_KERNEL = 1
else
	include $(KERNEL_DIR)/.config
endif

[ various variable declarations ]

FINAL_MODS      =       st_rules.o syscall_hijack.o

all: 		check_kernel $(FINAL_MODS)

check_kernel:
ifeq ($(NO_KERNEL),1)
	@echo
	@echo "you must set KERNEL_DIR (consult COMPILING)"
	@echo
	@exit 1
endif

st_rules.o:  	$(OBJECTS)
		$(LD) -r $^ -o $@

# extra rule to compile files found in $(RULES_LOC)
%.o: $(RULES_LOC)/%.c
	$(CC) $(CFLAGS) $(DFLAGS) -c $<
-- 
mulix

http://www.advogato.com/person/mulix
http://www.sf.net/projects/syscalltrack



=================================================================
To unsubscribe, send mail to linux-il-request@linux.org.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request@linux.org.il