*.mk: Support passing specific CFLAGS/LIBS

This commit is contained in:
Quentin Glidic 2012-07-22 22:04:14 +02:00
parent ac7278eb1a
commit 3b1b72ecbb
8 changed files with 40 additions and 24 deletions

View File

@ -5,13 +5,15 @@ CLEAN_TARGETS += clean-i3-config-wizard
i3_config_wizard_SOURCES_GENERATED = i3-config-wizard/cfgparse.tab.c i3-config-wizard/cfgparse.yy.c
i3_config_wizard_SOURCES := $(filter-out $(i3_config_wizard_SOURCES_GENERATED),$(wildcard i3-config-wizard/*.c))
i3_config_wizard_HEADERS := $(wildcard i3-config-wizard/*.h)
i3_config_wizard_CFLAGS =
i3_config_wizard_LIBS =
i3_config_wizard_OBJECTS := $(i3_config_wizard_SOURCES_GENERATED:.c=.o) $(i3_config_wizard_SOURCES:.c=.o)
i3-config-wizard/%.o: i3-config-wizard/%.c $(i3_config_wizard_HEADERS)
echo "[i3-config-wizard] CC $<"
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(CC) $(CPPFLAGS) $(i3_config_wizard_CFLAGS) $(CFLAGS) -c -o $@ $<
i3-config-wizard/cfgparse.yy.c: i3-config-wizard/cfgparse.l i3-config-wizard/cfgparse.tab.o $(i3_config_wizard_HEADERS)
echo "[i3-config-wizard] LEX $<"
@ -23,7 +25,7 @@ i3-config-wizard/cfgparse.tab.c: i3-config-wizard/cfgparse.y $(i3_config_wizard_
i3-config-wizard/i3-config-wizard: libi3.a $(i3_config_wizard_OBJECTS)
echo "[i3-config-wizard] Link i3-config-wizard"
$(CC) $(LDFLAGS) -o $@ $(filter-out libi3.a,$^) $(LIBS)
$(CC) $(LDFLAGS) -o $@ $(filter-out libi3.a,$^) $(i3_config_wizard_LIBS) $(LIBS)
install-i3-config-wizard: i3-config-wizard/i3-config-wizard
echo "[i3-config-wizard] Install"

View File

@ -4,17 +4,19 @@ CLEAN_TARGETS += clean-i3-dump-log
i3_dump_log_SOURCES := $(wildcard i3-dump-log/*.c)
i3_dump_log_HEADERS := $(wildcard i3-dump-log/*.h)
i3_dump_log_CFLAGS =
i3_dump_log_LIBS =
i3_dump_log_OBJECTS := $(i3_dump_log_SOURCES:.c=.o)
i3-dump-log/%.o: i3-dump-log/%.c $(i3_dump_log_HEADERS)
echo "[i3-dump-log] CC $<"
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(CC) $(CPPFLAGS) $(i3_dump_log_CFLAGS) $(CFLAGS) -c -o $@ $<
i3-dump-log/i3-dump-log: libi3.a $(i3_dump_log_OBJECTS)
echo "[i3-dump-log] Link i3-dump-log"
$(CC) $(LDFLAGS) -o $@ $(filter-out libi3.a,$^) $(LIBS)
$(CC) $(LDFLAGS) -o $@ $(filter-out libi3.a,$^) $(i3_dump_log_LIBS) $(LIBS)
install-i3-dump-log: i3-dump-log/i3-dump-log
echo "[i3-dump-log] Install"

View File

@ -4,17 +4,19 @@ CLEAN_TARGETS += clean-i3-input
i3_input_SOURCES := $(wildcard i3-input/*.c)
i3_input_HEADERS := $(wildcard i3-input/*.h)
i3_input_CFLAGS =
i3_input_LIBS =
i3_input_OBJECTS := $(i3_input_SOURCES:.c=.o)
i3-input/%.o: i3-input/%.c $(i3_input_HEADERS)
echo "[i3-input] CC $<"
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(CC) $(CPPFLAGS) $(i3_input_CFLAGS) $(CFLAGS) -c -o $@ $<
i3-input/i3-input: libi3.a $(i3_input_OBJECTS)
echo "[i3-input] Link i3-input"
$(CC) $(LDFLAGS) -o $@ $(filter-out libi3.a,$^) $(LIBS)
$(CC) $(LDFLAGS) -o $@ $(filter-out libi3.a,$^) $(i3_input_LIBS) $(LIBS)
install-i3-input: i3-input/i3-input
echo "[i3-input] Install"

View File

@ -4,17 +4,19 @@ CLEAN_TARGETS += clean-i3-msg
i3_msg_SOURCES := $(wildcard i3-msg/*.c)
i3_msg_HEADERS := $(wildcard i3-msg/*.h)
i3_msg_CFLAGS =
i3_msg_LIBS =
i3_msg_OBJECTS := $(i3_msg_SOURCES:.c=.o)
i3-msg/%.o: i3-msg/%.c $(i3_msg_HEADERS)
echo "[i3-msg] CC $<"
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(CC) $(CPPFLAGS) $(i3_msg_CFLAGS) $(CFLAGS) -c -o $@ $<
i3-msg/i3-msg: libi3.a $(i3_msg_OBJECTS)
echo "[i3-msg] Link i3-msg"
$(CC) $(LDFLAGS) -o $@ $(filter-out libi3.a,$^) $(LIBS)
$(CC) $(LDFLAGS) -o $@ $(filter-out libi3.a,$^) $(i3_msg_LIBS) $(LIBS)
install-i3-msg: i3-msg/i3-msg
echo "[i3-msg] Install"

View File

@ -4,17 +4,19 @@ CLEAN_TARGETS += clean-i3-nagbar
i3_nagbar_SOURCES := $(wildcard i3-nagbar/*.c)
i3_nagbar_HEADERS := $(wildcard i3-nagbar/*.h)
i3_nagbar_CFLAGS =
i3_nagbar_LIBS =
i3_nagbar_OBJECTS := $(i3_nagbar_SOURCES:.c=.o)
i3-nagbar/%.o: i3-nagbar/%.c $(i3_nagbar_HEADERS)
echo "[i3-nagbar] CC $<"
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(CC) $(CPPFLAGS) $(i3_nagbar_CFLAGS) $(CFLAGS) -c -o $@ $<
i3-nagbar/i3-nagbar: libi3.a $(i3_nagbar_OBJECTS)
echo "[i3-nagbar] Link i3-nagbar"
$(CC) $(LDFLAGS) -o $@ $(filter-out libi3.a,$^) $(LIBS)
$(CC) $(LDFLAGS) -o $@ $(filter-out libi3.a,$^) $(i3_nagbar_LIBS) $(LIBS)
install-i3-nagbar: i3-nagbar/i3-nagbar
echo "[i3-nagbar] Install"

View File

@ -4,17 +4,19 @@ CLEAN_TARGETS += clean-i3bar
i3bar_SOURCES := $(wildcard i3bar/src/*.c)
i3bar_HEADERS := $(wildcard i3bar/include/*.h)
i3bar_CFLAGS =
i3bar_LIBS =
i3bar_OBJECTS := $(i3bar_SOURCES:.c=.o)
i3bar/src/%.o: i3bar/src/%.c $(i3bar_HEADERS)
echo "[i3bar] CC $<"
$(CC) $(CPPFLAGS) $(CFLAGS) -Ii3bar/include -c -o $@ $<
$(CC) $(CPPFLAGS) $(i3bar_CFLAGS) $(CFLAGS) -Ii3bar/include -c -o $@ $<
i3bar/i3bar: libi3.a $(i3bar_OBJECTS)
echo "[i3bar] Link i3bar"
$(CC) $(LDFLAGS) -o $@ $(filter-out libi3.a,$^) $(LIBS)
$(CC) $(LDFLAGS) -o $@ $(filter-out libi3.a,$^) $(i3bar_LIBS) $(LIBS)
install-i3bar: i3bar/i3bar
echo "[i3bar] Install"

View File

@ -2,17 +2,19 @@ CLEAN_TARGETS += clean-libi3
libi3_SOURCES := $(wildcard libi3/*.c)
libi3_HEADERS := $(wildcard libi3/*.h)
libi3_CFLAGS =
libi3_LIBS =
libi3_OBJECTS := $(libi3_SOURCES:.c=.o)
libi3/%.o: libi3/%.c $(libi3_HEADERS)
echo "[libi3] CC $<"
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(CC) $(CPPFLAGS) $(libi3_CFLAGS) $(CFLAGS) -c -o $@ $<
libi3.a: $(libi3_OBJECTS)
echo "[libi3] AR libi3.a"
ar rcs $@ $^
ar rcs $@ $^ $(libi3_LIBS)
clean-libi3:
echo "[libi3] Clean"

View File

@ -6,12 +6,14 @@ i3_SOURCES_GENERATED = src/cfgparse.tab.c src/cfgparse.yy.c
i3_SOURCES := $(filter-out $(i3_SOURCES_GENERATED),$(wildcard src/*.c))
i3_HEADERS_CMDPARSER := $(wildcard include/GENERATED_*.h)
i3_HEADERS := $(filter-out $(i3_HEADERS_CMDPARSER),$(wildcard include/*.h))
i3_CFLAGS =
i3_LIBS =
i3_OBJECTS := $(i3_SOURCES_GENERATED:.c=.o) $(i3_SOURCES:.c=.o)
src/%.o: src/%.c $(i3_HEADERS)
echo "[i3] CC $<"
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(CC) $(CPPFLAGS) $(i3_CFLAGS) $(CFLAGS) -c -o $@ $<
src/cfgparse.yy.c: src/cfgparse.l src/cfgparse.tab.o $(i3_HEADERS)
echo "[i3] LEX $<"
@ -26,8 +28,8 @@ src/cfgparse.tab.c: src/cfgparse.y $(i3_HEADERS)
# and once as an object file for i3.
src/commands_parser.o: src/commands_parser.c $(i3_HEADERS) i3-command-parser.stamp
echo "[i3] CC $<"
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -DTEST_PARSER -o test.commands_parser $< $(LIBS)
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(CC) $(CPPFLAGS) $(i3_CFLAGS) $(CFLAGS) $(LDFLAGS) -DTEST_PARSER -o test.commands_parser $< $(i3_LIBS) $(LIBS)
$(CC) $(CPPFLAGS) $(i3_CFLAGS) $(CFLAGS) -c -o $@ $<
i3-command-parser.stamp: generate-command-parser.pl parser-specs/commands.spec
echo "[i3] Generating command parser"
@ -36,7 +38,7 @@ i3-command-parser.stamp: generate-command-parser.pl parser-specs/commands.spec
i3: libi3.a $(i3_OBJECTS)
echo "[i3] Link i3"
$(CC) $(LDFLAGS) -o $@ $(filter-out libi3.a,$^) $(LIBS)
$(CC) $(LDFLAGS) -o $@ $(filter-out libi3.a,$^) $(i3_LIBS) $(LIBS)
install-i3: i3
echo "[i3] Install"