C Board  

Go Back   C Board > Platform Specific Boards > Linux Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 05-15-2008, 10:41 AM   #1
Registered User
 
Join Date: May 2008
Posts: 11
GNU make - generating dynamic dependencies

I can't generate dependencies automatically like on line 20 in the
makefile below because the variable $@ does not yet exist at that
point. How could I overcome this problem? "pattern rule redefinition"
as in the manual, section 10.5 is also not the solution, as I don't
have any "%", but specific files.

Makefile:
1 MAKEFLAGS = -s
2 CFLAGS = -Wall
3 CC = gcc
4 #Used for releases: RM = rm -f
5 RM = rm
6
7 #directories' section, more to come
8 DIR_TESTS = tests/
9
10 #We may want to specify the tests manually in order to have an "incremental"
11 #error reporting. This would help for better bug hunting and overview.
12 #However, we are ok with this for now.
13 TEST_SRCS = $(wildcard encryption/*.c) $(wildcard $(DIR_TESTS)*.c)
14 TESTS = $(TEST_SRCS:.c=)
15
16 .PHONY: tests
17 tests: $(TESTS)
18 $(eval tests_output = $(foreach test,$(addprefix
$(DIR_TESTS),$(?F)),$(shell echo "\tRUNNING TEST: $(test)\n"; $(test)
| sed -e 's/$$/\\N/g')))
19 echo -e '$(tests_output)' | sed -r -e 's/\\N/\n/g'
20 $(TESTS): $(shell $(CC) -MM -DHAVE_MAIN $@.c | sed 's/.*: //g')
21 echo "DEPS: " $(shell $(CC) -MM -DHAVE_MAIN $@.c | sed 's/.*: //g')
22 $(CC) $(CFLAGS) -DHAVE_MAIN -o $(DIR_TESTS)$(@F) $@.c
23
24 .PHONY: clean
25 clean:
26 $(RM) $(foreach test,$(TESTS),$(DIR_TESTS)$(notdir $(test)))

How would you improve this simple makefile and why?

Regards,
Flavius.
OriginalCopy is offline   Reply With Quote
Reply

Tags
gnu make

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
make Child Dialog not Popup? Zeusbwr Windows Programming 5 04-08-2005 02:42 PM
how to make default for dynamic list afreedboy Tech Board 4 03-24-2005 08:21 AM
"Cannot make pipe" crepincdotcom C Programming 5 08-16-2004 12:43 PM
operator overloading and dynamic memory program jlmac2001 C++ Programming 3 04-06-2003 11:51 PM
BSD make and GNU make problem Skarr Linux Programming 4 09-10-2002 12:31 PM


All times are GMT -6. The time now is 07:10 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22