![]() |
| | #1 |
| Registered User Join Date: May 2008
Posts: 11
| GNU make - generating dynamic dependencies 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 | |
![]() |
| Tags |
| gnu make |
| Thread Tools | |
| Display Modes | |
|
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 |