Heredoc in a Makefile?

Another GNU Make solution. You can do it using the define and export commands as follows: define GITIGNOREDS *.o depend endef SRCS = $(wildcard [a-z]*.c) EXES = $(SRCS:.c=) export GITIGNOREDS .gitignore: $(SRCS) echo $(EXES) | sed ‘s/ /\n/g’ > $@ echo “$$GITIGNOREDS” >> $@ You have to be careful of make expansions (i.e. $(x)) inside … Read more

GNU Make silent by default

If you define the target .SILENT:, then make will not echo anything. It’s usually best to guard the definition, so you can easily turn it off: ifndef VERBOSE .SILENT: endif Now by default, make will print nothing, but if you run make VERBOSE=1, it will print. Note that despite the statement in the manual claiming … Read more

How to force make to always rebuild a file

The classic way to do it is: version.o: .FORCE .FORCE: (and you might add .PHONY: .FORCE). The file ‘.FORCE’ is presumed not to exist, so it is always ‘created’, so version.o is always out of date w.r.t it, so version.o is always compiled. I’m not sure that making version.o into a phony file is correct; … Read more

Autotools: how to cleanup files created by “./configure” in lighttpd project?

I personally would really use the features of a source control software (you should use one) for this. This would cleanup make independent of your build process. See e.g. svn-cleanup or git clean. Nevertheless, automake allows some tweaking when to remove which files. This has (intentionally?) built-in limitations on what files generated by autotools can … Read more

Pre-build step in makefile

I propose two solutions. The first mimics what NetBeans IDE generates: CC=gcc .PHONY: all clean all: post-build pre-build: @echo PRE post-build: main-build @echo POST main-build: pre-build @$(MAKE) –no-print-directory target target: $(OBJS) $(CC) -o $@ $(OBJS) clean: rm -f $(OBJS) target The second one is inpired by what Eclipse IDE generates: CC=gcc .PHONY: all clean .SECONDARY: … Read more

Why are .PHONY implicit pattern rules not triggered?

You’re right, it would make more sense to define the subdir rules as PHONY. But Make does not consider implicit rules for PHONY targets, so you’ll have to rewrite that rule. I suggest the following: SUBDIR_TARGETS = all.subdir clean.subdir .PHONY: all clean $(SUBDIR_TARGETS) $(SUBDIR_TARGETS): %.subdir: $(MAKE) -C src $* $(MAKE) -C dict $* all: all.subdir … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)