dependencies - Get makefile to build two targets from the same file but with different flags -
i'm changing project makefile in order build executable same passing different flag compiler.
before changing it, makefile this:
targets = elilo.efi : check_gcc $(subdirs) $(targets) elilo.efi : elilo.so elilo.so : $(files) elilo.o : elilo.c $(arch)/sysdeps.h ... $(subdirs): dummy $(make) -c $@ ... include make.rules
where:
$(subdirs)
stores subdirs of project$(files)
, store .o files must created in order link elilo.so- and
check_gcc
checks compiler version , exits if needed
additionally, make.rules contains general rules compile , link files:
%.efi: %.so $(objcopy) -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel \ -j .rela -j .reloc --target=$(format) $*.so $@ %.so: %.o $(ld) $(ldflags) $^ -o $@ $(loadlibes) %.o: %.c # rule number 1 $(cc) $(incdir) $(cflags) $(cppflags) -c $< -o $@ # rule .s %.o: %.s $(cc) $(incdir) $(cflags) $(cppflags) -c $< -o $@
my try:
so far, i've tried following in order have new target , be able compile them both rule
targets = elilo.efi usb : $(targets) elilo.efi : check_gcc $(subdirs) elilo.so touch $@.touch elilo.so : $(files) .phony : usb usb : check_gcc $(subdirs) cflags += "-dboot64" $(make) boot64.efi touch $@.touch boot64.efi : elilo.so $(objcopy) -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel \ -j .rela -j .reloc --target=$(format) $> $@
with make.rules:
%.efi: %.so $(objcopy) -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel \ -j .rela -j .reloc --target=$(format) $*.so $@ %.so: %.o $(ld) $(ldflags) $^ -o $@ $(loadlibes) %.o: %.c usb.touch elilo.touch # rule number 1 $(cc) $(incdir) $(cflags) $(cppflags) -c $< -o $@ ...
but doesn't change i've made rule number 1 stops when making $(subdirs)
, because rule general affects every object file in project directory , sub-directories...
basically, want is build boot64.efi elilo.efi passing flag -dboot64 compiler .c files change behaviour. tips on how that?
i think shoud rm elilo.so :
usb : check_gcc $(subdirs) rm elilo.so cflags += "-dboot64" $(make) boot64.efi touch $@.touch
because if elilo.so build without "boot64" won't rebuild
Comments
Post a Comment