Skip to content

Commit

Permalink
build system: only try building command line scripts if ./configure ran
Browse files Browse the repository at this point in the history
  • Loading branch information
sommer committed Jun 5, 2014
1 parent d35c156 commit e87a264
Showing 1 changed file with 47 additions and 18 deletions.
65 changes: 47 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,38 +1,67 @@
.PHONY: all makefiles clean cleanall doxy

all: checkmakefiles run debug memcheck
# if out/config.py exists, we can also create command line scripts for running simulations
ADDL_TARGETS =
ifeq ($(wildcard out/config.py),)
else
ADDL_TARGETS += run debug memcheck
endif

# default target
all: src/Makefile $(ADDL_TARGETS)
@cd src && $(MAKE)

# command line scripts
run debug memcheck: % : src/scripts/%.in.py out/config.py
@echo "Creating script \"./$@\""
@head -n1 "$<" > "$@"
@cat out/config.py >> "$@"
@tail -n+2 "$<" >> "$@"
@chmod a+x "$@"

# legacy
makefiles:
@echo
@echo '====================================================================='
@echo 'Warning: make makefiles has been deprecated in favor of ./configure'
@echo '====================================================================='
@echo
./configure
@echo
@echo '====================================================================='
@echo 'Warning: make makefiles has been deprecated in favor of ./configure'
@echo '====================================================================='
@echo

clean: checkmakefiles
clean: src/Makefile
cd src && $(MAKE) clean
rm -f run debug memcheck

cleanall: checkmakefiles
cleanall: src/Makefile
cd src && $(MAKE) MODE=release clean
cd src && $(MAKE) MODE=debug clean
rm -f src/Makefile
rm -f run debug memcheck

checkmakefiles:
@if [ ! -f src/Makefile ]; then \
echo; \
echo '====================================================================='; \
echo 'src/Makefile does not exist. Please use "./configure" to generate it!'; \
echo '====================================================================='; \
echo; \
exit 1; \
fi
src/Makefile:
@echo
@echo '====================================================================='
@echo '$@ does not exist.'
@echo 'Please run "./configure" or use the OMNeT++ IDE to generate it.'
@echo '====================================================================='
@echo
@exit 1

run debug memcheck: % : src/scripts/%.in.py out/config.py
@echo "Creating script \"./$@\""
@head -n1 "$<" > "$@"
@cat out/config.py >> "$@"
@tail -n+2 "$<" >> "$@"
@chmod a+x "$@"
out/config.py:
@echo
@echo '====================================================================='
@echo '$@ does not exist.'
@echo 'Please run "./configure" to generate it.'
@echo '====================================================================='
@echo
@exit 1

# autogenerated documentation
doxy:
doxygen doxy.cfg

Expand Down

0 comments on commit e87a264

Please # to comment.